]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/gen/terminal_interface-curses-menus.ads.m4
ncurses 5.4
[ncurses.git] / Ada95 / gen / terminal_interface-curses-menus.ads.m4
1 --  -*- ada -*-
2 define(`HTMLNAME',`terminal_interface-curses-menus__ads.htm')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, 1996
40 --  Version Control:
41 --  $Revision: 1.24 $
42 --  Binding Version 01.00
43 ------------------------------------------------------------------------------
44 include(`Menu_Base_Defs')
45 with System;
46 with Ada.Characters.Latin_1;
47
48 package Terminal_Interface.Curses.Menus is
49    pragma Preelaborate (Terminal_Interface.Curses.Menus);
50 include(`Menu_Linker_Options')dnl
51 include(`Linker_Options')
52    Space : Character renames Ada.Characters.Latin_1.Space;
53
54    type Item is private;
55    type Menu is private;
56
57    ---------------------------
58    --  Interface constants  --
59    ---------------------------
60    Null_Item : constant Item;
61    Null_Menu : constant Menu;
62
63    subtype Menu_Request_Code is Key_Code
64      range (Key_Max + 1) .. (Key_Max + 17);
65
66    --  The prefix M_ stands for "Menu Request"
67    M_Left_Item       : constant Menu_Request_Code := Key_Max + 1;
68    M_Right_Item      : constant Menu_Request_Code := Key_Max + 2;
69    M_Up_Item         : constant Menu_Request_Code := Key_Max + 3;
70    M_Down_Item       : constant Menu_Request_Code := Key_Max + 4;
71    M_ScrollUp_Line   : constant Menu_Request_Code := Key_Max + 5;
72    M_ScrollDown_Line : constant Menu_Request_Code := Key_Max + 6;
73    M_ScrollDown_Page : constant Menu_Request_Code := Key_Max + 7;
74    M_ScrollUp_Page   : constant Menu_Request_Code := Key_Max + 8;
75    M_First_Item      : constant Menu_Request_Code := Key_Max + 9;
76    M_Last_Item       : constant Menu_Request_Code := Key_Max + 10;
77    M_Next_Item       : constant Menu_Request_Code := Key_Max + 11;
78    M_Previous_Item   : constant Menu_Request_Code := Key_Max + 12;
79    M_Toggle_Item     : constant Menu_Request_Code := Key_Max + 13;
80    M_Clear_Pattern   : constant Menu_Request_Code := Key_Max + 14;
81    M_Back_Pattern    : constant Menu_Request_Code := Key_Max + 15;
82    M_Next_Match      : constant Menu_Request_Code := Key_Max + 16;
83    M_Previous_Match  : constant Menu_Request_Code := Key_Max + 17;
84
85    --  For those who like the old 'C' names for the request codes
86    REQ_LEFT_ITEM     : Menu_Request_Code renames M_Left_Item;
87    REQ_RIGHT_ITEM    : Menu_Request_Code renames M_Right_Item;
88    REQ_UP_ITEM       : Menu_Request_Code renames M_Up_Item;
89    REQ_DOWN_ITEM     : Menu_Request_Code renames M_Down_Item;
90    REQ_SCR_ULINE     : Menu_Request_Code renames M_ScrollUp_Line;
91    REQ_SCR_DLINE     : Menu_Request_Code renames M_ScrollDown_Line;
92    REQ_SCR_DPAGE     : Menu_Request_Code renames M_ScrollDown_Page;
93    REQ_SCR_UPAGE     : Menu_Request_Code renames M_ScrollUp_Page;
94    REQ_FIRST_ITEM    : Menu_Request_Code renames M_First_Item;
95    REQ_LAST_ITEM     : Menu_Request_Code renames M_Last_Item;
96    REQ_NEXT_ITEM     : Menu_Request_Code renames M_Next_Item;
97    REQ_PREV_ITEM     : Menu_Request_Code renames M_Previous_Item;
98    REQ_TOGGLE_ITEM   : Menu_Request_Code renames M_Toggle_Item;
99    REQ_CLEAR_PATTERN : Menu_Request_Code renames M_Clear_Pattern;
100    REQ_BACK_PATTERN  : Menu_Request_Code renames M_Back_Pattern;
101    REQ_NEXT_MATCH    : Menu_Request_Code renames M_Next_Match;
102    REQ_PREV_MATCH    : Menu_Request_Code renames M_Previous_Match;
103
104    procedure Request_Name (Key  : in Menu_Request_Code;
105                            Name : out String);
106
107    function  Request_Name (Key : Menu_Request_Code) return String;
108    --  Same as function
109
110    ------------------
111    --  Exceptions  --
112    ------------------
113
114    Menu_Exception : exception;
115    --
116    --  Menu options
117    --
118    pragma Warnings (Off);
119 include(`Menu_Opt_Rep')dnl
120
121    pragma Warnings (On);
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    pragma Warnings (Off);
130 include(`Item_Rep')dnl
131
132    pragma Warnings (On);
133
134    function Default_Item_Options return Item_Option_Set;
135    --  Initial default options for an item.
136    pragma Inline (Default_Item_Options);
137
138    --
139    --  Item Array
140    --
141    type Item_Array is array (Positive range <>) of aliased Item;
142    pragma Convention (C, Item_Array);
143
144    type Item_Array_Access is access Item_Array;
145
146    procedure Free (IA         : in out Item_Array_Access;
147                    Free_Items : Boolean := False);
148    --  Release the memory for an allocated item array
149    --  If Free_Items is True, call Delete() for all the items in
150    --  the array.
151
152    --  MANPAGE(`mitem_new.3x')
153
154    --  ANCHOR(`new_item()',`Create')
155    function Create (Name        : String;
156                     Description : String := "") return Item;
157    --  AKA
158    --  Not inlined.
159
160    --  ANCHOR(`new_item()',`New_Item')
161    function New_Item (Name        : String;
162                       Description : String := "") return Item
163      renames Create;
164    --  AKA
165
166    --  ANCHOR(`free_item()',`Delete')
167    procedure Delete (Itm : in out Item);
168    --  AKA
169    --  Resets Itm to Null_Item
170
171    --  MANPAGE(`mitem_value.3x')
172
173    --  ANCHOR(`set_item_value()',`Set_Value')
174    procedure Set_Value (Itm   : in Item;
175                         Value : in Boolean := True);
176    --  AKA
177    pragma Inline (Set_Value);
178
179    --  ANCHOR(`item_value()',`Value')
180    function Value (Itm : Item) return Boolean;
181    --  AKA
182    pragma Inline (Value);
183
184    --  MANPAGE(`mitem_visible.3x')
185
186    --  ANCHOR(`item_visible()',`Visible')
187    function Visible (Itm : Item) return Boolean;
188    --  AKA
189    pragma Inline (Visible);
190
191    --  MANPAGE(`mitem_opts.3x')
192
193    --  ANCHOR(`set_item_opts()',`Set_Options')
194    procedure Set_Options (Itm     : in Item;
195                           Options : in Item_Option_Set);
196    --  AKA
197    --  An overloaded Set_Options is defined later. Pragma Inline appears there
198
199    --  ANCHOR(`item_opts_on()',`Switch_Options')
200    procedure Switch_Options (Itm     : in Item;
201                              Options : in Item_Option_Set;
202                              On      : Boolean := True);
203    --  AKA
204    --  ALIAS(`item_opts_off()')
205    --  An overloaded Switch_Options is defined later.
206    --  Pragma Inline appears there
207
208    --  ANCHOR(`item_opts()',`Get_Options')
209    procedure Get_Options (Itm     : in  Item;
210                           Options : out Item_Option_Set);
211    --  AKA
212
213    --  ANCHOR(`item_opts()',`Get_Options')
214    function Get_Options (Itm : Item := Null_Item) return Item_Option_Set;
215    --  AKA
216    --  An overloaded Get_Options is defined later. Pragma Inline appears there
217
218    --  MANPAGE(`mitem_name.3x')
219
220    --  ANCHOR(`item_name()',`Name')
221    procedure Name (Itm  : in Item;
222                    Name : out String);
223    --  AKA
224    function  Name (Itm : Item) return String;
225    --  AKA
226    --  Implemented as function
227    pragma Inline (Name);
228
229    --  ANCHOR(`item_description();',`Description')
230    procedure Description (Itm         : in Item;
231                           Description : out String);
232    --  AKA
233
234    function  Description (Itm : Item) return String;
235    --  AKA
236    --  Implemented as function
237    pragma Inline (Description);
238
239    --  MANPAGE(`mitem_current.3x')
240
241    --  ANCHOR(`set_current_item()',`Set_Current')
242    procedure Set_Current (Men : in Menu;
243                           Itm : in Item);
244    --  AKA
245    pragma Inline (Set_Current);
246
247    --  ANCHOR(`current_item()',`Current')
248    function Current (Men : Menu) return Item;
249    --  AKA
250    pragma Inline (Current);
251
252    --  ANCHOR(`set_top_row()',`Set_Top_Row')
253    procedure Set_Top_Row (Men  : in Menu;
254                           Line : in Line_Position);
255    --  AKA
256    pragma Inline (Set_Top_Row);
257
258    --  ANCHOR(`top_row()',`Top_Row')
259    function Top_Row (Men : Menu) return Line_Position;
260    --  AKA
261    pragma Inline (Top_Row);
262
263    --  ANCHOR(`item_index()',`Get_Index')
264    function Get_Index (Itm : Item) return Positive;
265    --  AKA
266    --  Please note that in this binding we start the numbering of items
267    --  with 1. So this is number is one more than you get from the low
268    --  level call.
269    pragma Inline (Get_Index);
270
271    --  MANPAGE(`menu_post.3x')
272
273    --  ANCHOR(`post_menu()',`Post')
274    procedure Post (Men  : in Menu;
275                    Post : in Boolean := True);
276    --  AKA
277    --  ALIAS(`unpost_menu()')
278    pragma Inline (Post);
279
280    --  MANPAGE(`menu_opts.3x')
281
282    --  ANCHOR(`set_menu_opts()',`Set_Options')
283    procedure Set_Options (Men     : in Menu;
284                           Options : in Menu_Option_Set);
285    --  AKA
286    pragma Inline (Set_Options);
287
288    --  ANCHOR(`menu_opts_on()',`Switch_Options')
289    procedure Switch_Options (Men     : in Menu;
290                              Options : in Menu_Option_Set;
291                              On      : Boolean := True);
292    --  AKA
293    --  ALIAS(`menu_opts_off()')
294    pragma Inline (Switch_Options);
295
296    --  ANCHOR(`menu_opts()',`Get_Options')
297    procedure Get_Options (Men     : in  Menu;
298                           Options : out Menu_Option_Set);
299    --  AKA
300
301    --  ANCHOR(`menu_opts()',`Get_Options')
302    function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set;
303    --  AKA
304    pragma Inline (Get_Options);
305
306    --  MANPAGE(`menu_win.3x')
307
308    --  ANCHOR(`set_menu_win()',`Set_Window')
309    procedure Set_Window (Men : in Menu;
310                          Win : in Window);
311    --  AKA
312    pragma Inline (Set_Window);
313
314    --  ANCHOR(`menu_win()',`Get_Window')
315    function Get_Window (Men : Menu) return Window;
316    --  AKA
317    pragma Inline (Get_Window);
318
319    --  ANCHOR(`set_menu_sub()',`Set_Sub_Window')
320    procedure Set_Sub_Window (Men : in Menu;
321                              Win : in Window);
322    --  AKA
323    pragma Inline (Set_Sub_Window);
324
325    --  ANCHOR(`menu_sub()',`Get_Sub_Window')
326    function Get_Sub_Window (Men : Menu) return Window;
327    --  AKA
328    pragma Inline (Get_Sub_Window);
329
330    --  ANCHOR(`scale_menu()',`Scale')
331    procedure Scale (Men     : in Menu;
332                     Lines   : out Line_Count;
333                     Columns : out Column_Count);
334    --  AKA
335    pragma Inline (Scale);
336
337    --  MANPAGE(`menu_cursor.3x')
338
339    --  ANCHOR(`pos_menu_cursor()',`Position_Cursor')
340    procedure Position_Cursor (Men : Menu);
341    --  AKA
342    pragma Inline (Position_Cursor);
343
344    --  MANPAGE(`menu_mark.3x')
345
346    --  ANCHOR(`set_menu_mark()',`Set_Mark')
347    procedure Set_Mark (Men  : in Menu;
348                        Mark : in String);
349    --  AKA
350    pragma Inline (Set_Mark);
351
352    --  ANCHOR(`menu_mark()',`Mark')
353    procedure Mark (Men  : in  Menu;
354                    Mark : out String);
355    --  AKA
356
357    function  Mark (Men : Menu) return String;
358    --  AKA
359    --  Implemented as function
360    pragma Inline (Mark);
361
362    --  MANPAGE(`menu_attribs.3x')
363
364    --  ANCHOR(`set_menu_fore()',`Set_Foreground')
365    procedure Set_Foreground
366      (Men   : in Menu;
367       Fore  : in Character_Attribute_Set := Normal_Video;
368       Color : in Color_Pair := Color_Pair'First);
369    --  AKA
370    pragma Inline (Set_Foreground);
371
372    --  ANCHOR(`menu_fore()',`Foreground')
373    procedure Foreground (Men   : in  Menu;
374                          Fore  : out Character_Attribute_Set);
375    --  AKA
376
377    --  ANCHOR(`menu_fore()',`Foreground')
378    procedure Foreground (Men   : in  Menu;
379                          Fore  : out Character_Attribute_Set;
380                          Color : out Color_Pair);
381    --  AKA
382    pragma Inline (Foreground);
383
384    --  ANCHOR(`set_menu_back()',`Set_Background')
385    procedure Set_Background
386      (Men   : in Menu;
387       Back  : in Character_Attribute_Set := Normal_Video;
388       Color : in Color_Pair := Color_Pair'First);
389    --  AKA
390    pragma Inline (Set_Background);
391
392    --  ANCHOR(`menu_back()',`Background')
393    procedure Background (Men  : in  Menu;
394                          Back : out Character_Attribute_Set);
395    --  AKA
396    --  ANCHOR(`menu_back()',`Background')
397
398    procedure Background (Men   : in  Menu;
399                          Back  : out Character_Attribute_Set;
400                          Color : out Color_Pair);
401    --  AKA
402    pragma Inline (Background);
403
404    --  ANCHOR(`set_menu_grey()',`Set_Grey')
405    procedure Set_Grey
406      (Men   : in Menu;
407       Grey  : in Character_Attribute_Set := Normal_Video;
408       Color : in Color_Pair := Color_Pair'First);
409    --  AKA
410    pragma Inline (Set_Grey);
411
412    --  ANCHOR(`menu_grey()',`Grey')
413    procedure Grey (Men  : in  Menu;
414                    Grey : out Character_Attribute_Set);
415    --  AKA
416
417    --  ANCHOR(`menu_grey()',`Grey')
418    procedure Grey
419      (Men   : in  Menu;
420       Grey  : out Character_Attribute_Set;
421       Color : out Color_Pair);
422    --  AKA
423    pragma Inline (Grey);
424
425    --  ANCHOR(`set_menu_pad()',`Set_Pad_Character')
426    procedure Set_Pad_Character (Men : in Menu;
427                                 Pad : in Character := Space);
428    --  AKA
429    pragma Inline (Set_Pad_Character);
430
431    --  ANCHOR(`menu_pad()',`Pad_Character')
432    procedure Pad_Character (Men : in  Menu;
433                             Pad : out Character);
434    --  AKA
435    pragma Inline (Pad_Character);
436
437    --  MANPAGE(`menu_spacing.3x')
438
439    --  ANCHOR(`set_menu_spacing()',`Set_Spacing')
440    procedure Set_Spacing (Men   : in Menu;
441                           Descr : in Column_Position := 0;
442                           Row   : in Line_Position   := 0;
443                           Col   : in Column_Position := 0);
444    --  AKA
445    pragma Inline (Set_Spacing);
446
447    --  ANCHOR(`menu_spacing()',`Spacing')
448    procedure Spacing (Men   : in Menu;
449                       Descr : out Column_Position;
450                       Row   : out Line_Position;
451                       Col   : out Column_Position);
452    --  AKA
453    pragma Inline (Spacing);
454
455    --  MANPAGE(`menu_pattern.3x')
456
457    --  ANCHOR(`set_menu_pattern()',`Set_Pattern')
458    function Set_Pattern (Men  : Menu;
459                          Text : String) return Boolean;
460    --  AKA
461    --  Return TRUE if the pattern matches, FALSE otherwise
462    pragma Inline (Set_Pattern);
463
464    --  ANCHOR(`menu_pattern()',`Pattern')
465    procedure Pattern (Men  : in  Menu;
466                       Text : out String);
467    --  AKA
468    pragma Inline (Pattern);
469
470    --  MANPAGE(`menu_format.3x')
471
472    --  ANCHOR(`set_menu_format()',`Set_Format')
473    procedure Set_Format (Men     : in Menu;
474                          Lines   : in Line_Count;
475                          Columns : in Column_Count);
476    --  Not implemented: 0 argument for Lines or Columns;
477    --  instead use Format to get the current sizes
478    --      The  default  format  is  16  rows,  1  column.    Calling
479    --      set_menu_format  with a null menu pointer will change this
480    --      default.  A zero row or column argument to set_menu_format
481    --      is  interpreted  as  a  request  not to change the current
482    --      value.
483    --  AKA
484    pragma Inline (Set_Format);
485
486    --  ANCHOR(`menu_format()',`Format')
487    procedure Format (Men     : in  Menu;
488                      Lines   : out Line_Count;
489                      Columns : out Column_Count);
490    --  AKA
491    pragma Inline (Format);
492
493    --  MANPAGE(`menu_hook.3x')
494
495    type Menu_Hook_Function is access procedure (Men : in Menu);
496    pragma Convention (C, Menu_Hook_Function);
497
498    --  ANCHOR(`set_item_init()',`Set_Item_Init_Hook')
499    procedure Set_Item_Init_Hook (Men  : in Menu;
500                                  Proc : in Menu_Hook_Function);
501    --  AKA
502    pragma Inline (Set_Item_Init_Hook);
503
504    --  ANCHOR(`set_item_term()',`Set_Item_Term_Hook')
505    procedure Set_Item_Term_Hook (Men  : in Menu;
506                                  Proc : in Menu_Hook_Function);
507    --  AKA
508    pragma Inline (Set_Item_Term_Hook);
509
510    --  ANCHOR(`set_menu_init()',`Set_Menu_Init_Hook')
511    procedure Set_Menu_Init_Hook (Men  : in Menu;
512                                  Proc : in Menu_Hook_Function);
513    --  AKA
514    pragma Inline (Set_Menu_Init_Hook);
515
516    --  ANCHOR(`set_menu_term()',`Set_Menu_Term_Hook')
517    procedure Set_Menu_Term_Hook (Men  : in Menu;
518                                  Proc : in Menu_Hook_Function);
519    --  AKA
520    pragma Inline (Set_Menu_Term_Hook);
521
522    --  ANCHOR(`item_init()',`Get_Item_Init_Hook')
523    function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function;
524    --  AKA
525    pragma Inline (Get_Item_Init_Hook);
526
527    --  ANCHOR(`item_term()',`Get_Item_Term_Hook')
528    function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function;
529    --  AKA
530    pragma Inline (Get_Item_Term_Hook);
531
532    --  ANCHOR(`menu_init()',`Get_Menu_Init_Hook')
533    function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function;
534    --  AKA
535    pragma Inline (Get_Menu_Init_Hook);
536
537    --  ANCHOR(`menu_term()',`Get_Menu_Term_Hook')
538    function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function;
539    --  AKA
540    pragma Inline (Get_Menu_Term_Hook);
541
542    --  MANPAGE(`menu_items.3x')
543
544    --  ANCHOR(`set_menu_items()',`Redefine')
545    procedure Redefine (Men   : in Menu;
546                        Items : in Item_Array_Access);
547    --  AKA
548    pragma Inline (Redefine);
549
550    procedure Set_Items (Men   : in Menu;
551                         Items : in Item_Array_Access) renames Redefine;
552    pragma Inline (Set_Items);
553
554    --  ANCHOR(`menu_items()',`Items')
555    function Items (Men   : Menu;
556                    Index : Positive) return Item;
557    --  AKA
558    pragma Inline (Items);
559
560    --  ANCHOR(`item_count()',`Item_Count')
561    function Item_Count (Men : Menu) return Natural;
562    --  AKA
563    pragma Inline (Item_Count);
564
565    --  MANPAGE(`menu_new.3x')
566
567    --  ANCHOR(`new_menu()',`Create')
568    function Create (Items : Item_Array_Access) return Menu;
569    --  AKA
570    --  Not inlined
571
572    function New_Menu (Items : Item_Array_Access) return Menu renames Create;
573
574    --  ANCHOR(`free_menu()',`Delete')
575    procedure Delete (Men : in out Menu);
576    --  AKA
577    --  Reset Men to Null_Menu
578    --  Not inlined
579
580    --  MANPAGE(`menu_driver.3x')
581
582    type Driver_Result is (Menu_Ok,
583                           Request_Denied,
584                           Unknown_Request,
585                           No_Match);
586
587    --  ANCHOR(`menu_driver()',`Driver')
588    function Driver (Men : Menu;
589                     Key : Key_Code) return Driver_Result;
590    --  AKA
591    --  Driver is not inlined
592
593    --  ANCHOR(`menu_requestname.3x')
594    --  Not Implemented: menu_request_name, menu_request_by_name
595 -------------------------------------------------------------------------------
596 private
597    type Item   is new System.Storage_Elements.Integer_Address;
598    type Menu   is new System.Storage_Elements.Integer_Address;
599
600    Null_Item : constant Item := 0;
601    Null_Menu : constant Menu := 0;
602
603 end Terminal_Interface.Curses.Menus;