summaryrefslogtreecommitdiff
path: root/src/windows-editor.adb
blob: cfcf19171c3e9badadc81db53c3ad27de41f3f18 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228


package body Windows.Editor is


    package WD renames FLTK.Widgets.Groups.Windows.Double;
    package TD renames FLTK.Widgets.Groups.Text_Displays;
    package TE renames FLTK.Widgets.Groups.Text_Displays.Text_Editors;
    package MB renames FLTK.Widgets.Menus.Menu_Bars;
    package MU renames FLTK.Widgets.Menus.Menu_Buttons;




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

        Width       : Integer := Min_Editor_Width;
        Height      : Integer := Min_Editor_Height;
        Menu_Height : Integer := 22;
    begin
        if Width < W then
            Width := W;
        end if;

        if Height < H then
            Height := H;
        end if;

        return This : Editor_Window :=
                   (WD.Double_Window'(WD.Create (X, Y, Width, Height, Label_Text)) with

                    Editor => TE.Text_Editor'(TE.Create
                        (0, Menu_Height, Width, Height - Menu_Height, "")),
                    Bar => MB.Menu_Bar'(MB.Create
                        (0, 0, Width, Menu_Height, "")),
                    Popup => MU.Menu_Button'(MU.Create
                        (0, Menu_Height, Width, Height - Menu_Height, ""))) do

            This.Editor.Set_Text_Font (Courier);
            This.Add (This.Editor);

            This.Bar.Set_Box (No_Box);
            This.Add (This.Bar);

            This.Popup.Set_Box (No_Box);
            This.Popup.Set_Popup_Kind (MU.Popup3);
            This.Add (This.Popup);

            This.Set_Resizable (This.Editor);
            This.Set_Size_Range (Min_Editor_Width, Min_Editor_Height);

            This.Set_Icon (Logo);

            This.Editor.Remove_Key_Binding (Mod_Ctrl + 'z');
        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 FLTK.Text_Buffers.Text_Buffer_Cursor is
    begin
        return This.Editor.Get_Buffer;
    end Get_Buffer;




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




    function Get_Menu_Bar
           (This : in out Editor_Window)
        return FLTK.Widgets.Menus.Menu_Cursor is
    begin
        return Ref : FLTK.Widgets.Menus.Menu_Cursor (This.Bar'Access);
    end Get_Menu_Bar;




    function Get_Rightclick_Menu
           (This : in out Editor_Window)
        return FLTK.Widgets.Menus.Menu_Cursor is
    begin
        return Ref : FLTK.Widgets.Menus.Menu_Cursor (This.Popup'Access);
    end Get_Rightclick_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;




    function Get_Insert_Position
           (This : in Editor_Window)
        return Natural is
    begin
        return This.Editor.Get_Insert_Position;
    end Get_Insert_Position;




    procedure Set_Insert_Position
           (This : in out Editor_Window;
            Pos  : in     Natural) is
    begin
        This.Editor.Set_Insert_Position (Pos);
    end Set_Insert_Position;




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




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




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




    procedure Set_Wrap_Mode
           (This   : in out Editor_Window;
            Mode   : in     Wrap_Mode;
            Margin : in     Natural := 0) is
    begin
        This.Editor.Set_Wrap_Mode (TD.Wrap_Mode (Mode), Margin);
    end Set_Wrap_Mode;




    procedure Set_Linenumber_Width
           (This  : in out Editor_Window;
            Width : in     Natural) is
    begin
        This.Editor.Set_Linenumber_Width (Width);
    end Set_Linenumber_Width;


end Windows.Editor;