aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-04-15 17:23:52 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2025-04-15 17:23:52 +1200
commitce287c99ae15137138e2c5674f8f84a9c8bc1609 (patch)
tree0567cbd3dddc78f64a95d60eae1ce54d46da70a1
parent63c26c318a60efd20485978624352befd5f6c5ee (diff)
Constants marked constant, code style improvements, redundant with clauses removed
-rw-r--r--src/adapad.adb158
-rw-r--r--src/adapad.ads2
-rw-r--r--src/change_vectors.adb37
-rw-r--r--src/change_vectors.ads44
-rw-r--r--src/images.adb4
-rw-r--r--src/main.adb3
-rw-r--r--src/windows-about.adb59
-rw-r--r--src/windows-about.ads16
-rw-r--r--src/windows-editor.adb48
-rw-r--r--src/windows-editor.ads39
-rw-r--r--src/windows-find.adb72
-rw-r--r--src/windows-find.ads23
-rw-r--r--src/windows-jump.adb48
-rw-r--r--src/windows-jump.ads19
-rw-r--r--src/windows-replace.adb84
-rw-r--r--src/windows-replace.ads21
-rw-r--r--src/windows.adb1
17 files changed, 288 insertions, 390 deletions
diff --git a/src/adapad.adb b/src/adapad.adb
index 5f1f347..8d0e4ac 100644
--- a/src/adapad.adb
+++ b/src/adapad.adb
@@ -2,17 +2,17 @@
with
- FLTK.Widgets.Menus,
- FLTK.Widgets.Groups.Windows,
- FLTK.Text_Buffers,
+ Ada.Strings.Unbounded,
+ Change_Vectors,
FLTK.Asks,
- Windows.Editor,
+ FLTK.Text_Buffers,
+ FLTK.Widgets.Groups.Windows,
+ FLTK.Widgets.Menus,
Windows.About,
+ Windows.Editor,
Windows.Find,
- Windows.Replace,
Windows.Jump,
- Change_Vectors,
- Ada.Strings.Unbounded;
+ Windows.Replace;
use
@@ -59,8 +59,6 @@ package body Adapad is
end Show;
-
-
procedure Hide is
begin
About.Hide;
@@ -78,7 +76,9 @@ package body Adapad is
procedure New_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
- if not Safe_To_Discard then return; end if;
+ if not Safe_To_Discard then
+ return;
+ end if;
Filename := To_Unbounded_String (0);
Buffer.Remove_Text (0, Buffer.Length);
Changed := False;
@@ -86,14 +86,14 @@ package body Adapad is
end New_CB;
-
-
procedure Open_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
- if not Safe_To_Discard then return; end if;
+ if not Safe_To_Discard then
+ return;
+ end if;
declare
- New_Filename : String :=
+ New_Filename : constant String :=
FLTK.Asks.File_Chooser ("Open File?", "*", To_String (Filename));
begin
if New_Filename /= "" then
@@ -103,8 +103,6 @@ package body Adapad is
end Open_CB;
-
-
procedure Save_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -112,8 +110,6 @@ package body Adapad is
end Save_CB;
-
-
procedure Save_As_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -121,23 +117,21 @@ package body Adapad is
end Save_As_CB;
-
-
procedure Quit_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
- if not Safe_To_Discard then return; end if;
+ if not Safe_To_Discard then
+ return;
+ end if;
Hide;
end Quit_CB;
-
-
procedure Undo_CB
(Item : in out FLTK.Widgets.Widget'Class)
is
use type FLTK.Text_Buffers.Modification;
- Bar : FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
+ Bar : constant FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
Ch : Change_Vectors.Change;
begin
Buffer.Disable_Callbacks;
@@ -164,13 +158,11 @@ package body Adapad is
end Undo_CB;
-
-
procedure Redo_CB
(Item : in out FLTK.Widgets.Widget'Class)
is
use type FLTK.Text_Buffers.Modification;
- Bar : FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
+ Bar : constant FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
Ch : Change_Vectors.Change;
begin
Buffer.Disable_Callbacks;
@@ -197,8 +189,6 @@ package body Adapad is
end Redo_CB;
-
-
procedure Cut_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -206,8 +196,6 @@ package body Adapad is
end Cut_CB;
-
-
procedure Copy_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -215,8 +203,6 @@ package body Adapad is
end Copy_CB;
-
-
procedure Paste_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -224,8 +210,6 @@ package body Adapad is
end Paste_CB;
-
-
procedure Delete_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -233,8 +217,6 @@ package body Adapad is
end Delete_CB;
-
-
procedure Select_All_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -242,8 +224,6 @@ package body Adapad is
end Select_All_CB;
-
-
procedure Find_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -252,8 +232,6 @@ package body Adapad is
end Find_CB;
-
-
procedure Find_Next_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -261,8 +239,6 @@ package body Adapad is
end Find_Next_CB;
-
-
procedure Find_Prev_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -270,8 +246,6 @@ package body Adapad is
end Find_Prev_CB;
-
-
procedure Replace_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -280,8 +254,6 @@ package body Adapad is
end Replace_CB;
-
-
procedure Jump_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -290,12 +262,10 @@ package body Adapad is
end Jump_CB;
-
-
procedure Count_CB
(Item : in out FLTK.Widgets.Widget'Class)
is
- Restore_Position : Natural := Editor.Get_Insert_Position;
+ Restore_Position : constant Natural := Editor.Get_Insert_Position;
Current_Position, Result : Natural := 0;
begin
Editor.Set_Insert_Position (0);
@@ -309,13 +279,10 @@ package body Adapad is
Result := Result + 1;
end loop;
Editor.Set_Insert_Position (Restore_Position);
- FLTK.Asks.Message_Box
- ("There are " & Integer'Image (Result) & " words in the document.");
+ FLTK.Asks.Message_Box ("There are " & Integer'Image (Result) & " words in the document.");
end Count_CB;
-
-
procedure Wrap_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -327,8 +294,6 @@ package body Adapad is
end Wrap_CB;
-
-
procedure Lines_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -341,8 +306,6 @@ package body Adapad is
end Lines_CB;
-
-
procedure About_CB
(Item : in out FLTK.Widgets.Widget'Class) is
begin
@@ -362,8 +325,8 @@ package body Adapad is
Deleted_Text : in String)
is
use type FLTK.Text_Buffers.Modification;
- Bar : FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
- Pop : FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Rightclick_Menu;
+ Bar : constant FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
+ Pop : constant FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Rightclick_Menu;
begin
if Action = FLTK.Text_Buffers.Insert or Action = FLTK.Text_Buffers.Delete then
Changed := True;
@@ -376,7 +339,7 @@ package body Adapad is
Ch.Length := Length;
if Action = FLTK.Text_Buffers.Insert then
Ch.Text := To_Unbounded_String
- (Buffer.Text_At (Integer (Place), Integer (Place) + Length));
+ (Buffer.Text_At (Integer (Place), Integer (Place) + Length));
else
Ch.Text := To_Unbounded_String (Deleted_Text);
end if;
@@ -416,7 +379,7 @@ package body Adapad is
Facing : in Windows.Find.Direction)
is
use type Windows.Find.Direction;
- Bar : FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
+ Bar : constant FLTK.Widgets.Menus.Menu_Reference := Editor.Get_Menu_Bar;
Current_Position, Select_Start, Select_End, Found_At : Natural;
Was_Found : Boolean;
begin
@@ -459,8 +422,6 @@ package body Adapad is
end Do_Find_CB;
-
-
procedure Do_Replace_CB
(Item, Replace_With : in String;
Match_Case, Replace_All : in Boolean)
@@ -477,8 +438,7 @@ package body Adapad is
Editor.Set_Insert_Position (Found_At);
Editor.Show_Insert_Position;
if not Replace_All then
- User_Response := FLTK.Asks.Choice
- ("Replace?", "No", "Yes", "Cancel");
+ User_Response := FLTK.Asks.Choice ("Replace?", "No", "Yes", "Cancel");
else
User_Response := FLTK.Asks.Second;
end if;
@@ -494,16 +454,13 @@ package body Adapad is
end loop;
if Times_Replaced > 0 then
- FLTK.Asks.Message_Box
- ("Replaced " & Integer'Image (Times_Replaced) & " occurrences.");
+ FLTK.Asks.Message_Box ("Replaced " & Integer'Image (Times_Replaced) & " occurrences.");
else
FLTK.Asks.Alert ("No occurrences of '" & Item & "' found!");
end if;
end Do_Replace_CB;
-
-
procedure Do_Jump_CB
(Line_Number : in Positive) is
begin
@@ -532,32 +489,30 @@ package body Adapad is
end Set_Title;
-
-
function Safe_To_Discard
return Boolean
is
User_Response : FLTK.Asks.Choice_Result;
begin
- if not Changed then return True; end if;
+ if not Changed then
+ return True;
+ end if;
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");
+ ("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.Asks.First =>
- return False;
- when FLTK.Asks.Second =>
- Do_Save;
- return not Changed;
- when FLTK.Asks.Third =>
- return True;
+ when FLTK.Asks.First =>
+ return False;
+ when FLTK.Asks.Second =>
+ Do_Save;
+ return not Changed;
+ when FLTK.Asks.Third =>
+ return True;
end case;
end Safe_To_Discard;
-
-
procedure Do_Save is
begin
if Filename = "" then
@@ -568,11 +523,9 @@ package body Adapad is
end Do_Save;
-
-
procedure Do_Save_As is
- New_Filename : String := FLTK.Asks.File_Chooser
- ("Save File As?", "*", To_String (Filename));
+ New_Filename : constant String := FLTK.Asks.File_Chooser
+ ("Save File As?", "*", To_String (Filename));
begin
if New_Filename /= "" then
Save_File (New_Filename);
@@ -580,8 +533,6 @@ package body Adapad is
end Do_Save_As;
-
-
procedure Load_File
(Name : in String) is
begin
@@ -593,13 +544,11 @@ package body Adapad is
Editor.Get_Menu_Bar.Find_Item ("&Edit/&Undo").Deactivate;
Editor.Get_Menu_Bar.Find_Item ("&Edit/&Redo").Deactivate;
exception
- when Storage_Error =>
- FLTK.Asks.Alert ("Error reading from file " & Name);
+ when Storage_Error =>
+ FLTK.Asks.Alert ("Error reading from file " & Name);
end Load_File;
-
-
procedure Save_File
(Name : in String) is
begin
@@ -608,22 +557,20 @@ package body Adapad is
Changed := False;
Set_Title;
exception
- when Storage_Error =>
- FLTK.Asks.Alert ("Error writing to file " & Name);
+ when Storage_Error =>
+ FLTK.Asks.Alert ("Error writing to file " & Name);
end Save_File;
-
-
procedure Centre
(Win : in out FLTK.Widgets.Groups.Windows.Window'Class)
is
- Middle_X : Integer := Editor.Get_X + Editor.Get_W / 2;
- Middle_Y : Integer := Editor.Get_Y + Editor.Get_H / 2;
+ Middle_X : constant Integer := Editor.Get_X + Editor.Get_W / 2;
+ Middle_Y : constant Integer := Editor.Get_Y + Editor.Get_H / 2;
begin
Win.Reposition
- (Middle_X - Win.Get_W / 2,
- Middle_Y - Win.Get_H / 2);
+ (Middle_X - Win.Get_W / 2,
+ Middle_Y - Win.Get_H / 2);
end Centre;
@@ -635,7 +582,7 @@ begin
declare
use FLTK;
use FLTK.Widgets.Menus;
- Bar : Menu_Reference := Editor.Get_Menu_Bar;
+ Bar : constant Menu_Reference := Editor.Get_Menu_Bar;
begin
Bar.Add (Text => "&File", Flags => Flag_Submenu);
Bar.Add ("File/&New", New_CB'Access, Mod_Ctrl + 'n');
@@ -675,7 +622,7 @@ begin
declare
use FLTK;
use FLTK.Widgets.Menus;
- Pop : Menu_Reference := Editor.Get_Rightclick_Menu;
+ Pop : constant Menu_Reference := Editor.Get_Rightclick_Menu;
begin
Pop.Add ("Cu&t", Cut_CB'Access, No_Key, Flag_Inactive);
Pop.Add ("&Copy", Copy_CB'Access, No_Key, Flag_Inactive);
@@ -697,3 +644,4 @@ begin
end Adapad;
+
diff --git a/src/adapad.ads b/src/adapad.ads
index 0695315..8dfe2dd 100644
--- a/src/adapad.ads
+++ b/src/adapad.ads
@@ -4,8 +4,10 @@ package Adapad is
procedure Show;
+
procedure Hide;
end Adapad;
+
diff --git a/src/change_vectors.adb b/src/change_vectors.adb
index 13be51f..71f5acf 100644
--- a/src/change_vectors.adb
+++ b/src/change_vectors.adb
@@ -2,17 +2,11 @@
with
- FLTK.Text_Buffers,
- Ada.Strings.Unbounded;
-
-use
-
- Ada.Strings.Unbounded;
+ FLTK.Text_Buffers;
use type
- FLTK.Text_Buffers.Modification,
- FLTK.Text_Buffers.Position;
+ FLTK.Text_Buffers.Modification;
package body Change_Vectors is
@@ -30,8 +24,6 @@ package body Change_Vectors is
end Continues_Insert;
-
-
function Continues_Delete
(Orig, Cont : in Change)
return Boolean is
@@ -43,8 +35,6 @@ package body Change_Vectors is
end Continues_Delete;
-
-
function Continues_Backspace
(Orig, Cont : in Change)
return Boolean is
@@ -62,20 +52,20 @@ package body Change_Vectors is
(This : in out Change_Vector;
Item : in Change)
is
-
- procedure App (Ch : in out Change) is
+ procedure App
+ (Ch : in out Change) is
begin
Ch.Length := Ch.Length + 1;
Append (Ch.Text, Item.Text);
end App;
- procedure Pre (Ch : in out Change) is
+ procedure Pre
+ (Ch : in out Change) is
begin
Ch.Length := Ch.Length + 1;
Ch.Text := Item.Text & Ch.Text;
Ch.Place := Ch.Place - 1;
end Pre;
-
begin
if Item.Action = FLTK.Text_Buffers.Insert then
if This.Near > 0 and then
@@ -108,8 +98,6 @@ package body Change_Vectors is
end Push;
-
-
function Pop
(This : in out Change_Vector)
return Boolean is
@@ -123,8 +111,6 @@ package body Change_Vectors is
end Pop;
-
-
procedure Pop
(This : in out Change_Vector) is
begin
@@ -134,8 +120,6 @@ package body Change_Vectors is
end Pop;
-
-
function Peek
(This : in Change_Vector;
Item : out Change)
@@ -150,8 +134,6 @@ package body Change_Vectors is
end Peek;
-
-
procedure Peek
(This : in Change_Vector;
Item : out Change) is
@@ -162,8 +144,6 @@ package body Change_Vectors is
end Peek;
-
-
function Re_Push
(This : in out Change_Vector)
return Boolean is
@@ -177,8 +157,6 @@ package body Change_Vectors is
end Re_Push;
-
-
procedure Re_Push
(This : in out Change_Vector) is
begin
@@ -198,8 +176,6 @@ package body Change_Vectors is
end At_Start;
-
-
function At_End
(This : in Change_Vector)
return Boolean is
@@ -210,3 +186,4 @@ package body Change_Vectors is
end Change_Vectors;
+
diff --git a/src/change_vectors.ads b/src/change_vectors.ads
index e325821..86048a9 100644
--- a/src/change_vectors.ads
+++ b/src/change_vectors.ads
@@ -19,58 +19,53 @@ package Change_Vectors is
type Change_Vector is tagged private;
-
- type Change is
- record
- Action : FLTK.Text_Buffers.Modification;
- Place : FLTK.Text_Buffers.Position;
- Length : Natural;
- Text : Unbounded_String;
- end record;
+ type Change is record
+ Action : FLTK.Text_Buffers.Modification;
+ Place : FLTK.Text_Buffers.Position;
+ Length : Natural;
+ Text : Unbounded_String;
+ end record;
Empty_Vector : constant Change_Vector;
+
+
procedure Push
(This : in out Change_Vector;
Item : in Change);
-
function Pop
(This : in out Change_Vector)
return Boolean;
-
procedure Pop
(This : in out Change_Vector);
-
function Peek
(This : in Change_Vector;
Item : out Change)
return Boolean;
-
procedure Peek
(This : in Change_Vector;
Item : out Change);
-
function Re_Push
(This : in out Change_Vector)
return Boolean;
-
procedure Re_Push
(This : in out Change_Vector);
+
+
function At_Start
(This : in Change_Vector)
return Boolean;
-
function At_End
(This : in Change_Vector)
return Boolean;
@@ -80,21 +75,22 @@ private
package Internal_Vectors is new Ada.Containers.Vectors
- (Index_Type => Positive, Element_Type => Change);
+ (Index_Type => Positive,
+ Element_Type => Change);
- type Change_Vector is tagged
- record
- Near, Far : Natural;
- List : Internal_Vectors.Vector;
- end record;
+ type Change_Vector is tagged record
+ Near, Far : Natural;
+ List : Internal_Vectors.Vector;
+ end record;
Empty_Vector : constant Change_Vector :=
- (Near => 0,
- Far => 0,
- List => Internal_Vectors.Empty_Vector);
+ (Near => 0,
+ Far => 0,
+ List => Internal_Vectors.Empty_Vector);
end Change_Vectors;
+
diff --git a/src/images.adb b/src/images.adb
index 07897d1..6e35d80 100644
--- a/src/images.adb
+++ b/src/images.adb
@@ -24,8 +24,8 @@ package body Images is
return FLTK.Images.RGB.RGB_Image'Class is
begin
declare
- Base_Path : String := ADir.Containing_Directory (Here_I_Am.Executable);
- Logo_Path : String :=
+ Base_Path : constant String := ADir.Containing_Directory (Here_I_Am.Executable);
+ Logo_Path : constant String :=
ADir.Compose
(ADir.Compose -- No matter how many times I write this, still looks weird...
(ADir.Compose
diff --git a/src/main.adb b/src/main.adb
index 07e062a..fc27ba3 100644
--- a/src/main.adb
+++ b/src/main.adb
@@ -9,7 +9,10 @@ with
function Main
return Integer is
begin
+
Adapad.Show;
return FLTK.Run;
+
end Main;
+
diff --git a/src/windows-about.adb b/src/windows-about.adb
index 8248065..b9fec99 100644
--- a/src/windows-about.adb
+++ b/src/windows-about.adb
@@ -14,44 +14,44 @@ package body Windows.About is
function Create
return About_Window
is
- My_Width : constant Integer := 350;
- My_Height : constant Integer := 250;
+ My_Width : constant Integer := 350;
+ My_Height : constant Integer := 250;
- Logo_Line : constant Integer := 30;
- Logo_Width : constant Integer := 50;
- Logo_Height : constant Integer := 50;
+ Logo_Line : constant Integer := 30;
+ Logo_Width : constant Integer := 50;
+ Logo_Height : constant Integer := 50;
Button_Width : constant Integer := 140;
Button_Height : constant Integer := 40;
- Heading_Line : constant Integer := 90;
- Blurb_Line : constant Integer := 132;
- Author_Line : constant Integer := 157;
- Button_Line : constant Integer := 190;
+ Heading_Line : constant Integer := 90;
+ Blurb_Line : constant Integer := 132;
+ Author_Line : constant Integer := 157;
+ Button_Line : constant Integer := 190;
- Heading_Size : constant Integer := 22;
- Text_Size : constant Integer := 12;
+ Heading_Size : constant Integer := 22;
+ Text_Size : constant Integer := 12;
- Heading_Text : constant String := "Adapad 0.8";
- Blurb_Text : constant String := "FLTK based simple text editor written in Ada";
- Author_Text : constant String := "Programmed by Jed Barber";
+ Heading_Text : constant String := "Adapad 0.8";
+ Blurb_Text : constant String := "FLTK based simple text editor written in Ada";
+ Author_Text : constant String := "Programmed by Jed Barber";
begin
return This : About_Window :=
- (WD.Double_Window'(WD.Forge.Create (0, 0, My_Width, My_Height, "About Adapad")) with
-
- Picture => BX.Box'(BX.Forge.Create
- ((My_Width - Logo_Width) / 2,
- Logo_Line, Logo_Width, Logo_Height, "")),
- Heading => BX.Box'(BX.Forge.Create
- (0, Heading_Line, My_Width, Heading_Size, Heading_Text)),
- Blurb => BX.Box'(BX.Forge.Create
- (0, Blurb_Line, My_Width, Text_Size, Blurb_Text)),
- Author => BX.Box'(BX.Forge.Create
- (0, Author_Line, My_Width, Text_Size, Author_Text)),
- Dismiss => EN.Enter_Button'(EN.Forge.Create
- ((My_Width - Button_Width) / 2,
- Button_Line, Button_Width, Button_Height, "Close"))) do
-
+ (WD.Forge.Create (0, 0, My_Width, My_Height, "About Adapad")
+ with
+ Picture => BX.Forge.Create
+ ((My_Width - Logo_Width) / 2,
+ Logo_Line, Logo_Width, Logo_Height, ""),
+ Heading => BX.Forge.Create
+ (0, Heading_Line, My_Width, Heading_Size, Heading_Text),
+ Blurb => BX.Forge.Create
+ (0, Blurb_Line, My_Width, Text_Size, Blurb_Text),
+ Author => BX.Forge.Create
+ (0, Author_Line, My_Width, Text_Size, Author_Text),
+ Dismiss => EN.Forge.Create
+ ((My_Width - Button_Width) / 2,
+ Button_Line, Button_Width, Button_Height, "Close"))
+ do
This.Add (This.Picture);
This.Add (This.Heading);
This.Heading.Set_Label_Size (FLTK.Font_Size (Heading_Size));
@@ -71,3 +71,4 @@ package body Windows.About is
end Windows.About;
+
diff --git a/src/windows-about.ads b/src/windows-about.ads
index 27e655b..00b26dd 100644
--- a/src/windows-about.ads
+++ b/src/windows-about.ads
@@ -19,15 +19,15 @@ package Windows.About is
private
- type About_Window is new Window with
- record
- Picture : FLTK.Widgets.Boxes.Box;
- Heading : FLTK.Widgets.Boxes.Box;
- Blurb : FLTK.Widgets.Boxes.Box;
- Author : FLTK.Widgets.Boxes.Box;
- Dismiss : FLTK.Widgets.Buttons.Enter.Enter_Button;
- end record;
+ type About_Window is new Window with record
+ Picture : FLTK.Widgets.Boxes.Box;
+ Heading : FLTK.Widgets.Boxes.Box;
+ Blurb : FLTK.Widgets.Boxes.Box;
+ Author : FLTK.Widgets.Boxes.Box;
+ Dismiss : FLTK.Widgets.Buttons.Enter.Enter_Button;
+ end record;
end Windows.About;
+
diff --git a/src/windows-editor.adb b/src/windows-editor.adb
index 69fecdb..b25dc19 100644
--- a/src/windows-editor.adb
+++ b/src/windows-editor.adb
@@ -27,21 +27,20 @@ package body Windows.Editor is
if Width < W then
Width := W;
end if;
-
if Height < H then
Height := H;
end if;
return This : Editor_Window :=
- (WD.Double_Window'(WD.Forge.Create (X, Y, Width, Height, Label_Text)) with
-
- Editor => TE.Text_Editor'(TE.Forge.Create
- (0, Menu_Height, Width, Height - Menu_Height, "")),
- Bar => MB.Menu_Bar'(MB.Forge.Create
- (0, 0, Width, Menu_Height, "")),
- Popup => MU.Menu_Button'(MU.Forge.Create
- (0, Menu_Height, Width, Height - Menu_Height, ""))) do
-
+ (WD.Forge.Create (X, Y, Width, Height, Label_Text)
+ with
+ Editor => TE.Forge.Create
+ (0, Menu_Height, Width, Height - Menu_Height, ""),
+ Bar => MB.Forge.Create
+ (0, 0, Width, Menu_Height, ""),
+ Popup => MU.Forge.Create
+ (0, Menu_Height, Width, Height - Menu_Height, ""))
+ do
This.Editor.Set_Text_Font (Courier);
This.Add (This.Editor);
@@ -62,8 +61,6 @@ package body Windows.Editor is
end Create;
-
-
function Create
(W, H : in Integer)
return Editor_Window is
@@ -82,8 +79,6 @@ package body Windows.Editor is
end Get_Buffer;
-
-
procedure Set_Buffer
(This : in out Editor_Window;
Buff : in out FLTK.Text_Buffers.Text_Buffer) is
@@ -92,8 +87,6 @@ package body Windows.Editor is
end Set_Buffer;
-
-
function Get_Menu_Bar
(This : in out Editor_Window)
return FLTK.Widgets.Menus.Menu_Reference is
@@ -102,8 +95,6 @@ package body Windows.Editor is
end Get_Menu_Bar;
-
-
function Get_Rightclick_Menu
(This : in out Editor_Window)
return FLTK.Widgets.Menus.Menu_Reference is
@@ -121,8 +112,6 @@ package body Windows.Editor is
end Undo;
-
-
procedure Cut
(This : in out Editor_Window) is
begin
@@ -130,8 +119,6 @@ package body Windows.Editor is
end Cut;
-
-
procedure Copy
(This : in out Editor_Window) is
begin
@@ -139,8 +126,6 @@ package body Windows.Editor is
end Copy;
-
-
procedure Paste
(This : in out Editor_Window) is
begin
@@ -148,8 +133,6 @@ package body Windows.Editor is
end Paste;
-
-
procedure Delete
(This : in out Editor_Window) is
begin
@@ -167,8 +150,6 @@ package body Windows.Editor is
end Get_Insert_Position;
-
-
procedure Set_Insert_Position
(This : in out Editor_Window;
Pos : in Natural) is
@@ -177,8 +158,6 @@ package body Windows.Editor is
end Set_Insert_Position;
-
-
procedure Show_Insert_Position
(This : in out Editor_Window) is
begin
@@ -186,8 +165,6 @@ package body Windows.Editor is
end Show_Insert_Position;
-
-
procedure Next_Word
(This : in out Editor_Window) is
begin
@@ -195,8 +172,6 @@ package body Windows.Editor is
end Next_Word;
-
-
procedure Previous_Word
(This : in out Editor_Window) is
begin
@@ -204,8 +179,6 @@ package body Windows.Editor is
end Previous_Word;
-
-
procedure Set_Wrap_Mode
(This : in out Editor_Window;
Mode : in Wrap_Mode;
@@ -215,8 +188,6 @@ package body Windows.Editor is
end Set_Wrap_Mode;
-
-
procedure Set_Linenumber_Width
(This : in out Editor_Window;
Width : in Natural) is
@@ -227,3 +198,4 @@ package body Windows.Editor is
end Windows.Editor;
+
diff --git a/src/windows-editor.ads b/src/windows-editor.ads
index a9d0041..c172679 100644
--- a/src/windows-editor.ads
+++ b/src/windows-editor.ads
@@ -18,12 +18,13 @@ package Windows.Editor is
type Editor_Window is new Window with private;
-
type Wrap_Mode is new FLTK.Widgets.Groups.Text_Displays.Wrap_Mode;
- Min_Editor_Height : Integer := 60;
- Min_Editor_Width : Integer := 300;
+ Min_Editor_Height : constant Integer := 60;
+ Min_Editor_Width : constant Integer := 300;
+
+
function Create
@@ -31,80 +32,72 @@ package Windows.Editor is
Label_Text : in String)
return Editor_Window;
-
function Create
(W, H : in Integer)
return Editor_Window;
+
+
function Get_Buffer
(This : in Editor_Window)
return FLTK.Text_Buffers.Text_Buffer_Reference;
-
procedure Set_Buffer
(This : in out Editor_Window;
Buff : in out FLTK.Text_Buffers.Text_Buffer);
-
function Get_Menu_Bar
(This : in out Editor_Window)
return FLTK.Widgets.Menus.Menu_Reference;
-
function Get_Rightclick_Menu
(This : in out Editor_Window)
return FLTK.Widgets.Menus.Menu_Reference;
+
+
procedure Undo
(This : in out Editor_Window);
-
procedure Cut
(This : in out Editor_Window);
-
procedure Copy
(This : in out Editor_Window);
-
procedure Paste
(This : in out Editor_Window);
-
procedure Delete
(This : in out Editor_Window);
+
+
function Get_Insert_Position
(This : in Editor_Window)
return Natural;
-
procedure Set_Insert_Position
(This : in out Editor_Window;
Pos : in Natural);
-
procedure Show_Insert_Position
(This : in out Editor_Window);
-
procedure Next_Word
(This : in out Editor_Window);
-
procedure Previous_Word
(This : in out Editor_Window);
-
procedure Set_Wrap_Mode
(This : in out Editor_Window;
Mode : in Wrap_Mode;
Margin : in Natural := 0);
-
procedure Set_Linenumber_Width
(This : in out Editor_Window;
Width : in Natural);
@@ -113,13 +106,13 @@ package Windows.Editor is
private
- type Editor_Window is new Window with
- record
- Bar : aliased FLTK.Widgets.Menus.Menu_Bars.Menu_Bar;
- Popup : aliased FLTK.Widgets.Menus.Menu_Buttons.Menu_Button;
- Editor : FLTK.Widgets.Groups.Text_Displays.Text_Editors.Text_Editor;
- end record;
+ type Editor_Window is new Window with record
+ Bar : aliased FLTK.Widgets.Menus.Menu_Bars.Menu_Bar;
+ Popup : aliased FLTK.Widgets.Menus.Menu_Buttons.Menu_Button;
+ Editor : FLTK.Widgets.Groups.Text_Displays.Text_Editors.Text_Editor;
+ end record;
end Windows.Editor;
+
diff --git a/src/windows-find.adb b/src/windows-find.adb
index ea6a807..92b4663 100644
--- a/src/windows-find.adb
+++ b/src/windows-find.adb
@@ -18,13 +18,13 @@ package body Windows.Find is
is
use type BU.State;
type Find_Window_Access is access all Find_Window;
- Dialog : access Find_Window := Find_Window_Access (Item.Parent);
+ Dialog : constant access Find_Window := Find_Window_Access (Item.Parent);
begin
if Dialog.Callback /= null then
Dialog.Callback.all
- (Dialog.Find_What.Get_Value,
- Dialog.Match_Case.Get_State = BU.On,
- Forward);
+ (Dialog.Find_What.Get_Value,
+ Dialog.Match_Case.Get_State = BU.On,
+ Forward);
end if;
end Find_M;
@@ -34,43 +34,42 @@ package body Windows.Find is
function Create
return Find_Window
is
- My_Width : constant Integer := 350;
- My_Height : constant Integer := 130;
+ My_Width : constant Integer := 350;
+ My_Height : constant Integer := 130;
- Button_Width : constant Integer := 140;
- Button_Height : constant Integer := 40;
+ Button_Width : constant Integer := 140;
+ Button_Height : constant Integer := 40;
- Input_Line : constant Integer := 10;
- Case_Line : constant Integer := 50;
- Button_Line : constant Integer := 80;
+ Input_Line : constant Integer := 10;
+ Case_Line : constant Integer := 50;
+ Button_Line : constant Integer := 80;
- Input_Width : constant Integer := 240;
- Input_Height : constant Integer := 25;
+ Input_Width : constant Integer := 240;
+ Input_Height : constant Integer := 25;
Input_Margin_Right : constant Integer := 10;
- Check_Width : constant Integer := 100;
- Check_Height : constant Integer := 20;
+ Check_Width : constant Integer := 100;
+ Check_Height : constant Integer := 20;
Case_Margin_Left : constant Integer := 50;
- Text_Size : constant Integer := 12;
+ Text_Size : constant Integer := 12;
begin
return This : Find_Window :=
- (WD.Double_Window'(WD.Forge.Create (0, 0, My_Width, My_Height, "Find")) with
-
- Find_What => IP.Text_Input'(IP.Forge.Create
- (My_Width - Input_Width - Input_Margin_Right,
- Input_Line, Input_Width, Input_Height, "Find what:")),
- Match_Case => LC.Check_Button'(LC.Forge.Create
- (Case_Margin_Left, Case_Line, Check_Width, Check_Height, "Match case")),
- Cancel => BU.Button'(BU.Forge.Create
- ((My_Width - 2 * Button_Width) / 3,
- Button_Line, Button_Width, Button_Height, "Cancel")),
- Start => EN.Enter_Button'(EN.Forge.Create
- ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
- Button_Line, Button_Width, Button_Height, "Find")),
-
- Callback => null) do
-
+ (WD.Forge.Create (0, 0, My_Width, My_Height, "Find")
+ with
+ Find_What => IP.Forge.Create
+ (My_Width - Input_Width - Input_Margin_Right,
+ Input_Line, Input_Width, Input_Height, "Find what:"),
+ Match_Case => LC.Forge.Create
+ (Case_Margin_Left, Case_Line, Check_Width, Check_Height, "Match case"),
+ Cancel => BU.Forge.Create
+ ((My_Width - 2 * Button_Width) / 3,
+ Button_Line, Button_Width, Button_Height, "Cancel"),
+ Start => EN.Forge.Create
+ ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
+ Button_Line, Button_Width, Button_Height, "Find"),
+ Callback => null)
+ do
This.Add (This.Find_What);
This.Add (This.Match_Case);
This.Add (This.Cancel);
@@ -96,8 +95,6 @@ package body Windows.Find is
end Set_Find_Callback;
-
-
procedure Do_Callback
(This : in Find_Window;
Dir : in Direction := Forward)
@@ -106,12 +103,13 @@ package body Windows.Find is
begin
if This.Callback /= null then
This.Callback.all
- (This.Find_What.Get_Value,
- This.Match_Case.Get_State = BU.On,
- Dir);
+ (This.Find_What.Get_Value,
+ This.Match_Case.Get_State = BU.On,
+ Dir);
end if;
end Do_Callback;
end Windows.Find;
+
diff --git a/src/windows-find.ads b/src/windows-find.ads
index 9f78048..1f59a05 100644
--- a/src/windows-find.ads
+++ b/src/windows-find.ads
@@ -12,25 +12,26 @@ package Windows.Find is
type Find_Window is new Window with private;
-
type Direction is (Forward, Backward);
-
type Find_Callback is access procedure
(Item : in String;
Match_Case : in Boolean;
Facing : in Direction);
+
+
function Create
return Find_Window;
+
+
procedure Set_Find_Callback
(This : in out Find_Window;
Func : in Find_Callback);
-
procedure Do_Callback
(This : in Find_Window;
Dir : in Direction := Forward);
@@ -39,15 +40,15 @@ package Windows.Find is
private
- type Find_Window is new Window with
- record
- Find_What : FLTK.Widgets.Inputs.Text.Text_Input;
- Match_Case : FLTK.Widgets.Buttons.Light.Check.Check_Button;
- Cancel : FLTK.Widgets.Buttons.Button;
- Start : FLTK.Widgets.Buttons.Enter.Enter_Button;
- Callback : Find_Callback;
- end record;
+ type Find_Window is new Window with record
+ Find_What : FLTK.Widgets.Inputs.Text.Text_Input;
+ Match_Case : FLTK.Widgets.Buttons.Light.Check.Check_Button;
+ Cancel : FLTK.Widgets.Buttons.Button;
+ Start : FLTK.Widgets.Buttons.Enter.Enter_Button;
+ Callback : Find_Callback;
+ end record;
end Windows.Find;
+
diff --git a/src/windows-jump.adb b/src/windows-jump.adb
index baa4171..13eb21c 100644
--- a/src/windows-jump.adb
+++ b/src/windows-jump.adb
@@ -16,9 +16,9 @@ package body Windows.Jump is
(Item : in out FLTK.Widgets.Widget'Class)
is
type Jump_Window_Access is access all Jump_Window;
- Dialog : access Jump_Window := Jump_Window_Access (Item.Parent);
+ Dialog : constant access Jump_Window := Jump_Window_Access (Item.Parent);
- Line : Long_Integer := Dialog.To_Line.Get_Value;
+ Line : constant Long_Integer := Dialog.To_Line.Get_Value;
begin
if Dialog.Callback /= null then
if Line <= 0 then
@@ -37,34 +37,33 @@ package body Windows.Jump is
function Create
return Jump_Window
is
- My_Width : constant Integer := 350;
- My_Height : constant Integer := 110;
+ My_Width : constant Integer := 350;
+ My_Height : constant Integer := 110;
- Button_Width : constant Integer := 140;
- Button_Height : constant Integer := 40;
+ Button_Width : constant Integer := 140;
+ Button_Height : constant Integer := 40;
- Input_Line : constant Integer := 10;
- Button_Line : constant Integer := 60;
+ Input_Line : constant Integer := 10;
+ Button_Line : constant Integer := 60;
- Input_Width : constant Integer := 240;
- Input_Height : constant Integer := 25;
+ Input_Width : constant Integer := 240;
+ Input_Height : constant Integer := 25;
Input_Margin_Right : constant Integer := 10;
begin
return This : Jump_Window :=
- (WD.Double_Window'(WD.Forge.Create (0, 0, My_Width, My_Height, "Jump")) with
-
- To_Line => IT.Integer_Input'(IT.Forge.Create
- (My_Width - Input_Width - Input_Margin_Right,
- Input_Line, Input_Width, Input_Height, "Jump to:")),
- Cancel => BU.Button'(BU.Forge.Create
- ((My_Width - 2 * Button_Width) / 3,
- Button_Line, Button_Width, Button_Height, "Cancel")),
- Go_Jump => EN.Enter_Button'(EN.Forge.Create
- ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
- Button_Line, Button_Width, Button_Height, "Jump")),
-
- Callback => null) do
-
+ (WD.Forge.Create (0, 0, My_Width, My_Height, "Jump")
+ with
+ To_Line => IT.Forge.Create
+ (My_Width - Input_Width - Input_Margin_Right,
+ Input_Line, Input_Width, Input_Height, "Jump to:"),
+ Cancel => BU.Forge.Create
+ ((My_Width - 2 * Button_Width) / 3,
+ Button_Line, Button_Width, Button_Height, "Cancel"),
+ Go_Jump => EN.Forge.Create
+ ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
+ Button_Line, Button_Width, Button_Height, "Jump"),
+ Callback => null)
+ do
This.Add (This.To_Line);
This.Add (This.Cancel);
This.Cancel.Set_Callback (Hide_CB'Access);
@@ -91,3 +90,4 @@ package body Windows.Jump is
end Windows.Jump;
+
diff --git a/src/windows-jump.ads b/src/windows-jump.ads
index ae1920c..a1b5cb3 100644
--- a/src/windows-jump.ads
+++ b/src/windows-jump.ads
@@ -11,15 +11,18 @@ package Windows.Jump is
type Jump_Window is new Window with private;
-
type Jump_Callback is access procedure
(Line_Number : in Positive);
+
+
function Create
return Jump_Window;
+
+
procedure Set_Jump_Callback
(This : in out Jump_Window;
Func : in Jump_Callback);
@@ -28,14 +31,14 @@ package Windows.Jump is
private
- type Jump_Window is new Window with
- record
- 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;
- end record;
+ type Jump_Window is new Window with record
+ 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;
+ end record;
end Windows.Jump;
+
diff --git a/src/windows-replace.adb b/src/windows-replace.adb
index 5dce69e..6dd7a78 100644
--- a/src/windows-replace.adb
+++ b/src/windows-replace.adb
@@ -18,14 +18,14 @@ package body Windows.Replace is
is
use type BU.State;
type Replace_Window_Access is access all Replace_Window;
- Dialog : access Replace_Window := Replace_Window_Access (Item.Parent);
+ Dialog : constant access Replace_Window := Replace_Window_Access (Item.Parent);
begin
if Dialog.Callback /= null then
Dialog.Callback.all
- (Dialog.Find_What.Get_Value,
- Dialog.Replace_With.Get_Value,
- Dialog.Match_Case.Get_State = BU.On,
- Dialog.Replace_All.Get_State = BU.On);
+ (Dialog.Find_What.Get_Value,
+ Dialog.Replace_With.Get_Value,
+ Dialog.Match_Case.Get_State = BU.On,
+ Dialog.Replace_All.Get_State = BU.On);
end if;
end Replace_M;
@@ -35,52 +35,51 @@ package body Windows.Replace is
function Create
return Replace_Window
is
- My_Width : constant Integer := 350;
- My_Height : constant Integer := 180;
+ My_Width : constant Integer := 350;
+ My_Height : constant Integer := 180;
- Button_Width : constant Integer := 140;
- Button_Height : constant Integer := 40;
+ Button_Width : constant Integer := 140;
+ Button_Height : constant Integer := 40;
- Find_Line : constant Integer := 10;
- Replace_Line : constant Integer := 40;
- Match_Line : constant Integer := 80;
- Rep_All_Line : constant Integer := 100;
- Button_Line : constant Integer := 130;
+ Find_Line : constant Integer := 10;
+ Replace_Line : constant Integer := 40;
+ Match_Line : constant Integer := 80;
+ Rep_All_Line : constant Integer := 100;
+ Button_Line : constant Integer := 130;
- Input_Width : constant Integer := 220;
- Input_Height : constant Integer := 25;
+ Input_Width : constant Integer := 220;
+ Input_Height : constant Integer := 25;
Input_Margin_Right : constant Integer := 10;
- Check_Width : constant Integer := 100;
- Check_Height : constant Integer := 20;
+ Check_Width : constant Integer := 100;
+ Check_Height : constant Integer := 20;
Check_Margin_Left : constant Integer := 50;
- Text_Size : constant Integer := 12;
+ Text_Size : constant Integer := 12;
begin
return This : Replace_Window :=
- (WD.Double_Window'(WD.Forge.Create (0, 0, My_Width, My_Height, "Replace")) with
-
- Find_What => IP.Text_Input'(IP.Forge.Create
- (My_Width - Input_Width - Input_Margin_Right,
- Find_Line, Input_Width, Input_Height, "Find what:")),
- Replace_With => IP.Text_Input'(IP.Forge.Create
- (My_Width - Input_Width - Input_Margin_Right,
- Replace_Line, Input_Width, Input_Height, "Replace with:")),
- Match_Case => LC.Check_Button'(LC.Forge.Create
- (Check_Margin_Left, Match_Line,
- Check_Width, Check_Height, "Match case")),
- Replace_All => LC.Check_Button'(LC.Forge.Create
- (Check_Margin_Left, Rep_All_Line,
- Check_Width, Check_Height, "Replace all")),
- Cancel => BU.Button'(BU.Forge.Create
- ((My_Width - 2 * Button_Width) / 3,
- Button_Line, Button_Width, Button_Height, "Cancel")),
- Start => EN.Enter_Button'(EN.Forge.Create
- ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
- Button_Line, Button_Width, Button_Height, "Replace")),
-
- Callback => null) do
-
+ (WD.Forge.Create (0, 0, My_Width, My_Height, "Replace")
+ with
+ Find_What => IP.Forge.Create
+ (My_Width - Input_Width - Input_Margin_Right,
+ Find_Line, Input_Width, Input_Height, "Find what:"),
+ Replace_With => IP.Forge.Create
+ (My_Width - Input_Width - Input_Margin_Right,
+ Replace_Line, Input_Width, Input_Height, "Replace with:"),
+ Match_Case => LC.Forge.Create
+ (Check_Margin_Left, Match_Line,
+ Check_Width, Check_Height, "Match case"),
+ Replace_All => LC.Forge.Create
+ (Check_Margin_Left, Rep_All_Line,
+ Check_Width, Check_Height, "Replace all"),
+ Cancel => BU.Forge.Create
+ ((My_Width - 2 * Button_Width) / 3,
+ Button_Line, Button_Width, Button_Height, "Cancel"),
+ Start => EN.Forge.Create
+ ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width,
+ Button_Line, Button_Width, Button_Height, "Replace"),
+ Callback => null)
+ do
This.Add (This.Find_What);
This.Add (This.Replace_With);
This.Add (This.Match_Case);
@@ -110,3 +109,4 @@ package body Windows.Replace is
end Windows.Replace;
+
diff --git a/src/windows-replace.ads b/src/windows-replace.ads
index 5e020e6..8d2bc98 100644
--- a/src/windows-replace.ads
+++ b/src/windows-replace.ads
@@ -12,16 +12,19 @@ package Windows.Replace is
type Replace_Window is new Window with private;
-
type Replace_Callback is access procedure
(Item, Replace_With : in String;
Match_Case, Rep_All : in Boolean);
+
+
function Create
return Replace_Window;
+
+
procedure Set_Replace_Callback
(This : in out Replace_Window;
Func : in Replace_Callback);
@@ -30,15 +33,15 @@ package Windows.Replace is
private
- type Replace_Window is new Window with
- record
- Find_What, Replace_With : FLTK.Widgets.Inputs.Text.Text_Input;
- Match_Case, Replace_All : FLTK.Widgets.Buttons.Light.Check.Check_Button;
- Cancel : FLTK.Widgets.Buttons.Button;
- Start : FLTK.Widgets.Buttons.Enter.Enter_Button;
- Callback : Replace_Callback;
- end record;
+ type Replace_Window is new Window with record
+ Find_What, Replace_With : FLTK.Widgets.Inputs.Text.Text_Input;
+ Match_Case, Replace_All : FLTK.Widgets.Buttons.Light.Check.Check_Button;
+ Cancel : FLTK.Widgets.Buttons.Button;
+ Start : FLTK.Widgets.Buttons.Enter.Enter_Button;
+ Callback : Replace_Callback;
+ end record;
end Windows.Replace;
+
diff --git a/src/windows.adb b/src/windows.adb
index d8d2f5b..a2bd131 100644
--- a/src/windows.adb
+++ b/src/windows.adb
@@ -34,3 +34,4 @@ package body Windows is
end Windows;
+