summaryrefslogtreecommitdiff
path: root/src/editor_windows.adb
blob: 7fdf7442689b44ca4a12e9c80ff436b8c5bd929d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118


with FLTK.Enums;
use FLTK.Enums;


package body Editor_Windows is


    function Create
           (X, Y, W, H : in Integer;
            Label_Text : in String)
        return Editor_Window is

        Width, Height : Integer;

    begin
        if W < 300 then Width := 300; else Width := W; end if;
        if H < 60 then Height := 60; else Height := H; end if;

        return This : Editor_Window :=
                   (Double_Window'(Create (X, Y, Width, Height, Label_Text)) with
                    Editor => Text_Editor'(Create (0, 30, Width, Height - 30, "")),
                    Bar => Menu_Bar'(Create (0, 0, Width, 30, ""))) do
            This.Add (This.Editor);
            This.Add (This.Bar);
            This.Editor.Set_Text_Font (Courier);
        end return;
    end Create;




    function Create
           (W, H : in Integer)
        return Editor_Window is
    begin
        return Create (0, 0, W, H, "(Untitled)");
    end Create;




    function Get_Buffer
           (This : in Editor_Window)
        return Text_Buffer_Cursor is
    begin
        return This.Editor.Get_Buffer;
    end Get_Buffer;




    procedure Set_Buffer
           (This : in out Editor_Window;
            Buff : in out Text_Buffer) is
    begin
        This.Editor.Set_Buffer (Buff);
    end Set_Buffer;




    function Get_Menu
           (This : in out Editor_Window)
        return Menu_Cursor is
    begin
        return Ref : Menu_Cursor (This.Bar'Access);
    end Get_Menu;




    procedure Undo
           (This : in out Editor_Window) is
    begin
        This.Editor.Undo;
    end Undo;




    procedure Cut
           (This : in out Editor_Window) is
    begin
        This.Editor.Cut;
    end Cut;




    procedure Copy
           (This : in out Editor_Window) is
    begin
        This.Editor.Copy;
    end Copy;




    procedure Paste
           (This : in out Editor_Window) is
    begin
        This.Editor.Paste;
    end Paste;




    procedure Delete
           (This : in out Editor_Window) is
    begin
        This.Editor.Delete;
    end Delete;


end Editor_Windows;