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 /src/adapad.adb | |
parent | a937e0b2a25d49e813d85fa3da14ea0c6882ff2f (diff) |
Updated to current FLTK binding
Diffstat (limited to 'src/adapad.adb')
-rw-r--r-- | src/adapad.adb | 46 |
1 files changed, 24 insertions, 22 deletions
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); |