diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-12 01:45:26 +1300 | 
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-12 01:45:26 +1300 | 
| commit | 1e676b49bee920605529fd5e8f18c14fdfc900e2 (patch) | |
| tree | f56fa019065062194c7a077d545870e95fcd1260 | |
| parent | a937e0b2a25d49e813d85fa3da14ea0c6882ff2f (diff) | |
Updated to current FLTK binding
| -rw-r--r-- | adapad.gpr | 2 | ||||
| -rw-r--r-- | src/adapad.adb | 46 | ||||
| -rw-r--r-- | src/windows-jump.adb | 14 | ||||
| -rw-r--r-- | src/windows-jump.ads | 4 | 
4 files changed, 37 insertions, 29 deletions
@@ -25,7 +25,7 @@ project AdaPad is      package Compiler is -        for Default_Switches("Ada") use ("-gnaty4aAbcefhiklM99nprt"); +        for Default_Switches("Ada") use ("-gnaty4aAbcefhiklM100nprt");      end Compiler; diff --git a/src/adapad.adb b/src/adapad.adb index c24bb6e..5f1f347 100644 --- a/src/adapad.adb +++ b/src/adapad.adb @@ -5,7 +5,7 @@ with      FLTK.Widgets.Menus,      FLTK.Widgets.Groups.Windows,      FLTK.Text_Buffers, -    FLTK.Dialogs, +    FLTK.Asks,      Windows.Editor,      Windows.About,      Windows.Find, @@ -94,7 +94,7 @@ package body Adapad is          if not Safe_To_Discard then return; end if;          declare              New_Filename : String := -                FLTK.Dialogs.File_Chooser ("Open File?", "*", To_String (Filename)); +                FLTK.Asks.File_Chooser ("Open File?", "*", To_String (Filename));          begin              if New_Filename /= "" then                  Load_File (New_Filename); @@ -309,7 +309,7 @@ package body Adapad is              Result := Result + 1;          end loop;          Editor.Set_Insert_Position (Restore_Position); -        FLTK.Dialogs.Message_Box +        FLTK.Asks.Message_Box                 ("There are " & Integer'Image (Result) & " words in the document.");      end Count_CB; @@ -452,7 +452,7 @@ package body Adapad is              Bar.Find_Item ("&Search/Find &Next").Activate;              Bar.Find_Item ("&Search/Find &Previous").Activate;          else -            FLTK.Dialogs.Alert ("No occurrences of '" & Item & "' found!"); +            FLTK.Asks.Alert ("No occurrences of '" & Item & "' found!");              Bar.Find_Item ("&Search/Find &Next").Deactivate;              Bar.Find_Item ("&Search/Find &Previous").Deactivate;          end if; @@ -465,8 +465,8 @@ package body Adapad is             (Item, Replace_With      : in String;              Match_Case, Replace_All : in Boolean)      is -        use type FLTK.Dialogs.Choice; -        User_Response : FLTK.Dialogs.Choice; +        use type FLTK.Asks.Choice_Result; +        User_Response : FLTK.Asks.Choice_Result;          Found_At : Natural;          Current_Position, Times_Replaced : Natural := 0;      begin @@ -477,13 +477,13 @@ package body Adapad is              Editor.Set_Insert_Position (Found_At);              Editor.Show_Insert_Position;              if not Replace_All then -                User_Response := FLTK.Dialogs.Three_Way_Choice +                User_Response := FLTK.Asks.Choice                         ("Replace?", "No", "Yes", "Cancel");              else -                User_Response := FLTK.Dialogs.Second; +                User_Response := FLTK.Asks.Second;              end if; -            exit when User_Response = FLTK.Dialogs.Third; -            if User_Response = FLTK.Dialogs.Second then +            exit when User_Response = FLTK.Asks.Third; +            if User_Response = FLTK.Asks.Second then                  Buffer.Remove_Selection;                  Buffer.Insert_Text (Found_At, Replace_With);                  Current_Position := Found_At + Replace_With'Length; @@ -494,10 +494,10 @@ package body Adapad is          end loop;          if Times_Replaced > 0 then -            FLTK.Dialogs.Message_Box +            FLTK.Asks.Message_Box                  ("Replaced " & Integer'Image (Times_Replaced) & " occurrences.");          else -            FLTK.Dialogs.Alert ("No occurrences of '" & Item & "' found!"); +            FLTK.Asks.Alert ("No occurrences of '" & Item & "' found!");          end if;      end Do_Replace_CB; @@ -537,20 +537,20 @@ package body Adapad is      function Safe_To_Discard          return Boolean      is -        User_Response : FLTK.Dialogs.Choice; +        User_Response : FLTK.Asks.Choice_Result;      begin          if not Changed then return True; end if; -        User_Response := FLTK.Dialogs.Three_Way_Choice +        User_Response := FLTK.Asks.Choice                 ("The current file has not been saved." & Character'Val (10) &                  "Would you like to save it now?",                  "Cancel", "Save", "Discard");          case User_Response is -            when FLTK.Dialogs.First => +            when FLTK.Asks.First =>                  return False; -            when FLTK.Dialogs.Second => +            when FLTK.Asks.Second =>                  Do_Save;                  return not Changed; -            when FLTK.Dialogs.Third => +            when FLTK.Asks.Third =>                  return True;          end case;      end Safe_To_Discard; @@ -571,7 +571,7 @@ package body Adapad is      procedure Do_Save_As is -        New_Filename : String := FLTK.Dialogs.File_Chooser +        New_Filename : String := FLTK.Asks.File_Chooser                 ("Save File As?", "*", To_String (Filename));      begin          if New_Filename /= "" then @@ -594,7 +594,7 @@ package body Adapad is          Editor.Get_Menu_Bar.Find_Item ("&Edit/&Redo").Deactivate;      exception          when Storage_Error => -            FLTK.Dialogs.Alert ("Error reading from file " & Name); +            FLTK.Asks.Alert ("Error reading from file " & Name);      end Load_File; @@ -609,7 +609,7 @@ package body Adapad is          Set_Title;      exception          when Storage_Error => -            FLTK.Dialogs.Alert ("Error writing to file " & Name); +            FLTK.Asks.Alert ("Error writing to file " & Name);      end Save_File; @@ -646,7 +646,8 @@ begin          Bar.Add (Text => "&Edit", Flags => Flag_Submenu);          Bar.Add ("Edit/&Undo", Undo_CB'Access, Mod_Ctrl + 'z', Flag_Inactive); -        Bar.Add ("Edit/&Redo", Redo_CB'Access, Mod_Shift + Mod_Ctrl + 'z', Flag_Inactive + Flag_Divider); +        Bar.Add ("Edit/&Redo", Redo_CB'Access, Mod_Shift + Mod_Ctrl + 'z', +            Flag_Inactive + Flag_Divider);          Bar.Add ("Edit/Cu&t", Cut_CB'Access, Mod_Ctrl + 'x', Flag_Inactive);          Bar.Add ("Edit/&Copy", Copy_CB'Access, Mod_Ctrl + 'c', Flag_Inactive);          Bar.Add ("Edit/&Paste", Paste_CB'Access, Mod_Ctrl + 'v'); @@ -656,7 +657,8 @@ begin          Bar.Add (Text => "&Search", Flags => Flag_Submenu);          Bar.Add ("Search/&Find...", Find_CB'Access, Mod_Ctrl + 'f');          Bar.Add ("Search/Find &Next", Find_Next_CB'Access, Mod_Ctrl + 'g', Flag_Inactive); -        Bar.Add ("Search/Find &Previous", Find_Prev_CB'Access, Mod_Shift + Mod_Ctrl + 'g', Flag_Inactive); +        Bar.Add ("Search/Find &Previous", Find_Prev_CB'Access, Mod_Shift + Mod_Ctrl + 'g', +            Flag_Inactive);          Bar.Add ("Search/&Replace...", Replace_CB'Access, Mod_Ctrl + 'h', Flag_Divider);          Bar.Add ("Search/Jump To...", Jump_CB'Access, Mod_Ctrl + 'j');          Bar.Add ("Search/Word Count", Count_CB'Access); diff --git a/src/windows-jump.adb b/src/windows-jump.adb index f19315e..baa4171 100644 --- a/src/windows-jump.adb +++ b/src/windows-jump.adb @@ -7,7 +7,7 @@ package body Windows.Jump is      package WD renames FLTK.Widgets.Groups.Windows.Double;      package BU renames FLTK.Widgets.Buttons;      package EN renames FLTK.Widgets.Buttons.Enter; -    package IT renames FLTK.Widgets.Inputs.Integer; +    package IT renames FLTK.Widgets.Inputs.Text.Whole_Number; @@ -18,10 +18,16 @@ package body Windows.Jump is          type Jump_Window_Access is access all Jump_Window;          Dialog : access Jump_Window := Jump_Window_Access (Item.Parent); -        Line : Integer := Dialog.To_Line.Get_Value; +        Line : Long_Integer := Dialog.To_Line.Get_Value;      begin -        if Dialog.Callback /= null and Line > 0 then -            Dialog.Callback.all (Line); +        if Dialog.Callback /= null then +            if Line <= 0 then +                Dialog.Callback (1); +            elsif Line > Long_Integer (Integer'Last) then +                Dialog.Callback (Integer'Last); +            else +                Dialog.Callback (Integer (Line)); +            end if;          end if;      end Jump_M; diff --git a/src/windows-jump.ads b/src/windows-jump.ads index 6c483d5..ae1920c 100644 --- a/src/windows-jump.ads +++ b/src/windows-jump.ads @@ -3,7 +3,7 @@  private with      FLTK.Widgets.Buttons.Enter, -    FLTK.Widgets.Inputs.Integer; +    FLTK.Widgets.Inputs.Text.Whole_Number;  package Windows.Jump is @@ -30,7 +30,7 @@ private      type Jump_Window is new Window with          record -            To_Line  : FLTK.Widgets.Inputs.Integer.Integer_Input; +            To_Line  : FLTK.Widgets.Inputs.Text.Whole_Number.Integer_Input;              Cancel   : FLTK.Widgets.Buttons.Button;              Go_Jump  : FLTK.Widgets.Buttons.Enter.Enter_Button;              Callback : Jump_Callback;  | 
