diff options
author | Jed Barber <jjbarber@y7mail.com> | 2016-11-12 17:20:15 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2016-11-12 17:20:15 +1100 |
commit | 8908535c7dc9fc7adf3c56b96aecc49b319c5a9e (patch) | |
tree | c7dc949471370aa28924cfb8ca227d933e9e8702 /src/adapad.adb | |
parent | 7aa86670f5d76284ae193ed1e1ed936b20a5c5fb (diff) |
Added basic word count feature
Diffstat (limited to 'src/adapad.adb')
-rw-r--r-- | src/adapad.adb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/adapad.adb b/src/adapad.adb index 3a0ce97..5f8e7d8 100644 --- a/src/adapad.adb +++ b/src/adapad.adb @@ -197,6 +197,27 @@ package body Adapad is + procedure Count_CB + (Item : in out FLTK.Widgets.Widget'Class) + is + Restore_Position : Natural := Editor.Get_Insert_Position; + Current_Position, New_Position, Result : Natural := 0; + begin + Editor.Set_Insert_Position (0); + loop + Editor.Next_Word; + New_Position := Editor.Get_Insert_Position; + exit when New_Position = Buffer.Length; + Current_Position := New_Position; + Result := Result + 1; + end loop; + Editor.Set_Insert_Position (Restore_Position); + FLTK.Dialogs.Message_Box ("There are " & Integer'Image (Result) & " words in the document."); + end Count_CB; + + + + procedure About_CB (Item : in out FLTK.Widgets.Widget'Class) is begin @@ -419,7 +440,8 @@ begin Bar.Add (Text => "&Search", Flags => Flag_Submenu); Bar.Add ("Search/&Find...", Find_CB'Access, Mod_Ctrl + 'f'); - Bar.Add ("Search/&Replace...", Replace_CB'Access, Mod_Ctrl + 'h'); + Bar.Add ("Search/&Replace...", Replace_CB'Access, Mod_Ctrl + 'h', Flag_Divider); + Bar.Add ("Search/&Word Count", Count_CB'Access); Bar.Add (Text => "&Help", Flags => Flag_Submenu); Bar.Add ("Help/&About", About_CB'Access); |