diff options
Diffstat (limited to 'src/fltk-widgets-groups-text_displays-text_editors.ads')
-rw-r--r-- | src/fltk-widgets-groups-text_displays-text_editors.ads | 253 |
1 files changed, 185 insertions, 68 deletions
diff --git a/src/fltk-widgets-groups-text_displays-text_editors.ads b/src/fltk-widgets-groups-text_displays-text_editors.ads index 6f5131d..e6355c7 100644 --- a/src/fltk-widgets-groups-text_displays-text_editors.ads +++ b/src/fltk-widgets-groups-text_displays-text_editors.ads @@ -4,11 +4,14 @@ -- Released into the public domain -private with +with - Interfaces.C, Ada.Containers.Vectors; +private with + + Interfaces.C; + package FLTK.Widgets.Groups.Text_Displays.Text_Editors is @@ -34,7 +37,11 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is Func : Key_Func; end record; - type Key_Binding_List is array (Positive range <>) of Key_Binding; + type Key_Binding_Array is array (Positive range <>) of Key_Binding; + + package Key_Binding_Vectors is new Ada.Containers.Vectors + (Index_Type => Positive, + Element_Type => Key_Binding); @@ -57,29 +64,29 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is - procedure Default + procedure KF_Default (This : in out Text_Editor'Class; Key : in Key_Combo); - procedure Undo + procedure KF_Undo (This : in out Text_Editor'Class); - procedure Cut + procedure KF_Cut (This : in out Text_Editor'Class); - procedure Copy + procedure KF_Copy (This : in out Text_Editor'Class); - procedure Paste + procedure KF_Paste (This : in out Text_Editor'Class); - procedure Delete + procedure KF_Delete (This : in out Text_Editor'Class); - procedure Select_All + procedure KF_Select_All (This : in out Text_Editor'Class); @@ -97,6 +104,9 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is procedure KF_Ignore (This : in out Text_Editor'Class); + procedure KF_Tab + (This : in out Text_Editor'Class); + @@ -208,54 +218,133 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is - Default_Key_Bindings : constant Key_Binding_List := - ((Mod_None + Enter_Key, KF_Enter'Access), - (Mod_None + Keypad_Enter_Key, KF_Enter'Access), - (Mod_None + Backspace_Key, KF_Backspace'Access), - (Mod_None + Insert_Key, KF_Insert'Access), + procedure KF_Meta_Home + (This : in out Text_Editor'Class); - (Mod_None + Delete_Key, Delete'Access), - (Mod_Ctrl + 'c', Copy'Access), - (Mod_Ctrl + 'v', Paste'Access), - (Mod_Ctrl + 'x', Cut'Access), - (Mod_Ctrl + 'z', Undo'Access), - (Mod_Ctrl + 'a', Select_All'Access), + procedure KF_Meta_End + (This : in out Text_Editor'Class); - (Mod_None + Home_Key, KF_Home'Access), - (Mod_None + End_Key, KF_End'Access), - (Mod_None + Page_Down_Key, KF_Page_Down'Access), - (Mod_None + Page_Up_Key, KF_Page_Up'Access), - (Mod_None + Down_Key, KF_Down'Access), - (Mod_None + Left_Key, KF_Left'Access), - (Mod_None + Right_Key, KF_Right'Access), - (Mod_None + Up_Key, KF_Up'Access), + procedure KF_Meta_Page_Down + (This : in out Text_Editor'Class); - (Mod_Shift + Home_Key, KF_Shift_Home'Access), - (Mod_Shift + End_Key, KF_Shift_End'Access), - (Mod_Shift + Page_Down_Key, KF_Shift_Page_Down'Access), - (Mod_Shift + Page_Up_Key, KF_Shift_Page_Up'Access), - (Mod_Shift + Down_Key, KF_Shift_Down'Access), - (Mod_Shift + Left_Key, KF_Shift_Left'Access), - (Mod_Shift + Right_Key, KF_Shift_Right'Access), - (Mod_Shift + Up_Key, KF_Shift_Up'Access), + procedure KF_Meta_Page_Up + (This : in out Text_Editor'Class); - (Mod_Ctrl + Home_Key, KF_Ctrl_Home'Access), - (Mod_Ctrl + End_Key, KF_Ctrl_End'Access), - (Mod_Ctrl + Page_Down_Key, KF_Ctrl_Page_Down'Access), - (Mod_Ctrl + Page_Up_Key, KF_Ctrl_Page_Up'Access), - (Mod_Ctrl + Down_Key, KF_Ctrl_Down'Access), - (Mod_Ctrl + Left_Key, KF_Ctrl_Left'Access), - (Mod_Ctrl + Right_Key, KF_Ctrl_Right'Access), - (Mod_Ctrl + Up_Key, KF_Ctrl_Up'Access), + procedure KF_Meta_Down + (This : in out Text_Editor'Class); - (Mod_Ctrl + Mod_Shift + Home_Key, KF_Ctrl_Shift_Home'Access), - (Mod_Ctrl + Mod_Shift + End_Key, KF_Ctrl_Shift_End'Access), - (Mod_Ctrl + Mod_Shift + Page_Down_Key, KF_Ctrl_Shift_Page_Down'Access), - (Mod_Ctrl + Mod_Shift + Page_Up_Key, KF_Ctrl_Shift_Page_Up'Access), - (Mod_Ctrl + Mod_Shift + Down_Key, KF_Ctrl_Shift_Down'Access), - (Mod_Ctrl + Mod_Shift + Left_Key, KF_Ctrl_Shift_Left'Access), - (Mod_Ctrl + Mod_Shift + Right_Key, KF_Ctrl_Shift_Right'Access), - (Mod_Ctrl + Mod_Shift + Up_Key, KF_Ctrl_Shift_Up'Access)); + procedure KF_Meta_Left + (This : in out Text_Editor'Class); + + procedure KF_Meta_Right + (This : in out Text_Editor'Class); + + procedure KF_Meta_Up + (This : in out Text_Editor'Class); + + + + + procedure KF_Meta_Shift_Home + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_End + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_Page_Down + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_Page_Up + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_Down + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_Left + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_Right + (This : in out Text_Editor'Class); + + procedure KF_Meta_Shift_Up + (This : in out Text_Editor'Class); + + + + + Default_Key_Bindings : constant Key_Binding_Array := + ((Mod_None + Escape_Key, KF_Ignore'Access), + (Mod_None + Enter_Key, KF_Enter'Access), + (Mod_None + Keypad_Enter_Key, KF_Enter'Access), + (Mod_None + Backspace_Key, KF_Backspace'Access), + (Mod_None + Insert_Key, KF_Insert'Access), + (Mod_None + Tab_Key, KF_Tab'Access), + + (Mod_None + Delete_Key, KF_Delete'Access), + (Mod_Command + 'c', KF_Copy'Access), + (Mod_Command + 'v', KF_Paste'Access), + (Mod_Command + 'x', KF_Cut'Access), + (Mod_Command + 'z', KF_Undo'Access), + (Mod_Command + 'a', KF_Select_All'Access), + + -- Ctrl+'/' Shift+Del Ctrl+Insert Shift+Insert all intentionally absent + + (Mod_None + Home_Key, KF_Home'Access), + (Mod_None + End_Key, KF_End'Access), + (Mod_None + Page_Down_Key, KF_Page_Down'Access), + (Mod_None + Page_Up_Key, KF_Page_Up'Access), + (Mod_None + Down_Key, KF_Down'Access), + (Mod_None + Left_Key, KF_Left'Access), + (Mod_None + Right_Key, KF_Right'Access), + (Mod_None + Up_Key, KF_Up'Access), + + (Mod_Shift + Home_Key, KF_Shift_Home'Access), + (Mod_Shift + End_Key, KF_Shift_End'Access), + (Mod_Shift + Page_Down_Key, KF_Shift_Page_Down'Access), + (Mod_Shift + Page_Up_Key, KF_Shift_Page_Up'Access), + (Mod_Shift + Down_Key, KF_Shift_Down'Access), + (Mod_Shift + Left_Key, KF_Shift_Left'Access), + (Mod_Shift + Right_Key, KF_Shift_Right'Access), + (Mod_Shift + Up_Key, KF_Shift_Up'Access), + + (Mod_Ctrl + Home_Key, KF_Ctrl_Home'Access), + (Mod_Ctrl + End_Key, KF_Ctrl_End'Access), + (Mod_Ctrl + Page_Down_Key, KF_Ctrl_Page_Down'Access), + (Mod_Ctrl + Page_Up_Key, KF_Ctrl_Page_Up'Access), + (Mod_Ctrl + Down_Key, KF_Ctrl_Down'Access), + (Mod_Ctrl + Left_Key, KF_Ctrl_Left'Access), + (Mod_Ctrl + Right_Key, KF_Ctrl_Right'Access), + (Mod_Ctrl + Up_Key, KF_Ctrl_Up'Access), + + (Mod_Ctrl + Mod_Shift + Home_Key, KF_Ctrl_Shift_Home'Access), + (Mod_Ctrl + Mod_Shift + End_Key, KF_Ctrl_Shift_End'Access), + (Mod_Ctrl + Mod_Shift + Page_Down_Key, KF_Ctrl_Shift_Page_Down'Access), + (Mod_Ctrl + Mod_Shift + Page_Up_Key, KF_Ctrl_Shift_Page_Up'Access), + (Mod_Ctrl + Mod_Shift + Down_Key, KF_Ctrl_Shift_Down'Access), + (Mod_Ctrl + Mod_Shift + Left_Key, KF_Ctrl_Shift_Left'Access), + (Mod_Ctrl + Mod_Shift + Right_Key, KF_Ctrl_Shift_Right'Access), + (Mod_Ctrl + Mod_Shift + Up_Key, KF_Ctrl_Shift_Up'Access), + + (Mod_Meta + Home_Key, KF_Meta_Home'Access), + (Mod_Meta + End_Key, KF_Meta_End'Access), + (Mod_Meta + Page_Down_Key, KF_Meta_Page_Down'Access), + (Mod_Meta + Page_Up_Key, KF_Meta_Page_Up'Access), + (Mod_Meta + Down_Key, KF_Meta_Down'Access), + (Mod_Meta + Left_Key, KF_Meta_Left'Access), + (Mod_Meta + Right_Key, KF_Meta_Right'Access), + (Mod_Meta + Up_Key, KF_Meta_Up'Access), + + (Mod_Meta + Mod_Shift + Home_Key, KF_Meta_Shift_Home'Access), + (Mod_Meta + Mod_Shift + End_Key, KF_Meta_Shift_End'Access), + (Mod_Meta + Mod_Shift + Page_Down_Key, KF_Meta_Shift_Page_Down'Access), + (Mod_Meta + Mod_Shift + Page_Up_Key, KF_Meta_Shift_Page_Up'Access), + (Mod_Meta + Mod_Shift + Down_Key, KF_Meta_Shift_Down'Access), + (Mod_Meta + Mod_Shift + Left_Key, KF_Meta_Shift_Left'Access), + (Mod_Meta + Mod_Shift + Right_Key, KF_Meta_Shift_Right'Access), + (Mod_Meta + Mod_Shift + Up_Key, KF_Meta_Shift_Up'Access)); + + + Global_Key_Bindings : Key_Binding_Vectors.Vector; @@ -271,13 +360,17 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is procedure Add_Key_Bindings (This : in out Text_Editor; - List : in Key_Binding_List); + Bind : in Key_Binding_Array); function Get_Bound_Key_Function (This : in Text_Editor; Key : in Key_Combo) return Key_Func; + function Get_All_Bound_Key_Functions + (This : in Text_Editor) + return Key_Binding_Array; + procedure Remove_Key_Binding (This : in out Text_Editor; Key : in Key_Combo); @@ -288,7 +381,7 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is procedure Remove_Key_Bindings (This : in out Text_Editor; - List : in Key_Binding_List); + Bind : in Key_Binding_Array); procedure Remove_All_Key_Bindings (This : in out Text_Editor); @@ -331,16 +424,19 @@ package FLTK.Widgets.Groups.Text_Displays.Text_Editors is Event : in Event_Kind) return Event_Outcome; + function Handle_Key + (This : in out Text_Editor) + return Event_Outcome; -private + procedure Maybe_Do_Callback + (This : in out Text_Editor); - package Binding_Vectors is new Ada.Containers.Vectors - (Index_Type => Positive, Element_Type => Key_Binding); +private type Text_Editor is new Text_Display with record - Bindings : Binding_Vectors.Vector; + Bindings : Key_Binding_Vectors.Vector; Default_Func : Default_Key_Func; end record; @@ -369,19 +465,20 @@ private package Editor_Convert is new System.Address_To_Access_Conversions (Text_Editor'Class); - pragma Inline (Default); + pragma Inline (KF_Default); - pragma Inline (Undo); - pragma Inline (Cut); - pragma Inline (Copy); - pragma Inline (Paste); - pragma Inline (Delete); - pragma Inline (Select_All); + pragma Inline (KF_Undo); + pragma Inline (KF_Cut); + pragma Inline (KF_Copy); + pragma Inline (KF_Paste); + pragma Inline (KF_Delete); + pragma Inline (KF_Select_All); pragma Inline (KF_Backspace); pragma Inline (KF_Insert); pragma Inline (KF_Enter); pragma Inline (KF_Ignore); + pragma Inline (KF_Tab); pragma Inline (KF_Home); pragma Inline (KF_End); @@ -419,6 +516,24 @@ private pragma Inline (KF_Ctrl_Shift_Right); pragma Inline (KF_Ctrl_Shift_Up); + pragma Inline (KF_Meta_Home); + pragma Inline (KF_Meta_End); + pragma Inline (KF_Meta_Page_Down); + pragma Inline (KF_Meta_Page_Up); + pragma Inline (KF_Meta_Down); + pragma Inline (KF_Meta_Left); + pragma Inline (KF_Meta_Right); + pragma Inline (KF_Meta_Up); + + pragma Inline (KF_Meta_Shift_Home); + pragma Inline (KF_Meta_Shift_End); + pragma Inline (KF_Meta_Shift_Page_Down); + pragma Inline (KF_Meta_Shift_Page_Up); + pragma Inline (KF_Meta_Shift_Down); + pragma Inline (KF_Meta_Shift_Left); + pragma Inline (KF_Meta_Shift_Right); + pragma Inline (KF_Meta_Shift_Up); + pragma Inline (Add_Key_Binding); pragma Inline (Remove_All_Key_Bindings); pragma Inline (Get_Default_Key_Function); @@ -427,10 +542,12 @@ private pragma Inline (Get_Insert_Mode); pragma Inline (Set_Insert_Mode); - -- pragma Inline (Get_Tab_Nav_Mode); - -- pragma Inline (Set_Tab_Nav_Mode); + pragma Inline (Get_Tab_Mode); + pragma Inline (Set_Tab_Mode); pragma Inline (Handle); + pragma Inline (Handle_Key); + pragma Inline (Maybe_Do_Callback); end FLTK.Widgets.Groups.Text_Displays.Text_Editors; |