summaryrefslogtreecommitdiff
path: root/src/fltk-widgets-groups-text_displays-text_editors.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/fltk-widgets-groups-text_displays-text_editors.adb')
-rw-r--r--src/fltk-widgets-groups-text_displays-text_editors.adb88
1 files changed, 45 insertions, 43 deletions
diff --git a/src/fltk-widgets-groups-text_displays-text_editors.adb b/src/fltk-widgets-groups-text_displays-text_editors.adb
index c15cefa..0653c89 100644
--- a/src/fltk-widgets-groups-text_displays-text_editors.adb
+++ b/src/fltk-widgets-groups-text_displays-text_editors.adb
@@ -431,6 +431,50 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
-- (Escape_Key, -1));
+ procedure Extra_Init
+ (This : in out Text_Editor;
+ X, Y, W, H : in Integer;
+ Text : in String) is
+ begin
+ -- change things over so key bindings are all handled from the Ada side
+ This.Bindings := Binding_Vectors.Empty_Vector;
+ for B of Default_Key_Bindings loop
+ This.Bindings.Append (B);
+ end loop;
+ This.Default_Func := Default'Access;
+
+ -- remove these loops and uncomment subsequent "remove_all_key_bindings"
+ -- when FLTK keybindings fixed
+ -- for B of To_Remove_List loop
+ -- fl_text_editor_remove_key_binding
+ -- (This.Void_Ptr,
+ -- Interfaces.C.int (B.Press),
+ -- B.Modif * 65536);
+ -- end loop;
+ -- for B of To_Remove_Weird loop
+ -- fl_text_editor_remove_key_binding
+ -- (This.Void_Ptr,
+ -- Interfaces.C.int (B.Press),
+ -- B.Modif);
+ -- end loop;
+ fl_text_editor_remove_all_key_bindings (This.Void_Ptr);
+
+ fl_text_editor_set_default_key_function
+ (This.Void_Ptr, Storage.To_Integer (Key_Func_Hook'Address));
+
+ -- this is irritatingly required due to how FLTK handles certain keys
+ -- for B of Default_Key_Bindings loop
+ -- -- remove this conditional once FLTK keybindings fixed
+ -- if B.Key.Modcode = Mod_None then
+ -- fl_text_editor_add_key_binding
+ -- (This.Void_Ptr,
+ -- Interfaces.C.int (B.Key.Keycode),
+ -- Interfaces.C.int (B.Key.Modcode) * 65536,
+ -- Key_Func_Hook'Address);
+ -- end if;
+ -- end loop;
+ Extra_Init (Text_Display (This), X, Y, W, H, Text);
+ end Extra_Init;
package body Forge is
@@ -449,53 +493,11 @@ package body FLTK.Widgets.Groups.Text_Displays.Text_Editors is
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
- fl_group_end (This.Void_Ptr);
- fl_widget_set_user_data
- (This.Void_Ptr,
- Storage.To_Integer (Widget_Convert.To_Address (This'Unchecked_Access)));
+ Extra_Init (This, X, Y, W, H, Text);
text_editor_set_draw_hook
(This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address));
text_editor_set_handle_hook
(This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address));
- fl_widget_set_label (This.Void_Ptr, Interfaces.C.To_C (Text));
-
- -- change things over so key bindings are all handled from the Ada side
- This.Bindings := Binding_Vectors.Empty_Vector;
- for B of Default_Key_Bindings loop
- This.Bindings.Append (B);
- end loop;
- This.Default_Func := Default'Access;
-
- -- remove these loops and uncomment subsequent "remove_all_key_bindings"
- -- when FLTK keybindings fixed
- -- for B of To_Remove_List loop
- -- fl_text_editor_remove_key_binding
- -- (This.Void_Ptr,
- -- Interfaces.C.int (B.Press),
- -- B.Modif * 65536);
- -- end loop;
- -- for B of To_Remove_Weird loop
- -- fl_text_editor_remove_key_binding
- -- (This.Void_Ptr,
- -- Interfaces.C.int (B.Press),
- -- B.Modif);
- -- end loop;
- fl_text_editor_remove_all_key_bindings (This.Void_Ptr);
-
- fl_text_editor_set_default_key_function
- (This.Void_Ptr, Storage.To_Integer (Key_Func_Hook'Address));
-
- -- this is irritatingly required due to how FLTK handles certain keys
- -- for B of Default_Key_Bindings loop
- -- -- remove this conditional once FLTK keybindings fixed
- -- if B.Key.Modcode = Mod_None then
- -- fl_text_editor_add_key_binding
- -- (This.Void_Ptr,
- -- Interfaces.C.int (B.Key.Keycode),
- -- Interfaces.C.int (B.Key.Modcode) * 65536,
- -- Key_Func_Hook'Address);
- -- end if;
- -- end loop;
end return;
end Create;