File : terminal_interface-curses-menus.ads
with System;
with Ada.Characters.Latin_1;
package Terminal_Interface.Curses.Menus is
pragma Preelaborate (Terminal_Interface.Curses.Menus);
pragma Linker_Options ("-lmenu" & Curses_Constants.DFT_ARG_SUFFIX);
Space : Character renames Ada.Characters.Latin_1.Space;
type Item is private;
type Menu is private;
Null_Item : constant Item;
Null_Menu : constant Menu;
subtype Menu_Request_Code is Key_Code
range (Key_Max + 1) .. (Key_Max + 17);
M_Left_Item : constant Menu_Request_Code := Key_Max + 1;
M_Right_Item : constant Menu_Request_Code := Key_Max + 2;
M_Up_Item : constant Menu_Request_Code := Key_Max + 3;
M_Down_Item : constant Menu_Request_Code := Key_Max + 4;
M_ScrollUp_Line : constant Menu_Request_Code := Key_Max + 5;
M_ScrollDown_Line : constant Menu_Request_Code := Key_Max + 6;
M_ScrollDown_Page : constant Menu_Request_Code := Key_Max + 7;
M_ScrollUp_Page : constant Menu_Request_Code := Key_Max + 8;
M_First_Item : constant Menu_Request_Code := Key_Max + 9;
M_Last_Item : constant Menu_Request_Code := Key_Max + 10;
M_Next_Item : constant Menu_Request_Code := Key_Max + 11;
M_Previous_Item : constant Menu_Request_Code := Key_Max + 12;
M_Toggle_Item : constant Menu_Request_Code := Key_Max + 13;
M_Clear_Pattern : constant Menu_Request_Code := Key_Max + 14;
M_Back_Pattern : constant Menu_Request_Code := Key_Max + 15;
M_Next_Match : constant Menu_Request_Code := Key_Max + 16;
M_Previous_Match : constant Menu_Request_Code := Key_Max + 17;
REQ_LEFT_ITEM : Menu_Request_Code renames M_Left_Item;
REQ_RIGHT_ITEM : Menu_Request_Code renames M_Right_Item;
REQ_UP_ITEM : Menu_Request_Code renames M_Up_Item;
REQ_DOWN_ITEM : Menu_Request_Code renames M_Down_Item;
REQ_SCR_ULINE : Menu_Request_Code renames M_ScrollUp_Line;
REQ_SCR_DLINE : Menu_Request_Code renames M_ScrollDown_Line;
REQ_SCR_DPAGE : Menu_Request_Code renames M_ScrollDown_Page;
REQ_SCR_UPAGE : Menu_Request_Code renames M_ScrollUp_Page;
REQ_FIRST_ITEM : Menu_Request_Code renames M_First_Item;
REQ_LAST_ITEM : Menu_Request_Code renames M_Last_Item;
REQ_NEXT_ITEM : Menu_Request_Code renames M_Next_Item;
REQ_PREV_ITEM : Menu_Request_Code renames M_Previous_Item;
REQ_TOGGLE_ITEM : Menu_Request_Code renames M_Toggle_Item;
REQ_CLEAR_PATTERN : Menu_Request_Code renames M_Clear_Pattern;
REQ_BACK_PATTERN : Menu_Request_Code renames M_Back_Pattern;
REQ_NEXT_MATCH : Menu_Request_Code renames M_Next_Match;
REQ_PREV_MATCH : Menu_Request_Code renames M_Previous_Match;
procedure Request_Name (Key : Menu_Request_Code;
Name : out String);
function Request_Name (Key : Menu_Request_Code) return String;
Menu_Exception : exception;
type Menu_Option_Set is
record
One_Valued : Boolean;
Show_Descriptions : Boolean;
Row_Major_Order : Boolean;
Ignore_Case : Boolean;
Show_Matches : Boolean;
Non_Cyclic : Boolean;
end record;
pragma Convention (C_Pass_By_Copy, Menu_Option_Set);
for Menu_Option_Set use
record
One_Valued at 0 range Curses_Constants.O_ONEVALUE_First
.. Curses_Constants.O_ONEVALUE_Last;
Show_Descriptions at 0 range Curses_Constants.O_SHOWDESC_First
.. Curses_Constants.O_SHOWDESC_Last;
Row_Major_Order at 0 range Curses_Constants.O_ROWMAJOR_First
.. Curses_Constants.O_ROWMAJOR_Last;
Ignore_Case at 0 range Curses_Constants.O_IGNORECASE_First
.. Curses_Constants.O_IGNORECASE_Last;
Show_Matches at 0 range Curses_Constants.O_SHOWMATCH_First
.. Curses_Constants.O_SHOWMATCH_Last;
Non_Cyclic at 0 range Curses_Constants.O_NONCYCLIC_First
.. Curses_Constants.O_NONCYCLIC_Last;
end record;
pragma Warnings (Off);
for Menu_Option_Set'Size use Curses_Constants.Menu_Options_Size;
pragma Warnings (On);
function Default_Menu_Options return Menu_Option_Set;
pragma Inline (Default_Menu_Options);
type Item_Option_Set is
record
Selectable : Boolean;
end record;
pragma Convention (C_Pass_By_Copy, Item_Option_Set);
for Item_Option_Set use
record
Selectable at 0 range Curses_Constants.O_SELECTABLE_First
.. Curses_Constants.O_SELECTABLE_Last;
end record;
pragma Warnings (Off);
for Item_Option_Set'Size use Curses_Constants.Item_Options_Size;
pragma Warnings (On);
function Default_Item_Options return Item_Option_Set;
pragma Inline (Default_Item_Options);
type Item_Array is array (Positive range <>) of aliased Item;
pragma Convention (C, Item_Array);
type Item_Array_Access is access Item_Array;
procedure Free (IA : in out Item_Array_Access;
Free_Items : Boolean := False);
function Create (Name : String;
Description : String := "") return Item;
function New_Item (Name : String;
Description : String := "") return Item
renames Create;
procedure Delete (Itm : in out Item);
procedure Set_Value (Itm : Item;
Value : Boolean := True);
pragma Inline (Set_Value);
function Value (Itm : Item) return Boolean;
pragma Inline (Value);
function Visible (Itm : Item) return Boolean;
pragma Inline (Visible);
procedure Set_Options (Itm : Item;
Options : Item_Option_Set);
procedure Switch_Options (Itm : Item;
Options : Item_Option_Set;
On : Boolean := True);
procedure Get_Options (Itm : Item;
Options : out Item_Option_Set);
function Get_Options (Itm : Item := Null_Item) return Item_Option_Set;
procedure Name (Itm : Item;
Name : out String);
function Name (Itm : Item) return String;
pragma Inline (Name);
procedure Description (Itm : Item;
Description : out String);
function Description (Itm : Item) return String;
pragma Inline (Description);
procedure Set_Current (Men : Menu;
Itm : Item);
pragma Inline (Set_Current);
function Current (Men : Menu) return Item;
pragma Inline (Current);
procedure Set_Top_Row (Men : Menu;
Line : Line_Position);
pragma Inline (Set_Top_Row);
function Top_Row (Men : Menu) return Line_Position;
pragma Inline (Top_Row);
function Get_Index (Itm : Item) return Positive;
pragma Inline (Get_Index);
procedure Post (Men : Menu;
Post : Boolean := True);
pragma Inline (Post);
procedure Set_Options (Men : Menu;
Options : Menu_Option_Set);
pragma Inline (Set_Options);
procedure Switch_Options (Men : Menu;
Options : Menu_Option_Set;
On : Boolean := True);
pragma Inline (Switch_Options);
procedure Get_Options (Men : Menu;
Options : out Menu_Option_Set);
function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set;
pragma Inline (Get_Options);
procedure Set_Window (Men : Menu;
Win : Window);
pragma Inline (Set_Window);
function Get_Window (Men : Menu) return Window;
pragma Inline (Get_Window);
procedure Set_Sub_Window (Men : Menu;
Win : Window);
pragma Inline (Set_Sub_Window);
function Get_Sub_Window (Men : Menu) return Window;
pragma Inline (Get_Sub_Window);
procedure Scale (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count);
pragma Inline (Scale);
procedure Position_Cursor (Men : Menu);
pragma Inline (Position_Cursor);
procedure Set_Mark (Men : Menu;
Mark : String);
pragma Inline (Set_Mark);
procedure Mark (Men : Menu;
Mark : out String);
function Mark (Men : Menu) return String;
pragma Inline (Mark);
procedure Set_Foreground
(Men : Menu;
Fore : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First);
pragma Inline (Set_Foreground);
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set);
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set;
Color : out Color_Pair);
pragma Inline (Foreground);
procedure Set_Background
(Men : Menu;
Back : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First);
pragma Inline (Set_Background);
procedure Background (Men : Menu;
Back : out Character_Attribute_Set);
procedure Background (Men : Menu;
Back : out Character_Attribute_Set;
Color : out Color_Pair);
pragma Inline (Background);
procedure Set_Grey
(Men : Menu;
Grey : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First);
pragma Inline (Set_Grey);
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set);
procedure Grey
(Men : Menu;
Grey : out Character_Attribute_Set;
Color : out Color_Pair);
pragma Inline (Grey);
procedure Set_Pad_Character (Men : Menu;
Pad : Character := Space);
pragma Inline (Set_Pad_Character);
procedure Pad_Character (Men : Menu;
Pad : out Character);
pragma Inline (Pad_Character);
procedure Set_Spacing (Men : Menu;
Descr : Column_Position := 0;
Row : Line_Position := 0;
Col : Column_Position := 0);
pragma Inline (Set_Spacing);
procedure Spacing (Men : Menu;
Descr : out Column_Position;
Row : out Line_Position;
Col : out Column_Position);
pragma Inline (Spacing);
function Set_Pattern (Men : Menu;
Text : String) return Boolean;
pragma Inline (Set_Pattern);
procedure Pattern (Men : Menu;
Text : out String);
pragma Inline (Pattern);
procedure Set_Format (Men : Menu;
Lines : Line_Count;
Columns : Column_Count);
pragma Inline (Set_Format);
procedure Format (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count);
pragma Inline (Format);
type Menu_Hook_Function is access procedure (Men : Menu);
pragma Convention (C, Menu_Hook_Function);
procedure Set_Item_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function);
pragma Inline (Set_Item_Init_Hook);
procedure Set_Item_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function);
pragma Inline (Set_Item_Term_Hook);
procedure Set_Menu_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function);
pragma Inline (Set_Menu_Init_Hook);
procedure Set_Menu_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function);
pragma Inline (Set_Menu_Term_Hook);
function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function;
pragma Inline (Get_Item_Init_Hook);
function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function;
pragma Inline (Get_Item_Term_Hook);
function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function;
pragma Inline (Get_Menu_Init_Hook);
function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function;
pragma Inline (Get_Menu_Term_Hook);
procedure Redefine (Men : Menu;
Items : Item_Array_Access);
pragma Inline (Redefine);
procedure Set_Items (Men : Menu;
Items : Item_Array_Access) renames Redefine;
function Items (Men : Menu;
Index : Positive) return Item;
pragma Inline (Items);
function Item_Count (Men : Menu) return Natural;
pragma Inline (Item_Count);
function Create (Items : Item_Array_Access) return Menu;
function New_Menu (Items : Item_Array_Access) return Menu renames Create;
procedure Delete (Men : in out Menu);
type Driver_Result is (Menu_Ok,
Request_Denied,
Unknown_Request,
No_Match);
function Driver (Men : Menu;
Key : Key_Code) return Driver_Result;
private
type Item is new System.Storage_Elements.Integer_Address;
type Menu is new System.Storage_Elements.Integer_Address;
Null_Item : constant Item := 0;
Null_Menu : constant Menu := 0;
end Terminal_Interface.Curses.Menus;