diff --git a/.gitignore b/.gitignore index 617f2e1..eb81fbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.sw* obj/ +bin/ *.glade~ diff --git a/Makefile b/Makefile index b819c3e..d6f16fd 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ GPRBUILD:=$(shell which gprbuild) GPRCLEAN:=$(shell which gprclean) -EXE=obj/arun +EXE=bin/arun GPRFILE=arun.gpr RESOURCES=resources all: $(EXE) $(EXE): prepare - $(GPRBUILD) -P$(GPRFILE) -cargs:c $(shell pkg-config --cflags gio-2.0) + $(GPRBUILD) -p -P$(GPRFILE) -cargs:c $(shell pkg-config --cflags gio-2.0) prepare: src/arun-resources.c mkdir -p obj diff --git a/arun.gpr b/arun.gpr index 6cfb572..9f43467 100644 --- a/arun.gpr +++ b/arun.gpr @@ -5,6 +5,7 @@ project Arun is for Languages use ("Ada", "C"); for Source_Dirs use ("src"); for Object_Dir use "obj"; + for Exec_Dir use "bin"; for Main use ("main.adb"); package Linker is @@ -20,7 +21,12 @@ project Arun is for Switches ("Ada") use ("-gnat2012", "-fstack-check", "-gnata", - "-gnato"); + "-gnato", + "-gnatf", -- Full, verbose error messages + "-gnatwa", -- All optional warnings + "-gnatVa", -- All validity checks + "-gnaty3abcdefhiklmnoOprstux", -- Style checks + "-gnatwe"); -- Treat warnings as errors end Compiler; end Arun; diff --git a/src/arun-handlers.adb b/src/arun-handlers.adb index 29372cb..6bfb30c 100644 --- a/src/arun-handlers.adb +++ b/src/arun-handlers.adb @@ -1,5 +1,5 @@ --- --- Basic GtkAda handlers for Arun +-- Basic GtkAda handlers for Arun --- ------------------------------------------------------------------------------ -- @@ -17,18 +17,16 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ with Ada.Text_IO; -with GNAT.OS_Lib; -with Gdk.Event; + with Gdk.Types.Keysyms; with Glib; with Gtk.Main; -with Gtk.Widget; with Gtk.Search_Entry; -with Gtkada.Builder; use Gtkada.Builder; with GNAT.String_Split; @@ -38,35 +36,10 @@ with Arun.View; use Arun.View; package body Arun.Handlers is - procedure Quit (Object : access Gtkada_Builder_Record'Class) is - pragma Unreferenced (Object); - begin - Ada.Text_IO.Put_Line ("Exiting arun"); - Gtk.Main.Main_Quit; - end Quit; + use Gtkada.Builder; - procedure Search_Changed (Object : access Gtkada_Builder_Record'Class) is - use Ada.Text_IO; - use Gtk.Search_Entry; - use Gtkada.Builder; - - Widget : Gtk_Search_Entry := Gtk_Search_Entry (Get_Object (Object, "commandEntry")); - begin - Put_Line ("Searching for " & Widget.Get_Text); - end Search_Changed; - - - function Slice_Command (Text : in String) return GNAT.String_Split.Slice_Set is - use GNAT.String_Split; - - Separator : constant String := " "; - Slices : Slice_Set; - begin - - Create (Slices, Text, Separator, Single); - - return Slices; - end Slice_Command; + function Slice_Command (Text : in String) + return GNAT.String_Split.Slice_Set; procedure Execute_Command (Object : access Gtkada_Builder_Record'Class) is use Ada.Text_IO; @@ -74,10 +47,11 @@ package body Arun.Handlers is use Gtkada.Builder; use GNAT.String_Split; - Widget : Gtk_Search_Entry := Gtk_Search_Entry (Get_Object (Object, "commandEntry")); - Builder : Arun.View.Arun_Builder_Record renames Arun.View.Arun_Builder_Record (Object.all); - L : Arun.Launchers.Unix.UnixLauncher renames Arun.Launchers.Unix.UnixLauncher (Builder.Launcher); - + Widget : constant Gtk_Search_Entry := + Gtk_Search_Entry (Get_Object (Object, "commandEntry")); + Builder : Arun.View.Arun_Builder_Record + renames Arun.View.Arun_Builder_Record (Object.all); + L : Arun.Launchers.Unix.UnixLauncher renames Builder.Launcher; Slices : constant Slice_Set := Slice_Command (Widget.Get_Text); Command : constant String := Slice (S => Slices, Index => 1); @@ -92,32 +66,66 @@ package body Arun.Handlers is Gtk.Main.Main_Quit; end Execute_Command; - function Search_KeyPress (Widget : access Gtk.Widget.Gtk_Widget_Record'Class; - Event : in Gdk.Event.Gdk_Event_Key) return Boolean is + procedure Quit (Object : access Gtkada_Builder_Record'Class) is + pragma Unreferenced (Object); + begin + Ada.Text_IO.Put_Line ("Exiting arun"); + Gtk.Main.Main_Quit; + end Quit; + + procedure Search_Changed (Object : access Gtkada_Builder_Record'Class) is + use Ada.Text_IO; + use Gtk.Search_Entry; + use Gtkada.Builder; + + Widget : constant Gtk_Search_Entry := + Gtk_Search_Entry (Get_Object (Object, "commandEntry")); + begin + Put_Line ("Searching for " & Widget.Get_Text); + end Search_Changed; + + function Search_Keypress + (Widget : access Gtk.Widget.Gtk_Widget_Record'Class; + Event : in Gdk.Event.Gdk_Event_Key) return Boolean + is use Ada.Text_IO; use Gdk.Types; use Gdk.Types.Keysyms; begin if Event.Keyval = GDK_Tab then - -- When the Tab key is presented, let's assume the user is finishing - -- an auto-complete operation jump to the end so - -- they can add arguments if desired + -- When the Tab key is presented, let's assume the user is + -- finishing an auto-complete operation jump to the end so + -- they can add arguments if desired declare use Glib; - Search_Entry : Gtk.Search_Entry.Gtk_Search_Entry_Record renames Gtk.Search_Entry.Gtk_Search_Entry_Record (Widget.all); + Search_Entry : Gtk.Search_Entry.Gtk_Search_Entry_Record + renames Gtk.Search_Entry.Gtk_Search_Entry_Record (Widget.all); begin Search_Entry.Set_Position (-1); end; end if; - if Event.Keyval = GDK_Escape then Put_Line ("Escape! Exiting arun"); Gtk.Main.Main_Quit; end if; return True; - end Search_KeyPress; + end Search_Keypress; + + function Slice_Command (Text : in String) + return GNAT.String_Split.Slice_Set + is + use GNAT.String_Split; + + Separator : constant String := " "; + Slices : Slice_Set; + begin + + Create (Slices, Text, Separator, Single); + + return Slices; + end Slice_Command; end Arun.Handlers; diff --git a/src/arun-handlers.ads b/src/arun-handlers.ads index 9a50c14..b4640b1 100644 --- a/src/arun-handlers.ads +++ b/src/arun-handlers.ads @@ -1,5 +1,5 @@ --- --- Basic GtkAda handlers for Arun +-- Basic GtkAda handlers for Arun --- ------------------------------------------------------------------------------ -- @@ -17,31 +17,32 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ with Gtkada.Builder; use Gtkada.Builder; with Gtk.Widget; with Gdk.Event; -with Arun.Launchers.Unix; - -with Arun.View; use Arun.View; - package Arun.Handlers is procedure Quit (Object : access Gtkada_Builder_Record'Class); + -- Whenever the search entry changes call this handler for + -- autocompletion + -- procedure Search_Changed (Object : access Gtkada_Builder_Record'Class); - -- Whenever the search entry changes call this handler for autocompletion + -- On "activate" of the search entry call this handler (basically + -- when the user hits the enter key + -- procedure Execute_Command (Object : access Gtkada_Builder_Record'Class); - -- On "activate" of the search entry call this handler (basically when the user - -- hits the enter key - - function Search_KeyPress (Widget : access Gtk.Widget.Gtk_Widget_Record'Class; - Event : in Gdk.Event.Gdk_Event_Key) return Boolean; - -- On key-presses in the commandEntry field + -- On key-presses in the commandEntry field + -- + function Search_Keypress + (Widget : access Gtk.Widget.Gtk_Widget_Record'Class; + Event : in Gdk.Event.Gdk_Event_Key) return Boolean; end Arun.Handlers; diff --git a/src/arun-launchers-unix.adb b/src/arun-launchers-unix.adb index 50ee198..005f3a0 100644 --- a/src/arun-launchers-unix.adb +++ b/src/arun-launchers-unix.adb @@ -14,120 +14,44 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ - with Ada.Text_IO; use Ada.Text_IO; -with Ada.Command_Line.Environment; with Ada.Environment_Variables; with GNAT.Directory_Operations; with GNAT.OS_Lib; -with GNAT.String_Split; with Interfaces.C; with Interfaces.C.Strings; - package body Arun.Launchers.Unix is - procedure Initialize (L : in out UnixLauncher) is - use Gnat.String_Split; - - PATH : constant String := Ada.Environment_Variables.Value ("PATH"); - Separator : constant String := ":"; - begin - - Create (L.Path_Components, PATH, Separator, Single); - L.Initialized := True; - end Initialize; - - - function Find_Full_Path (L : in UnixLauncher; - Path_Snippet : in String) return String is - use GNAT.String_Split; - begin - - if L.Initialized /= True then - Put_Line ("Uninitialized UnixLauncher!"); - return ""; - end if; - - for Index in 1 .. Slice_Count (L.Path_Components) loop - Put_Line ("Looking for an executable in " & Slice (S => L.Path_Components, - Index => Index)); - declare - Path_Component : constant String := Slice (S => L.Path_Components, - Index => Index); - Computed_Location : constant String := Path_Component & "/" & Path_Snippet; - begin - - if GNAT.OS_Lib.Is_Executable_File (Computed_Location) then - Put_Line ("Found executable at " & Computed_Location); - return Computed_Location; - end if; - end; - - end loop; - - return ""; - end Find_Full_Path; - - - - - function Exec_And_Replace (Filename : in Interfaces.C.Char_Array; - Arguments : in Interfaces.C.Strings.Chars_Ptr_Array) return Integer + function Exec_And_Replace + (Filename : in Interfaces.C.char_array; + Arguments : in Interfaces.C.Strings.chars_ptr_array) return Integer with Import, - Convention => C, - Link_Name => "execv"; + Convention => C, + Link_Name => "execv"; procedure Print_Errno (Message : in String) with Import, - Convention => C, - Link_Name => "perror"; + Convention => C, + Link_Name => "perror"; - procedure Execute (L : in UnixLauncher; - Executable_Path : in String; - Argv : in GNAT.String_Split.Slice_Set) is - use GNAT.String_Split; - use Interfaces.C; - use Interfaces.C.Strings; - - Status : Integer; - Argc : constant Size_T := Size_T (Slice_Count (Argv)); - Arguments : Chars_Ptr_Array (1 .. (Argc + 1)) := (others => Null_Ptr); - begin - -- For the first argument, we must replace the executable name with - -- the full path, e.g. "xeyes" => "/usr/bin/xeyes" - Arguments (1) := New_String (Executable_Path); - for Index in 1 .. Argc loop - Arguments (Index) := New_String (Slice (S => Argv, - Index => Slice_Number (Index))); - end loop; - - Put_Line ("Spawning " & Executable_Path); - - Status := Exec_And_Replace (Filename => To_C (Item => Executable_Path, - Append_Nul => True), - Arguments => Arguments); - - -- If the Exec_And_Replace function returns then something has gone wrong - if Status /= 0 then - Print_Errno ("Something went wrong"); - end if; - end Execute; - - - function Discover_Executables (L : in UnixLauncher) return Arun.String_Vectors.Vector is + overriding + function Discover_Executables (L : in UnixLauncher) + return Arun.String_Vectors.Vector + is use GNAT.Directory_Operations; use GNAT.OS_Lib; use GNAT.String_Split; use Ada.Strings.Unbounded; - Dir : Dir_Type; - File_Name : String (1 .. MAX_FILENAME_LENGTH); - File_Index : Natural := 0; + Dir : Dir_Type; + File_Name : String (1 .. MAX_FILENAME_LENGTH); + File_Index : Natural := 0; Executables : Arun.String_Vectors.Vector; begin for Index in 1 .. Slice_Count (L.Path_Components) loop @@ -155,5 +79,86 @@ package body Arun.Launchers.Unix is return Executables; end Discover_Executables; + overriding + procedure Execute (L : in UnixLauncher; + Executable_Path : in String; + Argv : in GNAT.String_Split.Slice_Set) is + pragma Unreferenced (L); + + use GNAT.String_Split; + use Interfaces.C; + use Interfaces.C.Strings; + + Status : Integer; + Argc : constant size_t := size_t (Slice_Count (Argv)); + Arguments : chars_ptr_array (1 .. (Argc + 1)) := (others => Null_Ptr); + begin + -- For the first argument, we must replace the executable name + -- with the full path, e.g. "xeyes" => "/usr/bin/xeyes" + Arguments (1) := New_String (Executable_Path); + for Index in 1 .. Argc loop + Arguments (Index) := + New_String (Slice (S => Argv, + Index => Slice_Number (Index))); + end loop; + + Put_Line ("Spawning " & Executable_Path); + + Status := + Exec_And_Replace (Filename => To_C (Item => Executable_Path, + Append_Nul => True), + Arguments => Arguments); + + -- If the Exec_And_Replace function returns then something has + -- gone wrong + if Status /= 0 then + Print_Errno ("Something went wrong"); + end if; + end Execute; + + overriding + function Find_Full_Path (L : in UnixLauncher; + Path_Snippet : in String) return String is + use GNAT.String_Split; + begin + + if not L.Initialized then + Put_Line ("Uninitialized UnixLauncher!"); + return ""; + end if; + + for Index in 1 .. Slice_Count (L.Path_Components) loop + Put_Line ("Looking for an executable in " & + Slice (S => L.Path_Components, + Index => Index)); + declare + Path_Component : constant String := + Slice (S => L.Path_Components, + Index => Index); + Computed_Location : constant String := + Path_Component & "/" & Path_Snippet; + begin + + if GNAT.OS_Lib.Is_Executable_File (Computed_Location) then + Put_Line ("Found executable at " & Computed_Location); + return Computed_Location; + end if; + end; + + end loop; + + return ""; + end Find_Full_Path; + + procedure Initialize (L : in out UnixLauncher) is + use GNAT.String_Split; + + PATH : constant String := Ada.Environment_Variables.Value ("PATH"); + Separator : constant String := ":"; + begin + + Create (L.Path_Components, PATH, Separator, Single); + L.Initialized := True; + end Initialize; end Arun.Launchers.Unix; diff --git a/src/arun-launchers-unix.ads b/src/arun-launchers-unix.ads index 60c68cf..418e72e 100644 --- a/src/arun-launchers-unix.ads +++ b/src/arun-launchers-unix.ads @@ -14,7 +14,8 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ with Arun; @@ -29,27 +30,33 @@ package Arun.Launchers.Unix is procedure Initialize (L : in out UnixLauncher); + -- Determine the full path of the snippet based on PATH or other + -- environment variables. + -- + -- Will return an empty string if a full path was not discoverable. + -- + overriding function Find_Full_Path (L : in UnixLauncher; Path_Snippet : in String) return String; - -- Determine the full path of the snippet based on PATH or other environment - -- variables. + + -- Execute a command using the given UnixLauncher with an "Argv" + -- Slice_Set assuming the first argument is the command and + -- subsequent values are arguments for that command. -- - -- Will return an empty string if a full path was not discoverable. - - + overriding procedure Execute (L : in UnixLauncher; Executable_Path : in String; Argv : in GNAT.String_Split.Slice_Set); - -- Execute a command using the given UnixLauncher with an "Argv" - -- Slice_Set assuming the first argument is the command and subsequent values - -- are arguments for that command. - function Discover_Executables (L : in UnixLauncher) return Arun.String_Vectors.Vector; + overriding + function Discover_Executables (L : in UnixLauncher) + return Arun.String_Vectors.Vector; + private type UnixLauncher is new Arun.Launcher_Type with record Initialized : Boolean := False; - Path_Components : Gnat.String_Split.Slice_Set; + Path_Components : GNAT.String_Split.Slice_Set; end record; end Arun.Launchers.Unix; diff --git a/src/arun-launchers.ads b/src/arun-launchers.ads index 712fdff..6cab579 100644 --- a/src/arun-launchers.ads +++ b/src/arun-launchers.ads @@ -14,9 +14,9 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ - package Arun.Launchers is end Arun.Launchers; diff --git a/src/arun-view.adb b/src/arun-view.adb index c786135..44db70f 100644 --- a/src/arun-view.adb +++ b/src/arun-view.adb @@ -14,21 +14,20 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ - with Gtk.Widget; use Gtk.Widget; -with Ada.Text_IO; package body Arun.View is function From_Object (Builder : out Arun_Builder_Record'Class; Object_Name : in String) return Gtk_Widget is - -- Return the Gtk_Widget for the specified Object_Name in the Builder. - -- Basically pass the name of the widget given in Glade. - begin - return Gtk_Widget (Builder.Get_Object (Object_Name)); + -- Return the Gtk_Widget for the specified Object_Name in the Builder. + -- Basically pass the name of the widget given in Glade. + begin + return Gtk_Widget (Builder.Get_Object (Object_Name)); end From_Object; end Arun.View; diff --git a/src/arun-view.ads b/src/arun-view.ads index 3b7c76c..74e9386 100644 --- a/src/arun-view.ads +++ b/src/arun-view.ads @@ -14,7 +14,8 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ with Gtkada.Builder; use Gtkada.Builder; diff --git a/src/arun.adb b/src/arun.adb index 61a63aa..7486bef 100644 --- a/src/arun.adb +++ b/src/arun.adb @@ -14,14 +14,10 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ - -with GNAT.OS_Lib; -with GNAT.Directory_Operations; -with Ada.Strings.Unbounded; - with Gtk.Widget; use Gtk.Widget; with Gtk.GEntry; with Gtk.Entry_Completion; @@ -40,47 +36,9 @@ with Arun.View; package body Arun is - procedure Rig_Autocomplete (Builder : in Arun.View.Arun_Builder) is - -- Rig up the autocomplete support for the "commandEntry" - - use Gtk.Entry_Completion; - use Gtk.List_Store; - use Gtk.Tree_Model; - use Ada.Strings.Unbounded; - - Completion_Types : constant GType_Array (1 .. 1) := (1 => GType_String); - Items : Gtk_List_Store := Gtk_List_Store_Newv (Types => Completion_Types); - Iter : Gtk_Tree_Iter; - Command_Entry : Gtk.GEntry.Gtk_Entry := Gtk.GEntry.Gtk_Entry (Builder.From_Object ("commandEntry")); - Command_Completion : aliased Gtk_Entry_Completion := Gtk_Entry_Completion_New; - - Completion_String : Glib.Values.GValue; - - Executables : String_Vectors.Vector := Builder.Launcher.Discover_Executables; - begin - for Element of Executables loop - Items.Append (Iter); - Glib.Values.Init_Set_String (Completion_String, - To_String (Element)); - Items.Set_Value (Iter, 0, Completion_String); - end loop; - - Command_Completion.Set_Model (Items.To_Interface); - Command_Completion.Set_Text_Column (Column => 0); - Command_Completion.Set_Inline_Completion (True); - Command_Completion.Set_Inline_Selection (True); - Command_Entry.Set_Completion (Completion => Command_Completion); - Command_Entry.On_Key_Release_Event (Call => Arun.Handlers.Search_KeyPress'Access, - After => False); - end Rig_Autocomplete; - - function Compare_Strings (Left : in Ada.Strings.Unbounded.Unbounded_String; - Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean is - -- Simple comparision function for the String_Vector - use Ada.Strings.Unbounded; - begin - return Left = Right; - end Compare_Strings; + -- Rig up the autocomplete support for the "commandEntry" + -- + procedure Rig_Autocomplete (Builder : in Arun.View.Arun_Builder); procedure Main is use Ada.Text_IO; @@ -98,13 +56,17 @@ package body Arun is Gtkada.Builder.Initialize (Builder); Builder.Launcher.Initialize; - Return_Code := Add_From_Resource (Builder => Builder, - Resource_Path => "/io/lasagna/arun/arun.glade", - Error => Error'Access); + Return_Code := + Add_From_Resource (Builder => Builder, + Resource_Path => "/io/lasagna/arun/arun.glade", + Error => Error'Access); if Error /= null then Put_Line ("Error : " & Get_Message (Error)); Error_Free (Error); return; + elsif Return_Code /= 0 then + Put_Line ("Error " & Return_Code'Image); + return; end if; Register_Handler (Builder => Builder, @@ -125,4 +87,45 @@ package body Arun is Gtk.Main.Main; Unref (Builder); end Main; + + procedure Rig_Autocomplete (Builder : in Arun.View.Arun_Builder) is + + use Gtk.Entry_Completion; + use Gtk.List_Store; + use Gtk.Tree_Model; + use Ada.Strings.Unbounded; + + Completion_Types : constant GType_Array (1 .. 1) := + (1 => GType_String); + Items : constant Gtk_List_Store := + Gtk_List_Store_Newv (Types => Completion_Types); + Iter : Gtk_Tree_Iter; + Command_Entry : constant Gtk.GEntry.Gtk_Entry := + Gtk.GEntry.Gtk_Entry (Builder.From_Object + ("commandEntry")); + Command_Completion : aliased constant Gtk_Entry_Completion := + Gtk_Entry_Completion_New; + + Completion_String : Glib.Values.GValue; + + Executables : constant String_Vectors.Vector := + Builder.Launcher.Discover_Executables; + begin + for Element of Executables loop + Items.Append (Iter); + Glib.Values.Init_Set_String (Completion_String, + To_String (Element)); + Items.Set_Value (Iter, 0, Completion_String); + end loop; + + Command_Completion.Set_Model (Items.To_Interface); + Command_Completion.Set_Text_Column (Column => 0); + Command_Completion.Set_Inline_Completion (True); + Command_Completion.Set_Inline_Selection (True); + Command_Entry.Set_Completion (Completion => Command_Completion); + Command_Entry.On_Key_Release_Event + (Call => Arun.Handlers.Search_Keypress'Access, + After => False); + end Rig_Autocomplete; + end Arun; diff --git a/src/arun.ads b/src/arun.ads index e961d27..2d90ac6 100644 --- a/src/arun.ads +++ b/src/arun.ads @@ -14,7 +14,8 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ with GNAT.String_Split; @@ -26,32 +27,38 @@ package Arun is type Launcher_Type is interface; - type Discovered_Executable_Handler is access function (L : in Launcher_Type'Class; - Name : in String; - Full_Path : in String) return Boolean; + type Discovered_Executable_Handler is + access function (L : in Launcher_Type'Class; + Name : in String; + Full_Path : in String) return Boolean; - procedure Initialize (L : in Launcher_Type'Class) is abstract; - -- Launcher_Type-specific initialization routine - - function Find_Full_Path (L : in Launcher_Type; - Path_Snippet : in String) return String is abstract; - -- Determine the full path of the snippet based on PATH or other environment - -- variables. + -- Determine the full path of the snippet based on PATH or other + -- environment variables. -- - -- Will return an empty string if a full path was not discoverable. + -- Will return an empty string if a full path was not + -- discoverable. + -- + function Find_Full_Path (L : in Launcher_Type; + Path_Snippet : in String) return String is + abstract; + -- Spawn the Executable in place of the current process + -- procedure Execute (L : in Launcher_Type; Executable_Path : in String; - Argv : in GNAT.String_Split.Slice_Set) is abstract; - -- Spawn the Executable in place of the current process + Argv : in GNAT.String_Split.Slice_Set) is + abstract; - function Compare_Strings (Left : in Ada.Strings.Unbounded.Unbounded_String; - Right : in Ada.Strings.Unbounded.Unbounded_String) return Boolean; - package String_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, - Element_Type => Ada.Strings.Unbounded.Unbounded_String, - "=" => Compare_Strings); + package String_Vectors is + new Ada.Containers.Vectors + (Index_Type => Natural, + Element_Type => Ada.Strings.Unbounded.Unbounded_String, + "=" => Ada.Strings.Unbounded."="); - function Discover_Executables (L : in Launcher_Type) return String_Vectors.Vector is abstract; - -- Discover executables which can be launched by the configured Launcher_Type + -- Discover executables which can be launched by the configured + -- Launcher_Type + -- + function Discover_Executables (L : in Launcher_Type) + return String_Vectors.Vector is abstract; end Arun; diff --git a/src/main.adb b/src/main.adb index 916bef0..8d86566 100644 --- a/src/main.adb +++ b/src/main.adb @@ -14,7 +14,8 @@ -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301, USA. ------------------------------------------------------------------------------ with Arun;