From 7a14ee099c2fd382c2951627bf43e3fc507181f4 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 19 Sep 2016 18:53:14 +1000 Subject: Editors.adb/ads now known as Editor_Windows.adb/ads in preparation for more window types --- src/adapad.adb | 4 +- src/editor_windows.adb | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ src/editor_windows.ads | 67 ++++++++++++++++++++++++++++ src/editors.adb | 118 ------------------------------------------------- src/editors.ads | 67 ---------------------------- 5 files changed, 187 insertions(+), 187 deletions(-) create mode 100644 src/editor_windows.adb create mode 100644 src/editor_windows.ads delete mode 100644 src/editors.adb delete mode 100644 src/editors.ads diff --git a/src/adapad.adb b/src/adapad.adb index 5dc36ca..20d5ba4 100644 --- a/src/adapad.adb +++ b/src/adapad.adb @@ -1,8 +1,8 @@ with FLTK; -with Editors; -use Editors; +with Editor_Windows; +use Editor_Windows; with FLTK.Text_Buffers; use FLTK.Text_Buffers; with FLTK.Widgets; diff --git a/src/editor_windows.adb b/src/editor_windows.adb new file mode 100644 index 0000000..7fdf744 --- /dev/null +++ b/src/editor_windows.adb @@ -0,0 +1,118 @@ + + +with FLTK.Enums; +use FLTK.Enums; + + +package body Editor_Windows is + + + function Create + (X, Y, W, H : in Integer; + Label_Text : in String) + return Editor_Window is + + Width, Height : Integer; + + begin + if W < 300 then Width := 300; else Width := W; end if; + if H < 60 then Height := 60; else Height := H; end if; + + return This : Editor_Window := + (Double_Window'(Create (X, Y, Width, Height, Label_Text)) with + Editor => Text_Editor'(Create (0, 30, Width, Height - 30, "")), + Bar => Menu_Bar'(Create (0, 0, Width, 30, ""))) do + This.Add (This.Editor); + This.Add (This.Bar); + This.Editor.Set_Text_Font (Courier); + end return; + end Create; + + + + + function Create + (W, H : in Integer) + return Editor_Window is + begin + return Create (0, 0, W, H, "(Untitled)"); + end Create; + + + + + function Get_Buffer + (This : in Editor_Window) + return Text_Buffer_Cursor is + begin + return This.Editor.Get_Buffer; + end Get_Buffer; + + + + + procedure Set_Buffer + (This : in out Editor_Window; + Buff : in out Text_Buffer) is + begin + This.Editor.Set_Buffer (Buff); + end Set_Buffer; + + + + + function Get_Menu + (This : in out Editor_Window) + return Menu_Cursor is + begin + return Ref : Menu_Cursor (This.Bar'Access); + end Get_Menu; + + + + + procedure Undo + (This : in out Editor_Window) is + begin + This.Editor.Undo; + end Undo; + + + + + procedure Cut + (This : in out Editor_Window) is + begin + This.Editor.Cut; + end Cut; + + + + + procedure Copy + (This : in out Editor_Window) is + begin + This.Editor.Copy; + end Copy; + + + + + procedure Paste + (This : in out Editor_Window) is + begin + This.Editor.Paste; + end Paste; + + + + + procedure Delete + (This : in out Editor_Window) is + begin + This.Editor.Delete; + end Delete; + + +end Editor_Windows; + diff --git a/src/editor_windows.ads b/src/editor_windows.ads new file mode 100644 index 0000000..3fefd4f --- /dev/null +++ b/src/editor_windows.ads @@ -0,0 +1,67 @@ + + +with FLTK.Widgets.Groups.Windows.Double; +use FLTK.Widgets.Groups.Windows.Double; +with FLTK.Widgets.Menus; +use FLTK.Widgets.Menus; +with FLTK.Text_Buffers; +use FLTK.Text_Buffers; +private with FLTK.Widgets.Groups.Text_Displays.Text_Editors; +private with FLTK.Widgets.Menus.Menu_Bars; + + +package Editor_Windows is + + + type Editor_Window is new Double_Window with private; + + + function Create + (X, Y, W, H : in Integer; + Label_Text : in String) + return Editor_Window; + + + function Create + (W, H : in Integer) + return Editor_Window; + + + function Get_Buffer + (This : in Editor_Window) + return Text_Buffer_Cursor; + + + procedure Set_Buffer + (This : in out Editor_Window; + Buff : in out Text_Buffer); + + + function Get_Menu + (This : in out Editor_Window) + return Menu_Cursor; + + + 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); + + +private + + + use FLTK.Widgets.Groups.Text_Displays.Text_Editors; + use FLTK.Widgets.Menus.Menu_Bars; + + + type Editor_Window is new Double_Window with + record + Bar : aliased Menu_Bar; + Editor : Text_Editor; + end record; + + +end Editor_Windows; + diff --git a/src/editors.adb b/src/editors.adb deleted file mode 100644 index 74ae629..0000000 --- a/src/editors.adb +++ /dev/null @@ -1,118 +0,0 @@ - - -with FLTK.Enums; -use FLTK.Enums; - - -package body Editors is - - - function Create - (X, Y, W, H : in Integer; - Label_Text : in String) - return Editor_Window is - - Width, Height : Integer; - - begin - if W < 300 then Width := 300; else Width := W; end if; - if H < 60 then Height := 60; else Height := H; end if; - - return This : Editor_Window := - (Double_Window'(Create (X, Y, Width, Height, Label_Text)) with - Editor => Text_Editor'(Create (0, 30, Width, Height - 30, "")), - Bar => Menu_Bar'(Create (0, 0, Width, 30, ""))) do - This.Add (This.Editor); - This.Add (This.Bar); - This.Editor.Set_Text_Font (Courier); - end return; - end Create; - - - - - function Create - (W, H : in Integer) - return Editor_Window is - begin - return Create (0, 0, W, H, "(Untitled)"); - end Create; - - - - - function Get_Buffer - (This : in Editor_Window) - return Text_Buffer_Cursor is - begin - return This.Editor.Get_Buffer; - end Get_Buffer; - - - - - procedure Set_Buffer - (This : in out Editor_Window; - Buff : in out Text_Buffer) is - begin - This.Editor.Set_Buffer (Buff); - end Set_Buffer; - - - - - function Get_Menu - (This : in out Editor_Window) - return Menu_Cursor is - begin - return Ref : Menu_Cursor (This.Bar'Access); - end Get_Menu; - - - - - procedure Undo - (This : in out Editor_Window) is - begin - This.Editor.Undo; - end Undo; - - - - - procedure Cut - (This : in out Editor_Window) is - begin - This.Editor.Cut; - end Cut; - - - - - procedure Copy - (This : in out Editor_Window) is - begin - This.Editor.Copy; - end Copy; - - - - - procedure Paste - (This : in out Editor_Window) is - begin - This.Editor.Paste; - end Paste; - - - - - procedure Delete - (This : in out Editor_Window) is - begin - This.Editor.Delete; - end Delete; - - -end Editors; - diff --git a/src/editors.ads b/src/editors.ads deleted file mode 100644 index 2d4f599..0000000 --- a/src/editors.ads +++ /dev/null @@ -1,67 +0,0 @@ - - -with FLTK.Widgets.Groups.Windows.Double; -use FLTK.Widgets.Groups.Windows.Double; -with FLTK.Widgets.Menus; -use FLTK.Widgets.Menus; -with FLTK.Text_Buffers; -use FLTK.Text_Buffers; -private with FLTK.Widgets.Groups.Text_Displays.Text_Editors; -private with FLTK.Widgets.Menus.Menu_Bars; - - -package Editors is - - - type Editor_Window is new Double_Window with private; - - - function Create - (X, Y, W, H : in Integer; - Label_Text : in String) - return Editor_Window; - - - function Create - (W, H : in Integer) - return Editor_Window; - - - function Get_Buffer - (This : in Editor_Window) - return Text_Buffer_Cursor; - - - procedure Set_Buffer - (This : in out Editor_Window; - Buff : in out Text_Buffer); - - - function Get_Menu - (This : in out Editor_Window) - return Menu_Cursor; - - - 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); - - -private - - - use FLTK.Widgets.Groups.Text_Displays.Text_Editors; - use FLTK.Widgets.Menus.Menu_Bars; - - - type Editor_Window is new Double_Window with - record - Bar : aliased Menu_Bar; - Editor : Text_Editor; - end record; - - -end Editors; - -- cgit