]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/gen/terminal_interface-curses-menus.ads.m4
ncurses 4.2
[ncurses.git] / Ada95 / gen / terminal_interface-curses-menus.ads.m4
1 --  -*- ada -*-
2 define(`HTMLNAME',`terminal_interface-curses-menus_s.html')dnl
3 include(M4MACRO)dnl
4 ------------------------------------------------------------------------------
5 --                                                                          --
6 --                           GNAT ncurses Binding                           --
7 --                                                                          --
8 --                      Terminal_Interface.Curses.Menu                      --
9 --                                                                          --
10 --                                 S P E C                                  --
11 --                                                                          --
12 ------------------------------------------------------------------------------
13 -- Copyright (c) 1998 Free Software Foundation, Inc.                        --
14 --                                                                          --
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:                 --
22 --                                                                          --
23 -- The above copyright notice and this permission notice shall be included  --
24 -- in all copies or substantial portions of the Software.                   --
25 --                                                                          --
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.                               --
33 --                                                                          --
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       --
37 -- authorization.                                                           --
38 ------------------------------------------------------------------------------
39 --  Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1996
40 --  Version Control:
41 --  $Revision: 1.12 $
42 --  Binding Version 00.93
43 ------------------------------------------------------------------------------
44 include(`Menu_Base_Defs')
45 with System;
46 with Interfaces.C;
47 with Ada.Characters.Latin_1;
48
49 package Terminal_Interface.Curses.Menus is
50    pragma Preelaborate (Menus);
51 include(`Menu_Linker_Options')
52
53
54    Space : Character renames Ada.Characters.Latin_1.Space;
55
56    type Item is private;
57    type Menu is private;
58
59    ---------------------------
60    --  Interface constants  --
61    ---------------------------
62    Null_Item : constant Item;
63    Null_Menu : constant Menu;
64
65    subtype Menu_Request_Code is Key_Code
66      range (Key_Max + 1) .. (Key_Max + 17);
67
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;
86
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;
105
106    procedure Request_Name (Key  : in Menu_Request_Code;
107                            Name : out String);
108
109    function  Request_Name (Key : Menu_Request_Code) return String;
110    --  Same as function
111
112    ------------------
113    --  Exceptions  --
114    ------------------
115
116    Menu_Exception : exception;
117    --
118    --  Menu options
119    --
120
121 include(`Menu_Opt_Rep')
122
123    function Default_Menu_Options return Menu_Option_Set;
124    --  Initial default options for a menu.
125    pragma Inline (Default_Menu_Options);
126    --
127    --  Item options
128    --
129 include(`Item_Rep')
130
131    function Default_Item_Options return Item_Option_Set;
132    --  Initial default options for an item.
133    pragma Inline (Default_Item_Options);
134
135    --
136    --  Item Array
137    --
138    type Item_Array is array (Positive range <>) of aliased Item;
139    pragma Convention (C, Item_Array);
140
141    type Item_Array_Access is access Item_Array;
142
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
147    --  the array.
148
149    --  MANPAGE(`mitem_new.3x')
150
151    --  ANCHOR(`new_item()',`Create')
152    function Create (Name        : String;
153                     Description : String := "") return Item;
154    --  AKA
155    --  Not inlined.
156
157    --  ANCHOR(`new_item()',`New_Item')
158    function New_Item (Name        : String;
159                       Description : String := "") return Item
160      renames Create;
161    --  AKA
162
163    --  ANCHOR(`free_item()',`Delete')
164    procedure Delete (Itm : in out Item);
165    --  AKA
166    --  Resets Itm to Null_Item
167
168    --  MANPAGE(`mitem_value.3x')
169
170    --  ANCHOR(`set_item_value()',`Set_Value')
171    procedure Set_Value (Itm   : in Item;
172                         Value : in Boolean := True);
173    --  AKA
174    pragma Inline (Set_Value);
175
176    --  ANCHOR(`item_value()',`Value')
177    function Value (Itm : Item) return Boolean;
178    --  AKA
179    pragma Inline (Value);
180
181    --  MANPAGE(`mitem_visible.3x')
182
183    --  ANCHOR(`item_visible()',`Visible')
184    function Visible (Itm : Item) return Boolean;
185    --  AKA
186    pragma Inline (Visible);
187
188    --  MANPAGE(`mitem_opts.3x')
189
190    --  ANCHOR(`set_item_opts()',`Set_Options')
191    procedure Set_Options (Itm     : in Item;
192                           Options : in Item_Option_Set);
193    --  AKA
194    --  An overloaded Set_Options is defined later. Pragma Inline appears there
195
196    --  ANCHOR(`item_opts_on()',`Switch_Options')
197    procedure Switch_Options (Itm     : in Item;
198                              Options : in Item_Option_Set;
199                              On      : Boolean := True);
200    --  AKA
201    --  ALIAS(`item_opts_off()')
202    --  An overloaded Switch_Options is defined later.
203    --  Pragma Inline appears there
204
205    --  ANCHOR(`item_opts()',`Get_Options')
206    procedure Get_Options (Itm     : in  Item;
207                           Options : out Item_Option_Set);
208    --  AKA
209
210    --  ANCHOR(`item_opts()',`Get_Options')
211    function Get_Options (Itm : Item := Null_Item) return Item_Option_Set;
212    --  AKA
213    --  An overloaded Get_Options is defined later. Pragma Inline appears there
214
215    --  MANPAGE(`mitem_name.3x')
216
217    --  ANCHOR(`item_name()',`Name')
218    procedure Name (Itm  : in Item;
219                    Name : out String);
220    --  AKA
221    function  Name (Itm : Item) return String;
222    --  AKA
223    --  Implemented as function
224    pragma Inline (Name);
225
226    --  ANCHOR(`item_description();',`Description')
227    procedure Description (Itm         : in Item;
228                           Description : out String);
229    --  AKA
230
231    function  Description (Itm : Item) return String;
232    --  AKA
233    --  Implemented as function
234    pragma Inline (Description);
235
236    --  MANPAGE(`mitem_current.3x')
237
238    --  ANCHOR(`set_current_item()',`Set_Current')
239    procedure Set_Current (Men : in Menu;
240                           Itm : in Item);
241    --  AKA
242    pragma Inline (Set_Current);
243
244    --  ANCHOR(`current_item()',`Current')
245    function Current (Men : Menu) return Item;
246    --  AKA
247    pragma Inline (Current);
248
249    --  ANCHOR(`set_top_row()',`Set_Top_Row')
250    procedure Set_Top_Row (Men  : in Menu;
251                           Line : in Line_Position);
252    --  AKA
253    pragma Inline (Set_Top_Row);
254
255    --  ANCHOR(`top_row()',`Top_Row')
256    function Top_Row (Men : Menu) return Line_Position;
257    --  AKA
258    pragma Inline (Top_Row);
259
260    --  ANCHOR(`item_index()',`Get_Index')
261    function Get_Index (Itm : Item) return Positive;
262    --  AKA
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
265    --  level call.
266    pragma Inline (Get_Index);
267
268    --  MANPAGE(`menu_post.3x')
269
270    --  ANCHOR(`post_menu()',`Post')
271    procedure Post (Men  : in Menu;
272                    Post : in Boolean := True);
273    --  AKA
274    --  ALIAS(`unpost_menu()')
275    pragma Inline (Post);
276
277    --  MANPAGE(`menu_opts.3x')
278
279    --  ANCHOR(`set_menu_opts()',`Set_Options')
280    procedure Set_Options (Men     : in Menu;
281                           Options : in Menu_Option_Set);
282    --  AKA
283    pragma Inline (Set_Options);
284
285    --  ANCHOR(`menu_opts_on()',`Switch_Options')
286    procedure Switch_Options (Men     : in Menu;
287                              Options : in Menu_Option_Set;
288                              On      : Boolean := True);
289    --  AKA
290    --  ALIAS(`menu_opts_off()')
291    pragma Inline (Switch_Options);
292
293    --  ANCHOR(`menu_opts()',`Get_Options')
294    procedure Get_Options (Men     : in  Menu;
295                           Options : out Menu_Option_Set);
296    --  AKA
297
298    --  ANCHOR(`menu_opts()',`Get_Options')
299    function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set;
300    --  AKA
301    pragma Inline (Get_Options);
302
303    --  MANPAGE(`menu_win.3x')
304
305    --  ANCHOR(`set_menu_win()',`Set_Window')
306    procedure Set_Window (Men : in Menu;
307                          Win : in Window);
308    --  AKA
309    pragma Inline (Set_Window);
310
311    --  ANCHOR(`menu_win()',`Get_Window')
312    function Get_Window (Men : Menu) return Window;
313    --  AKA
314    pragma Inline (Get_Window);
315
316    --  ANCHOR(`set_menu_sub()',`Set_Sub_Window')
317    procedure Set_Sub_Window (Men : in Menu;
318                              Win : in Window);
319    --  AKA
320    pragma Inline (Set_Sub_Window);
321
322    --  ANCHOR(`menu_sub()',`Get_Sub_Window')
323    function Get_Sub_Window (Men : Menu) return Window;
324    --  AKA
325    pragma Inline (Get_Sub_Window);
326
327    --  ANCHOR(`scale_menu()',`Scale')
328    procedure Scale (Men     : in Menu;
329                     Lines   : out Line_Count;
330                     Columns : out Column_Count);
331    --  AKA
332    pragma Inline (Scale);
333
334    --  MANPAGE(`menu_cursor.3x')
335
336    --  ANCHOR(`pos_menu_cursor()',`Position_Cursor')
337    procedure Position_Cursor (Men : Menu);
338    --  AKA
339    pragma Inline (Position_Cursor);
340
341    --  MANPAGE(`menu_mark.3x')
342
343    --  ANCHOR(`set_menu_mark()',`Set_Mark')
344    procedure Set_Mark (Men  : in Menu;
345                        Mark : in String);
346    --  AKA
347    pragma Inline (Set_Mark);
348
349    --  ANCHOR(`menu_mark()',`Mark')
350    procedure Mark (Men  : in  Menu;
351                    Mark : out String);
352    --  AKA
353
354    function  Mark (Men : Menu) return String;
355    --  AKA
356    --  Implemented as function
357    pragma Inline (Mark);
358
359    --  MANPAGE(`menu_attribs.3x')
360
361    --  ANCHOR(`set_menu_fore()',`Set_Foreground')
362    procedure Set_Foreground
363      (Men   : in Menu;
364       Fore  : in Character_Attribute_Set := Normal_Video;
365       Color : in Color_Pair := Color_Pair'First);
366    --  AKA
367    pragma Inline (Set_Foreground);
368
369    --  ANCHOR(`menu_fore()',`Foreground')
370    procedure Foreground (Men   : in  Menu;
371                          Fore  : out Character_Attribute_Set);
372    --  AKA
373
374    --  ANCHOR(`menu_fore()',`Foreground')
375    procedure Foreground (Men   : in  Menu;
376                          Fore  : out Character_Attribute_Set;
377                          Color : out Color_Pair);
378    --  AKA
379    pragma Inline (Foreground);
380
381    --  ANCHOR(`set_menu_back()',`Set_Background')
382    procedure Set_Background
383      (Men   : in Menu;
384       Back  : in Character_Attribute_Set := Normal_Video;
385       Color : in Color_Pair := Color_Pair'First);
386    --  AKA
387    pragma Inline (Set_Background);
388
389    --  ANCHOR(`menu_back()',`Background')
390    procedure Background (Men  : in  Menu;
391                          Back : out Character_Attribute_Set);
392    --  AKA
393    --  ANCHOR(`menu_back()',`Background')
394
395    procedure Background (Men   : in  Menu;
396                          Back  : out Character_Attribute_Set;
397                          Color : out Color_Pair);
398    --  AKA
399    pragma Inline (Background);
400
401    --  ANCHOR(`set_menu_grey()',`Set_Grey')
402    procedure Set_Grey
403      (Men   : in Menu;
404       Grey  : in Character_Attribute_Set := Normal_Video;
405       Color : in Color_Pair := Color_Pair'First);
406    --  AKA
407    pragma Inline (Set_Grey);
408
409    --  ANCHOR(`menu_grey()',`Grey')
410    procedure Grey (Men  : in  Menu;
411                    Grey : out Character_Attribute_Set);
412    --  AKA
413
414    --  ANCHOR(`menu_grey()',`Grey')
415    procedure Grey
416      (Men   : in  Menu;
417       Grey  : out Character_Attribute_Set;
418       Color : out Color_Pair);
419    --  AKA
420    pragma Inline (Grey);
421
422    --  ANCHOR(`set_menu_pad()',`Set_Pad_Character')
423    procedure Set_Pad_Character (Men : in Menu;
424                                 Pad : in Character := Space);
425    --  AKA
426    pragma Inline (Set_Pad_Character);
427
428    --  ANCHOR(`menu_pad()',`Pad_Character')
429    procedure Pad_Character (Men : in  Menu;
430                             Pad : out Character);
431    --  AKA
432    pragma Inline (Pad_Character);
433
434    --  MANPAGE(`menu_spacing.3x')
435
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);
441    --  AKA
442    pragma Inline (Set_Spacing);
443
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);
449    --  AKA
450    pragma Inline (Spacing);
451
452    --  MANPAGE(`menu_pattern.3x')
453
454    --  ANCHOR(`set_menu_pattern()',`Set_Pattern')
455    function Set_Pattern (Men  : Menu;
456                          Text : String) return Boolean;
457    --  AKA
458    --  Return TRUE if the pattern matches, FALSE otherwise
459    pragma Inline (Set_Pattern);
460
461    --  ANCHOR(`menu_pattern()',`Pattern')
462    procedure Pattern (Men  : in  Menu;
463                       Text : out String);
464    --  AKA
465    pragma Inline (Pattern);
466
467    --  MANPAGE(`menu_format.3x')
468
469    --  ANCHOR(`set_menu_format()',`Set_Format')
470    procedure Set_Format (Men     : in Menu;
471                          Lines   : in Line_Count;
472                          Columns : in Column_Count);
473    --  AKA
474    pragma Inline (Set_Format);
475
476    --  ANCHOR(`menu_format()',`Format')
477    procedure Format (Men     : in  Menu;
478                      Lines   : out Line_Count;
479                      Columns : out Column_Count);
480    --  AKA
481    pragma Inline (Format);
482
483    --  MANPAGE(`menu_hook.3x')
484
485    type Menu_Hook_Function is access procedure (Men : in Menu);
486    pragma Convention (C, Menu_Hook_Function);
487
488    --  ANCHOR(`set_item_init()',`Set_Item_Init_Hook')
489    procedure Set_Item_Init_Hook (Men  : in Menu;
490                                  Proc : in Menu_Hook_Function);
491    --  AKA
492    pragma Inline (Set_Item_Init_Hook);
493
494    --  ANCHOR(`set_item_term()',`Set_Item_Term_Hook')
495    procedure Set_Item_Term_Hook (Men  : in Menu;
496                                  Proc : in Menu_Hook_Function);
497    --  AKA
498    pragma Inline (Set_Item_Term_Hook);
499
500    --  ANCHOR(`set_menu_init()',`Set_Menu_Init_Hook')
501    procedure Set_Menu_Init_Hook (Men  : in Menu;
502                                  Proc : in Menu_Hook_Function);
503    --  AKA
504    pragma Inline (Set_Menu_Init_Hook);
505
506    --  ANCHOR(`set_menu_term()',`Set_Menu_Term_Hook')
507    procedure Set_Menu_Term_Hook (Men  : in Menu;
508                                  Proc : in Menu_Hook_Function);
509    --  AKA
510    pragma Inline (Set_Menu_Term_Hook);
511
512    --  ANCHOR(`item_init()',`Get_Item_Init_Hook')
513    function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function;
514    --  AKA
515    pragma Inline (Get_Item_Init_Hook);
516
517    --  ANCHOR(`item_term()',`Get_Item_Term_Hook')
518    function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function;
519    --  AKA
520    pragma Inline (Get_Item_Term_Hook);
521
522    --  ANCHOR(`menu_init()',`Get_Menu_Init_Hook')
523    function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function;
524    --  AKA
525    pragma Inline (Get_Menu_Init_Hook);
526
527    --  ANCHOR(`menu_term()',`Get_Menu_Term_Hook')
528    function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function;
529    --  AKA
530    pragma Inline (Get_Menu_Term_Hook);
531
532    --  MANPAGE(`menu_items.3x')
533
534    --  ANCHOR(`set_menu_items()',`Redefine')
535    procedure Redefine (Men   : in Menu;
536                        Items : in Item_Array_Access);
537    --  AKA
538    pragma Inline (Redefine);
539
540    procedure Set_Items (Men   : in Menu;
541                         Items : in Item_Array_Access) renames Redefine;
542    pragma Inline (Set_Items);
543
544    --  ANCHOR(`menu_items()',`Items')
545    function Items (Men   : Menu;
546                    Index : Positive) return Item;
547    --  AKA
548    pragma Inline (Items);
549
550    --  ANCHOR(`item_count()',`Item_Count')
551    function Item_Count (Men : Menu) return Natural;
552    --  AKA
553    pragma Inline (Item_Count);
554
555    --  MANPAGE(`menu_new.3x')
556
557    --  ANCHOR(`new_menu()',`Create')
558    function Create (Items : Item_Array_Access) return Menu;
559    --  AKA
560    --  Not inlined
561
562    function New_Menu (Items : Item_Array_Access) return Menu renames Create;
563
564    --  ANCHOR(`free_menu()',`Delete')
565    procedure Delete (Men : in out Menu);
566    --  AKA
567    --  Reset Men to Null_Menu
568    --  Not inlined
569
570    --  MANPAGE(`menu_new.3x')
571
572    type Driver_Result is (Menu_Ok,
573                           Request_Denied,
574                           Unknown_Request,
575                           No_Match);
576
577    --  ANCHOR(`menu_driver()',`Driver')
578    function Driver (Men : Menu;
579                     Key : Key_Code) return Driver_Result;
580    --  AKA
581    --  Driver is not inlined
582
583 -------------------------------------------------------------------------------
584 private
585    type Item   is new System.Address;
586    type Menu   is new System.Address;
587
588    Null_Item : constant Item := Item (System.Null_Address);
589    Null_Menu : constant Menu := Menu (System.Null_Address);
590
591 end Terminal_Interface.Curses.Menus;