2 define(`HTMLNAME',`terminal_interface-curses-menus_s.html')dnl
4 ------------------------------------------------------------------------------
6 -- GNAT ncurses Binding --
8 -- Terminal_Interface.Curses.Menu --
12 ------------------------------------------------------------------------------
13 -- Copyright (c) 1998 Free Software Foundation, Inc. --
15 -- Permission is hereby granted, free of charge, to any person obtaining a --
16 -- copy of this software and associated documentation files (the --
17 -- "Software"), to deal in the Software without restriction, including --
18 -- without limitation the rights to use, copy, modify, merge, publish, --
19 -- distribute, distribute with modifications, sublicense, and/or sell --
20 -- copies of the Software, and to permit persons to whom the Software is --
21 -- furnished to do so, subject to the following conditions: --
23 -- The above copyright notice and this permission notice shall be included --
24 -- in all copies or substantial portions of the Software. --
26 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
27 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
28 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
29 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
30 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
31 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
32 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
34 -- Except as contained in this notice, the name(s) of the above copyright --
35 -- holders shall not be used in advertising or otherwise to promote the --
36 -- sale, use or other dealings in this Software without prior written --
38 ------------------------------------------------------------------------------
39 -- Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1996
42 -- Binding Version 00.93
43 ------------------------------------------------------------------------------
44 include(`Menu_Base_Defs')
47 with Ada.Characters.Latin_1;
49 package Terminal_Interface.Curses.Menus is
50 pragma Preelaborate (Menus);
51 include(`Menu_Linker_Options')
54 Space : Character renames Ada.Characters.Latin_1.Space;
59 ---------------------------
60 -- Interface constants --
61 ---------------------------
62 Null_Item : constant Item;
63 Null_Menu : constant Menu;
65 subtype Menu_Request_Code is Key_Code
66 range (Key_Max + 1) .. (Key_Max + 17);
68 -- The prefix M_ stands for "Menu Request"
69 M_Left_Item : constant Menu_Request_Code := Key_Max + 1;
70 M_Right_Item : constant Menu_Request_Code := Key_Max + 2;
71 M_Up_Item : constant Menu_Request_Code := Key_Max + 3;
72 M_Down_Item : constant Menu_Request_Code := Key_Max + 4;
73 M_ScrollUp_Line : constant Menu_Request_Code := Key_Max + 5;
74 M_ScrollDown_Line : constant Menu_Request_Code := Key_Max + 6;
75 M_ScrollDown_Page : constant Menu_Request_Code := Key_Max + 7;
76 M_ScrollUp_Page : constant Menu_Request_Code := Key_Max + 8;
77 M_First_Item : constant Menu_Request_Code := Key_Max + 9;
78 M_Last_Item : constant Menu_Request_Code := Key_Max + 10;
79 M_Next_Item : constant Menu_Request_Code := Key_Max + 11;
80 M_Previous_Item : constant Menu_Request_Code := Key_Max + 12;
81 M_Toggle_Item : constant Menu_Request_Code := Key_Max + 13;
82 M_Clear_Pattern : constant Menu_Request_Code := Key_Max + 14;
83 M_Back_Pattern : constant Menu_Request_Code := Key_Max + 15;
84 M_Next_Match : constant Menu_Request_Code := Key_Max + 16;
85 M_Previous_Match : constant Menu_Request_Code := Key_Max + 17;
87 -- For those who like the old 'C' names for the request codes
88 REQ_LEFT_ITEM : Menu_Request_Code renames M_Left_Item;
89 REQ_RIGHT_ITEM : Menu_Request_Code renames M_Right_Item;
90 REQ_UP_ITEM : Menu_Request_Code renames M_Up_Item;
91 REQ_DOWN_ITEM : Menu_Request_Code renames M_Down_Item;
92 REQ_SCR_ULINE : Menu_Request_Code renames M_ScrollUp_Line;
93 REQ_SCR_DLINE : Menu_Request_Code renames M_ScrollDown_Line;
94 REQ_SCR_DPAGE : Menu_Request_Code renames M_ScrollDown_Page;
95 REQ_SCR_UPAGE : Menu_Request_Code renames M_ScrollUp_Page;
96 REQ_FIRST_ITEM : Menu_Request_Code renames M_First_Item;
97 REQ_LAST_ITEM : Menu_Request_Code renames M_Last_Item;
98 REQ_NEXT_ITEM : Menu_Request_Code renames M_Next_Item;
99 REQ_PREV_ITEM : Menu_Request_Code renames M_Previous_Item;
100 REQ_TOGGLE_ITEM : Menu_Request_Code renames M_Toggle_Item;
101 REQ_CLEAR_PATTERN : Menu_Request_Code renames M_Clear_Pattern;
102 REQ_BACK_PATTERN : Menu_Request_Code renames M_Back_Pattern;
103 REQ_NEXT_MATCH : Menu_Request_Code renames M_Next_Match;
104 REQ_PREV_MATCH : Menu_Request_Code renames M_Previous_Match;
106 procedure Request_Name (Key : in Menu_Request_Code;
109 function Request_Name (Key : Menu_Request_Code) return String;
116 Menu_Exception : exception;
121 include(`Menu_Opt_Rep')
123 function Default_Menu_Options return Menu_Option_Set;
124 -- Initial default options for a menu.
125 pragma Inline (Default_Menu_Options);
131 function Default_Item_Options return Item_Option_Set;
132 -- Initial default options for an item.
133 pragma Inline (Default_Item_Options);
138 type Item_Array is array (Positive range <>) of aliased Item;
139 pragma Convention (C, Item_Array);
141 type Item_Array_Access is access Item_Array;
143 procedure Free (IA : in out Item_Array_Access;
144 Free_Items : Boolean := False);
145 -- Release the memory for an allocated item array
146 -- If Free_Items is True, call Delete() for all the items in
149 -- MANPAGE(`mitem_new.3x')
151 -- ANCHOR(`new_item()',`Create')
152 function Create (Name : String;
153 Description : String := "") return Item;
157 -- ANCHOR(`new_item()',`New_Item')
158 function New_Item (Name : String;
159 Description : String := "") return Item
163 -- ANCHOR(`free_item()',`Delete')
164 procedure Delete (Itm : in out Item);
166 -- Resets Itm to Null_Item
168 -- MANPAGE(`mitem_value.3x')
170 -- ANCHOR(`set_item_value()',`Set_Value')
171 procedure Set_Value (Itm : in Item;
172 Value : in Boolean := True);
174 pragma Inline (Set_Value);
176 -- ANCHOR(`item_value()',`Value')
177 function Value (Itm : Item) return Boolean;
179 pragma Inline (Value);
181 -- MANPAGE(`mitem_visible.3x')
183 -- ANCHOR(`item_visible()',`Visible')
184 function Visible (Itm : Item) return Boolean;
186 pragma Inline (Visible);
188 -- MANPAGE(`mitem_opts.3x')
190 -- ANCHOR(`set_item_opts()',`Set_Options')
191 procedure Set_Options (Itm : in Item;
192 Options : in Item_Option_Set);
194 -- An overloaded Set_Options is defined later. Pragma Inline appears there
196 -- ANCHOR(`item_opts_on()',`Switch_Options')
197 procedure Switch_Options (Itm : in Item;
198 Options : in Item_Option_Set;
199 On : Boolean := True);
201 -- ALIAS(`item_opts_off()')
202 -- An overloaded Switch_Options is defined later.
203 -- Pragma Inline appears there
205 -- ANCHOR(`item_opts()',`Get_Options')
206 procedure Get_Options (Itm : in Item;
207 Options : out Item_Option_Set);
210 -- ANCHOR(`item_opts()',`Get_Options')
211 function Get_Options (Itm : Item := Null_Item) return Item_Option_Set;
213 -- An overloaded Get_Options is defined later. Pragma Inline appears there
215 -- MANPAGE(`mitem_name.3x')
217 -- ANCHOR(`item_name()',`Name')
218 procedure Name (Itm : in Item;
221 function Name (Itm : Item) return String;
223 -- Implemented as function
224 pragma Inline (Name);
226 -- ANCHOR(`item_description();',`Description')
227 procedure Description (Itm : in Item;
228 Description : out String);
231 function Description (Itm : Item) return String;
233 -- Implemented as function
234 pragma Inline (Description);
236 -- MANPAGE(`mitem_current.3x')
238 -- ANCHOR(`set_current_item()',`Set_Current')
239 procedure Set_Current (Men : in Menu;
242 pragma Inline (Set_Current);
244 -- ANCHOR(`current_item()',`Current')
245 function Current (Men : Menu) return Item;
247 pragma Inline (Current);
249 -- ANCHOR(`set_top_row()',`Set_Top_Row')
250 procedure Set_Top_Row (Men : in Menu;
251 Line : in Line_Position);
253 pragma Inline (Set_Top_Row);
255 -- ANCHOR(`top_row()',`Top_Row')
256 function Top_Row (Men : Menu) return Line_Position;
258 pragma Inline (Top_Row);
260 -- ANCHOR(`item_index()',`Get_Index')
261 function Get_Index (Itm : Item) return Positive;
263 -- Please note that in this binding we start the numbering of items
264 -- with 1. So this is number is one more than you get from the low
266 pragma Inline (Get_Index);
268 -- MANPAGE(`menu_post.3x')
270 -- ANCHOR(`post_menu()',`Post')
271 procedure Post (Men : in Menu;
272 Post : in Boolean := True);
274 -- ALIAS(`unpost_menu()')
275 pragma Inline (Post);
277 -- MANPAGE(`menu_opts.3x')
279 -- ANCHOR(`set_menu_opts()',`Set_Options')
280 procedure Set_Options (Men : in Menu;
281 Options : in Menu_Option_Set);
283 pragma Inline (Set_Options);
285 -- ANCHOR(`menu_opts_on()',`Switch_Options')
286 procedure Switch_Options (Men : in Menu;
287 Options : in Menu_Option_Set;
288 On : Boolean := True);
290 -- ALIAS(`menu_opts_off()')
291 pragma Inline (Switch_Options);
293 -- ANCHOR(`menu_opts()',`Get_Options')
294 procedure Get_Options (Men : in Menu;
295 Options : out Menu_Option_Set);
298 -- ANCHOR(`menu_opts()',`Get_Options')
299 function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set;
301 pragma Inline (Get_Options);
303 -- MANPAGE(`menu_win.3x')
305 -- ANCHOR(`set_menu_win()',`Set_Window')
306 procedure Set_Window (Men : in Menu;
309 pragma Inline (Set_Window);
311 -- ANCHOR(`menu_win()',`Get_Window')
312 function Get_Window (Men : Menu) return Window;
314 pragma Inline (Get_Window);
316 -- ANCHOR(`set_menu_sub()',`Set_Sub_Window')
317 procedure Set_Sub_Window (Men : in Menu;
320 pragma Inline (Set_Sub_Window);
322 -- ANCHOR(`menu_sub()',`Get_Sub_Window')
323 function Get_Sub_Window (Men : Menu) return Window;
325 pragma Inline (Get_Sub_Window);
327 -- ANCHOR(`scale_menu()',`Scale')
328 procedure Scale (Men : in Menu;
329 Lines : out Line_Count;
330 Columns : out Column_Count);
332 pragma Inline (Scale);
334 -- MANPAGE(`menu_cursor.3x')
336 -- ANCHOR(`pos_menu_cursor()',`Position_Cursor')
337 procedure Position_Cursor (Men : Menu);
339 pragma Inline (Position_Cursor);
341 -- MANPAGE(`menu_mark.3x')
343 -- ANCHOR(`set_menu_mark()',`Set_Mark')
344 procedure Set_Mark (Men : in Menu;
347 pragma Inline (Set_Mark);
349 -- ANCHOR(`menu_mark()',`Mark')
350 procedure Mark (Men : in Menu;
354 function Mark (Men : Menu) return String;
356 -- Implemented as function
357 pragma Inline (Mark);
359 -- MANPAGE(`menu_attribs.3x')
361 -- ANCHOR(`set_menu_fore()',`Set_Foreground')
362 procedure Set_Foreground
364 Fore : in Character_Attribute_Set := Normal_Video;
365 Color : in Color_Pair := Color_Pair'First);
367 pragma Inline (Set_Foreground);
369 -- ANCHOR(`menu_fore()',`Foreground')
370 procedure Foreground (Men : in Menu;
371 Fore : out Character_Attribute_Set);
374 -- ANCHOR(`menu_fore()',`Foreground')
375 procedure Foreground (Men : in Menu;
376 Fore : out Character_Attribute_Set;
377 Color : out Color_Pair);
379 pragma Inline (Foreground);
381 -- ANCHOR(`set_menu_back()',`Set_Background')
382 procedure Set_Background
384 Back : in Character_Attribute_Set := Normal_Video;
385 Color : in Color_Pair := Color_Pair'First);
387 pragma Inline (Set_Background);
389 -- ANCHOR(`menu_back()',`Background')
390 procedure Background (Men : in Menu;
391 Back : out Character_Attribute_Set);
393 -- ANCHOR(`menu_back()',`Background')
395 procedure Background (Men : in Menu;
396 Back : out Character_Attribute_Set;
397 Color : out Color_Pair);
399 pragma Inline (Background);
401 -- ANCHOR(`set_menu_grey()',`Set_Grey')
404 Grey : in Character_Attribute_Set := Normal_Video;
405 Color : in Color_Pair := Color_Pair'First);
407 pragma Inline (Set_Grey);
409 -- ANCHOR(`menu_grey()',`Grey')
410 procedure Grey (Men : in Menu;
411 Grey : out Character_Attribute_Set);
414 -- ANCHOR(`menu_grey()',`Grey')
417 Grey : out Character_Attribute_Set;
418 Color : out Color_Pair);
420 pragma Inline (Grey);
422 -- ANCHOR(`set_menu_pad()',`Set_Pad_Character')
423 procedure Set_Pad_Character (Men : in Menu;
424 Pad : in Character := Space);
426 pragma Inline (Set_Pad_Character);
428 -- ANCHOR(`menu_pad()',`Pad_Character')
429 procedure Pad_Character (Men : in Menu;
430 Pad : out Character);
432 pragma Inline (Pad_Character);
434 -- MANPAGE(`menu_spacing.3x')
436 -- ANCHOR(`set_menu_spacing()',`Set_Spacing')
437 procedure Set_Spacing (Men : in Menu;
438 Descr : in Column_Position := 0;
439 Row : in Line_Position := 0;
440 Col : in Column_Position := 0);
442 pragma Inline (Set_Spacing);
444 -- ANCHOR(`menu_spacing()',`Spacing')
445 procedure Spacing (Men : in Menu;
446 Descr : out Column_Position;
447 Row : out Line_Position;
448 Col : out Column_Position);
450 pragma Inline (Spacing);
452 -- MANPAGE(`menu_pattern.3x')
454 -- ANCHOR(`set_menu_pattern()',`Set_Pattern')
455 function Set_Pattern (Men : Menu;
456 Text : String) return Boolean;
458 -- Return TRUE if the pattern matches, FALSE otherwise
459 pragma Inline (Set_Pattern);
461 -- ANCHOR(`menu_pattern()',`Pattern')
462 procedure Pattern (Men : in Menu;
465 pragma Inline (Pattern);
467 -- MANPAGE(`menu_format.3x')
469 -- ANCHOR(`set_menu_format()',`Set_Format')
470 procedure Set_Format (Men : in Menu;
471 Lines : in Line_Count;
472 Columns : in Column_Count);
474 pragma Inline (Set_Format);
476 -- ANCHOR(`menu_format()',`Format')
477 procedure Format (Men : in Menu;
478 Lines : out Line_Count;
479 Columns : out Column_Count);
481 pragma Inline (Format);
483 -- MANPAGE(`menu_hook.3x')
485 type Menu_Hook_Function is access procedure (Men : in Menu);
486 pragma Convention (C, Menu_Hook_Function);
488 -- ANCHOR(`set_item_init()',`Set_Item_Init_Hook')
489 procedure Set_Item_Init_Hook (Men : in Menu;
490 Proc : in Menu_Hook_Function);
492 pragma Inline (Set_Item_Init_Hook);
494 -- ANCHOR(`set_item_term()',`Set_Item_Term_Hook')
495 procedure Set_Item_Term_Hook (Men : in Menu;
496 Proc : in Menu_Hook_Function);
498 pragma Inline (Set_Item_Term_Hook);
500 -- ANCHOR(`set_menu_init()',`Set_Menu_Init_Hook')
501 procedure Set_Menu_Init_Hook (Men : in Menu;
502 Proc : in Menu_Hook_Function);
504 pragma Inline (Set_Menu_Init_Hook);
506 -- ANCHOR(`set_menu_term()',`Set_Menu_Term_Hook')
507 procedure Set_Menu_Term_Hook (Men : in Menu;
508 Proc : in Menu_Hook_Function);
510 pragma Inline (Set_Menu_Term_Hook);
512 -- ANCHOR(`item_init()',`Get_Item_Init_Hook')
513 function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function;
515 pragma Inline (Get_Item_Init_Hook);
517 -- ANCHOR(`item_term()',`Get_Item_Term_Hook')
518 function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function;
520 pragma Inline (Get_Item_Term_Hook);
522 -- ANCHOR(`menu_init()',`Get_Menu_Init_Hook')
523 function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function;
525 pragma Inline (Get_Menu_Init_Hook);
527 -- ANCHOR(`menu_term()',`Get_Menu_Term_Hook')
528 function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function;
530 pragma Inline (Get_Menu_Term_Hook);
532 -- MANPAGE(`menu_items.3x')
534 -- ANCHOR(`set_menu_items()',`Redefine')
535 procedure Redefine (Men : in Menu;
536 Items : in Item_Array_Access);
538 pragma Inline (Redefine);
540 procedure Set_Items (Men : in Menu;
541 Items : in Item_Array_Access) renames Redefine;
542 pragma Inline (Set_Items);
544 -- ANCHOR(`menu_items()',`Items')
545 function Items (Men : Menu;
546 Index : Positive) return Item;
548 pragma Inline (Items);
550 -- ANCHOR(`item_count()',`Item_Count')
551 function Item_Count (Men : Menu) return Natural;
553 pragma Inline (Item_Count);
555 -- MANPAGE(`menu_new.3x')
557 -- ANCHOR(`new_menu()',`Create')
558 function Create (Items : Item_Array_Access) return Menu;
562 function New_Menu (Items : Item_Array_Access) return Menu renames Create;
564 -- ANCHOR(`free_menu()',`Delete')
565 procedure Delete (Men : in out Menu);
567 -- Reset Men to Null_Menu
570 -- MANPAGE(`menu_new.3x')
572 type Driver_Result is (Menu_Ok,
577 -- ANCHOR(`menu_driver()',`Driver')
578 function Driver (Men : Menu;
579 Key : Key_Code) return Driver_Result;
581 -- Driver is not inlined
583 -------------------------------------------------------------------------------
585 type Item is new System.Address;
586 type Menu is new System.Address;
588 Null_Item : constant Item := Item (System.Null_Address);
589 Null_Menu : constant Menu := Menu (System.Null_Address);
591 end Terminal_Interface.Curses.Menus;