Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | ------------------------------------------------------------------------------ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 13 | -- Copyright (c) 1998-2009,2014 Free Software Foundation, Inc. -- |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 41 | -- $Revision: 1.31 $ |
| 42 | -- $Date: 2014/05/24 21:31:57 $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 43 | -- Binding Version 01.00 |
| 44 | ------------------------------------------------------------------------------ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 45 | with System; |
| 46 | with Ada.Characters.Latin_1; |
| 47 | |
| 48 | package Terminal_Interface.Curses.Menus is |
| 49 | pragma Preelaborate (Terminal_Interface.Curses.Menus); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 50 | pragma Linker_Options ("-lmenu" & Curses_Constants.DFT_ARG_SUFFIX); |
| 51 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 104 | procedure Request_Name (Key : Menu_Request_Code; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | -- |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 118 | type Menu_Option_Set is |
| 119 | record |
| 120 | One_Valued : Boolean; |
| 121 | Show_Descriptions : Boolean; |
| 122 | Row_Major_Order : Boolean; |
| 123 | Ignore_Case : Boolean; |
| 124 | Show_Matches : Boolean; |
| 125 | Non_Cyclic : Boolean; |
| 126 | end record; |
| 127 | pragma Convention (C_Pass_By_Copy, Menu_Option_Set); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 128 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 129 | for Menu_Option_Set use |
| 130 | record |
| 131 | One_Valued at 0 range Curses_Constants.O_ONEVALUE_First |
| 132 | .. Curses_Constants.O_ONEVALUE_Last; |
| 133 | Show_Descriptions at 0 range Curses_Constants.O_SHOWDESC_First |
| 134 | .. Curses_Constants.O_SHOWDESC_Last; |
| 135 | Row_Major_Order at 0 range Curses_Constants.O_ROWMAJOR_First |
| 136 | .. Curses_Constants.O_ROWMAJOR_Last; |
| 137 | Ignore_Case at 0 range Curses_Constants.O_IGNORECASE_First |
| 138 | .. Curses_Constants.O_IGNORECASE_Last; |
| 139 | Show_Matches at 0 range Curses_Constants.O_SHOWMATCH_First |
| 140 | .. Curses_Constants.O_SHOWMATCH_Last; |
| 141 | Non_Cyclic at 0 range Curses_Constants.O_NONCYCLIC_First |
| 142 | .. Curses_Constants.O_NONCYCLIC_Last; |
| 143 | end record; |
| 144 | pragma Warnings (Off); |
| 145 | for Menu_Option_Set'Size use Curses_Constants.Menu_Options_Size; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 146 | pragma Warnings (On); |
| 147 | |
| 148 | function Default_Menu_Options return Menu_Option_Set; |
| 149 | -- Initial default options for a menu. |
| 150 | pragma Inline (Default_Menu_Options); |
| 151 | -- |
| 152 | -- Item options |
| 153 | -- |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 154 | type Item_Option_Set is |
| 155 | record |
| 156 | Selectable : Boolean; |
| 157 | end record; |
| 158 | pragma Convention (C_Pass_By_Copy, Item_Option_Set); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 159 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 160 | for Item_Option_Set use |
| 161 | record |
| 162 | Selectable at 0 range Curses_Constants.O_SELECTABLE_First |
| 163 | .. Curses_Constants.O_SELECTABLE_Last; |
| 164 | end record; |
| 165 | pragma Warnings (Off); |
| 166 | for Item_Option_Set'Size use Curses_Constants.Item_Options_Size; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 167 | pragma Warnings (On); |
| 168 | |
| 169 | function Default_Item_Options return Item_Option_Set; |
| 170 | -- Initial default options for an item. |
| 171 | pragma Inline (Default_Item_Options); |
| 172 | |
| 173 | -- |
| 174 | -- Item Array |
| 175 | -- |
| 176 | type Item_Array is array (Positive range <>) of aliased Item; |
| 177 | pragma Convention (C, Item_Array); |
| 178 | |
| 179 | type Item_Array_Access is access Item_Array; |
| 180 | |
| 181 | procedure Free (IA : in out Item_Array_Access; |
| 182 | Free_Items : Boolean := False); |
| 183 | -- Release the memory for an allocated item array |
| 184 | -- If Free_Items is True, call Delete() for all the items in |
| 185 | -- the array. |
| 186 | |
| 187 | -- MANPAGE(`mitem_new.3x') |
| 188 | |
| 189 | -- ANCHOR(`new_item()',`Create') |
| 190 | function Create (Name : String; |
| 191 | Description : String := "") return Item; |
| 192 | -- AKA |
| 193 | -- Not inlined. |
| 194 | |
| 195 | -- ANCHOR(`new_item()',`New_Item') |
| 196 | function New_Item (Name : String; |
| 197 | Description : String := "") return Item |
| 198 | renames Create; |
| 199 | -- AKA |
| 200 | |
| 201 | -- ANCHOR(`free_item()',`Delete') |
| 202 | procedure Delete (Itm : in out Item); |
| 203 | -- AKA |
| 204 | -- Resets Itm to Null_Item |
| 205 | |
| 206 | -- MANPAGE(`mitem_value.3x') |
| 207 | |
| 208 | -- ANCHOR(`set_item_value()',`Set_Value') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 209 | procedure Set_Value (Itm : Item; |
| 210 | Value : Boolean := True); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 211 | -- AKA |
| 212 | pragma Inline (Set_Value); |
| 213 | |
| 214 | -- ANCHOR(`item_value()',`Value') |
| 215 | function Value (Itm : Item) return Boolean; |
| 216 | -- AKA |
| 217 | pragma Inline (Value); |
| 218 | |
| 219 | -- MANPAGE(`mitem_visible.3x') |
| 220 | |
| 221 | -- ANCHOR(`item_visible()',`Visible') |
| 222 | function Visible (Itm : Item) return Boolean; |
| 223 | -- AKA |
| 224 | pragma Inline (Visible); |
| 225 | |
| 226 | -- MANPAGE(`mitem_opts.3x') |
| 227 | |
| 228 | -- ANCHOR(`set_item_opts()',`Set_Options') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 229 | procedure Set_Options (Itm : Item; |
| 230 | Options : Item_Option_Set); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 231 | -- AKA |
| 232 | -- An overloaded Set_Options is defined later. Pragma Inline appears there |
| 233 | |
| 234 | -- ANCHOR(`item_opts_on()',`Switch_Options') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 235 | procedure Switch_Options (Itm : Item; |
| 236 | Options : Item_Option_Set; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 237 | On : Boolean := True); |
| 238 | -- AKA |
| 239 | -- ALIAS(`item_opts_off()') |
| 240 | -- An overloaded Switch_Options is defined later. |
| 241 | -- Pragma Inline appears there |
| 242 | |
| 243 | -- ANCHOR(`item_opts()',`Get_Options') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 244 | procedure Get_Options (Itm : Item; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 245 | Options : out Item_Option_Set); |
| 246 | -- AKA |
| 247 | |
| 248 | -- ANCHOR(`item_opts()',`Get_Options') |
| 249 | function Get_Options (Itm : Item := Null_Item) return Item_Option_Set; |
| 250 | -- AKA |
| 251 | -- An overloaded Get_Options is defined later. Pragma Inline appears there |
| 252 | |
| 253 | -- MANPAGE(`mitem_name.3x') |
| 254 | |
| 255 | -- ANCHOR(`item_name()',`Name') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 256 | procedure Name (Itm : Item; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 257 | Name : out String); |
| 258 | -- AKA |
| 259 | function Name (Itm : Item) return String; |
| 260 | -- AKA |
| 261 | -- Implemented as function |
| 262 | pragma Inline (Name); |
| 263 | |
| 264 | -- ANCHOR(`item_description();',`Description') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 265 | procedure Description (Itm : Item; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 266 | Description : out String); |
| 267 | -- AKA |
| 268 | |
| 269 | function Description (Itm : Item) return String; |
| 270 | -- AKA |
| 271 | -- Implemented as function |
| 272 | pragma Inline (Description); |
| 273 | |
| 274 | -- MANPAGE(`mitem_current.3x') |
| 275 | |
| 276 | -- ANCHOR(`set_current_item()',`Set_Current') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 277 | procedure Set_Current (Men : Menu; |
| 278 | Itm : Item); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 279 | -- AKA |
| 280 | pragma Inline (Set_Current); |
| 281 | |
| 282 | -- ANCHOR(`current_item()',`Current') |
| 283 | function Current (Men : Menu) return Item; |
| 284 | -- AKA |
| 285 | pragma Inline (Current); |
| 286 | |
| 287 | -- ANCHOR(`set_top_row()',`Set_Top_Row') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 288 | procedure Set_Top_Row (Men : Menu; |
| 289 | Line : Line_Position); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 290 | -- AKA |
| 291 | pragma Inline (Set_Top_Row); |
| 292 | |
| 293 | -- ANCHOR(`top_row()',`Top_Row') |
| 294 | function Top_Row (Men : Menu) return Line_Position; |
| 295 | -- AKA |
| 296 | pragma Inline (Top_Row); |
| 297 | |
| 298 | -- ANCHOR(`item_index()',`Get_Index') |
| 299 | function Get_Index (Itm : Item) return Positive; |
| 300 | -- AKA |
| 301 | -- Please note that in this binding we start the numbering of items |
| 302 | -- with 1. So this is number is one more than you get from the low |
| 303 | -- level call. |
| 304 | pragma Inline (Get_Index); |
| 305 | |
| 306 | -- MANPAGE(`menu_post.3x') |
| 307 | |
| 308 | -- ANCHOR(`post_menu()',`Post') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 309 | procedure Post (Men : Menu; |
| 310 | Post : Boolean := True); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 311 | -- AKA |
| 312 | -- ALIAS(`unpost_menu()') |
| 313 | pragma Inline (Post); |
| 314 | |
| 315 | -- MANPAGE(`menu_opts.3x') |
| 316 | |
| 317 | -- ANCHOR(`set_menu_opts()',`Set_Options') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 318 | procedure Set_Options (Men : Menu; |
| 319 | Options : Menu_Option_Set); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 320 | -- AKA |
| 321 | pragma Inline (Set_Options); |
| 322 | |
| 323 | -- ANCHOR(`menu_opts_on()',`Switch_Options') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 324 | procedure Switch_Options (Men : Menu; |
| 325 | Options : Menu_Option_Set; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 326 | On : Boolean := True); |
| 327 | -- AKA |
| 328 | -- ALIAS(`menu_opts_off()') |
| 329 | pragma Inline (Switch_Options); |
| 330 | |
| 331 | -- ANCHOR(`menu_opts()',`Get_Options') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 332 | procedure Get_Options (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 333 | Options : out Menu_Option_Set); |
| 334 | -- AKA |
| 335 | |
| 336 | -- ANCHOR(`menu_opts()',`Get_Options') |
| 337 | function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set; |
| 338 | -- AKA |
| 339 | pragma Inline (Get_Options); |
| 340 | |
| 341 | -- MANPAGE(`menu_win.3x') |
| 342 | |
| 343 | -- ANCHOR(`set_menu_win()',`Set_Window') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 344 | procedure Set_Window (Men : Menu; |
| 345 | Win : Window); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 346 | -- AKA |
| 347 | pragma Inline (Set_Window); |
| 348 | |
| 349 | -- ANCHOR(`menu_win()',`Get_Window') |
| 350 | function Get_Window (Men : Menu) return Window; |
| 351 | -- AKA |
| 352 | pragma Inline (Get_Window); |
| 353 | |
| 354 | -- ANCHOR(`set_menu_sub()',`Set_Sub_Window') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 355 | procedure Set_Sub_Window (Men : Menu; |
| 356 | Win : Window); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 357 | -- AKA |
| 358 | pragma Inline (Set_Sub_Window); |
| 359 | |
| 360 | -- ANCHOR(`menu_sub()',`Get_Sub_Window') |
| 361 | function Get_Sub_Window (Men : Menu) return Window; |
| 362 | -- AKA |
| 363 | pragma Inline (Get_Sub_Window); |
| 364 | |
| 365 | -- ANCHOR(`scale_menu()',`Scale') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 366 | procedure Scale (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 367 | Lines : out Line_Count; |
| 368 | Columns : out Column_Count); |
| 369 | -- AKA |
| 370 | pragma Inline (Scale); |
| 371 | |
| 372 | -- MANPAGE(`menu_cursor.3x') |
| 373 | |
| 374 | -- ANCHOR(`pos_menu_cursor()',`Position_Cursor') |
| 375 | procedure Position_Cursor (Men : Menu); |
| 376 | -- AKA |
| 377 | pragma Inline (Position_Cursor); |
| 378 | |
| 379 | -- MANPAGE(`menu_mark.3x') |
| 380 | |
| 381 | -- ANCHOR(`set_menu_mark()',`Set_Mark') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 382 | procedure Set_Mark (Men : Menu; |
| 383 | Mark : String); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 384 | -- AKA |
| 385 | pragma Inline (Set_Mark); |
| 386 | |
| 387 | -- ANCHOR(`menu_mark()',`Mark') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 388 | procedure Mark (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 389 | Mark : out String); |
| 390 | -- AKA |
| 391 | |
| 392 | function Mark (Men : Menu) return String; |
| 393 | -- AKA |
| 394 | -- Implemented as function |
| 395 | pragma Inline (Mark); |
| 396 | |
| 397 | -- MANPAGE(`menu_attributes.3x') |
| 398 | |
| 399 | -- ANCHOR(`set_menu_fore()',`Set_Foreground') |
| 400 | procedure Set_Foreground |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 401 | (Men : Menu; |
| 402 | Fore : Character_Attribute_Set := Normal_Video; |
| 403 | Color : Color_Pair := Color_Pair'First); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 404 | -- AKA |
| 405 | pragma Inline (Set_Foreground); |
| 406 | |
| 407 | -- ANCHOR(`menu_fore()',`Foreground') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 408 | procedure Foreground (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 409 | Fore : out Character_Attribute_Set); |
| 410 | -- AKA |
| 411 | |
| 412 | -- ANCHOR(`menu_fore()',`Foreground') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 413 | procedure Foreground (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 414 | Fore : out Character_Attribute_Set; |
| 415 | Color : out Color_Pair); |
| 416 | -- AKA |
| 417 | pragma Inline (Foreground); |
| 418 | |
| 419 | -- ANCHOR(`set_menu_back()',`Set_Background') |
| 420 | procedure Set_Background |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 421 | (Men : Menu; |
| 422 | Back : Character_Attribute_Set := Normal_Video; |
| 423 | Color : Color_Pair := Color_Pair'First); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 424 | -- AKA |
| 425 | pragma Inline (Set_Background); |
| 426 | |
| 427 | -- ANCHOR(`menu_back()',`Background') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 428 | procedure Background (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 429 | Back : out Character_Attribute_Set); |
| 430 | -- AKA |
| 431 | -- ANCHOR(`menu_back()',`Background') |
| 432 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 433 | procedure Background (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 434 | Back : out Character_Attribute_Set; |
| 435 | Color : out Color_Pair); |
| 436 | -- AKA |
| 437 | pragma Inline (Background); |
| 438 | |
| 439 | -- ANCHOR(`set_menu_grey()',`Set_Grey') |
| 440 | procedure Set_Grey |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 441 | (Men : Menu; |
| 442 | Grey : Character_Attribute_Set := Normal_Video; |
| 443 | Color : Color_Pair := Color_Pair'First); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 444 | -- AKA |
| 445 | pragma Inline (Set_Grey); |
| 446 | |
| 447 | -- ANCHOR(`menu_grey()',`Grey') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 448 | procedure Grey (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 449 | Grey : out Character_Attribute_Set); |
| 450 | -- AKA |
| 451 | |
| 452 | -- ANCHOR(`menu_grey()',`Grey') |
| 453 | procedure Grey |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 454 | (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 455 | Grey : out Character_Attribute_Set; |
| 456 | Color : out Color_Pair); |
| 457 | -- AKA |
| 458 | pragma Inline (Grey); |
| 459 | |
| 460 | -- ANCHOR(`set_menu_pad()',`Set_Pad_Character') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 461 | procedure Set_Pad_Character (Men : Menu; |
| 462 | Pad : Character := Space); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 463 | -- AKA |
| 464 | pragma Inline (Set_Pad_Character); |
| 465 | |
| 466 | -- ANCHOR(`menu_pad()',`Pad_Character') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 467 | procedure Pad_Character (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 468 | Pad : out Character); |
| 469 | -- AKA |
| 470 | pragma Inline (Pad_Character); |
| 471 | |
| 472 | -- MANPAGE(`menu_spacing.3x') |
| 473 | |
| 474 | -- ANCHOR(`set_menu_spacing()',`Set_Spacing') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 475 | procedure Set_Spacing (Men : Menu; |
| 476 | Descr : Column_Position := 0; |
| 477 | Row : Line_Position := 0; |
| 478 | Col : Column_Position := 0); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 479 | -- AKA |
| 480 | pragma Inline (Set_Spacing); |
| 481 | |
| 482 | -- ANCHOR(`menu_spacing()',`Spacing') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 483 | procedure Spacing (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 484 | Descr : out Column_Position; |
| 485 | Row : out Line_Position; |
| 486 | Col : out Column_Position); |
| 487 | -- AKA |
| 488 | pragma Inline (Spacing); |
| 489 | |
| 490 | -- MANPAGE(`menu_pattern.3x') |
| 491 | |
| 492 | -- ANCHOR(`set_menu_pattern()',`Set_Pattern') |
| 493 | function Set_Pattern (Men : Menu; |
| 494 | Text : String) return Boolean; |
| 495 | -- AKA |
| 496 | -- Return TRUE if the pattern matches, FALSE otherwise |
| 497 | pragma Inline (Set_Pattern); |
| 498 | |
| 499 | -- ANCHOR(`menu_pattern()',`Pattern') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 500 | procedure Pattern (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 501 | Text : out String); |
| 502 | -- AKA |
| 503 | pragma Inline (Pattern); |
| 504 | |
| 505 | -- MANPAGE(`menu_format.3x') |
| 506 | |
| 507 | -- ANCHOR(`set_menu_format()',`Set_Format') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 508 | procedure Set_Format (Men : Menu; |
| 509 | Lines : Line_Count; |
| 510 | Columns : Column_Count); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 511 | -- Not implemented: 0 argument for Lines or Columns; |
| 512 | -- instead use Format to get the current sizes |
| 513 | -- The default format is 16 rows, 1 column. Calling |
| 514 | -- set_menu_format with a null menu pointer will change this |
| 515 | -- default. A zero row or column argument to set_menu_format |
| 516 | -- is interpreted as a request not to change the current |
| 517 | -- value. |
| 518 | -- AKA |
| 519 | pragma Inline (Set_Format); |
| 520 | |
| 521 | -- ANCHOR(`menu_format()',`Format') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 522 | procedure Format (Men : Menu; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 523 | Lines : out Line_Count; |
| 524 | Columns : out Column_Count); |
| 525 | -- AKA |
| 526 | pragma Inline (Format); |
| 527 | |
| 528 | -- MANPAGE(`menu_hook.3x') |
| 529 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 530 | type Menu_Hook_Function is access procedure (Men : Menu); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 531 | pragma Convention (C, Menu_Hook_Function); |
| 532 | |
| 533 | -- ANCHOR(`set_item_init()',`Set_Item_Init_Hook') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 534 | procedure Set_Item_Init_Hook (Men : Menu; |
| 535 | Proc : Menu_Hook_Function); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 536 | -- AKA |
| 537 | pragma Inline (Set_Item_Init_Hook); |
| 538 | |
| 539 | -- ANCHOR(`set_item_term()',`Set_Item_Term_Hook') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 540 | procedure Set_Item_Term_Hook (Men : Menu; |
| 541 | Proc : Menu_Hook_Function); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 542 | -- AKA |
| 543 | pragma Inline (Set_Item_Term_Hook); |
| 544 | |
| 545 | -- ANCHOR(`set_menu_init()',`Set_Menu_Init_Hook') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 546 | procedure Set_Menu_Init_Hook (Men : Menu; |
| 547 | Proc : Menu_Hook_Function); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 548 | -- AKA |
| 549 | pragma Inline (Set_Menu_Init_Hook); |
| 550 | |
| 551 | -- ANCHOR(`set_menu_term()',`Set_Menu_Term_Hook') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 552 | procedure Set_Menu_Term_Hook (Men : Menu; |
| 553 | Proc : Menu_Hook_Function); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 554 | -- AKA |
| 555 | pragma Inline (Set_Menu_Term_Hook); |
| 556 | |
| 557 | -- ANCHOR(`item_init()',`Get_Item_Init_Hook') |
| 558 | function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function; |
| 559 | -- AKA |
| 560 | pragma Inline (Get_Item_Init_Hook); |
| 561 | |
| 562 | -- ANCHOR(`item_term()',`Get_Item_Term_Hook') |
| 563 | function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function; |
| 564 | -- AKA |
| 565 | pragma Inline (Get_Item_Term_Hook); |
| 566 | |
| 567 | -- ANCHOR(`menu_init()',`Get_Menu_Init_Hook') |
| 568 | function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function; |
| 569 | -- AKA |
| 570 | pragma Inline (Get_Menu_Init_Hook); |
| 571 | |
| 572 | -- ANCHOR(`menu_term()',`Get_Menu_Term_Hook') |
| 573 | function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function; |
| 574 | -- AKA |
| 575 | pragma Inline (Get_Menu_Term_Hook); |
| 576 | |
| 577 | -- MANPAGE(`menu_items.3x') |
| 578 | |
| 579 | -- ANCHOR(`set_menu_items()',`Redefine') |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 580 | procedure Redefine (Men : Menu; |
| 581 | Items : Item_Array_Access); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 582 | -- AKA |
| 583 | pragma Inline (Redefine); |
| 584 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 585 | procedure Set_Items (Men : Menu; |
| 586 | Items : Item_Array_Access) renames Redefine; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 587 | -- pragma Inline (Set_Items); |
| 588 | |
| 589 | -- ANCHOR(`menu_items()',`Items') |
| 590 | function Items (Men : Menu; |
| 591 | Index : Positive) return Item; |
| 592 | -- AKA |
| 593 | pragma Inline (Items); |
| 594 | |
| 595 | -- ANCHOR(`item_count()',`Item_Count') |
| 596 | function Item_Count (Men : Menu) return Natural; |
| 597 | -- AKA |
| 598 | pragma Inline (Item_Count); |
| 599 | |
| 600 | -- MANPAGE(`menu_new.3x') |
| 601 | |
| 602 | -- ANCHOR(`new_menu()',`Create') |
| 603 | function Create (Items : Item_Array_Access) return Menu; |
| 604 | -- AKA |
| 605 | -- Not inlined |
| 606 | |
| 607 | function New_Menu (Items : Item_Array_Access) return Menu renames Create; |
| 608 | |
| 609 | -- ANCHOR(`free_menu()',`Delete') |
| 610 | procedure Delete (Men : in out Menu); |
| 611 | -- AKA |
| 612 | -- Reset Men to Null_Menu |
| 613 | -- Not inlined |
| 614 | |
| 615 | -- MANPAGE(`menu_driver.3x') |
| 616 | |
| 617 | type Driver_Result is (Menu_Ok, |
| 618 | Request_Denied, |
| 619 | Unknown_Request, |
| 620 | No_Match); |
| 621 | |
| 622 | -- ANCHOR(`menu_driver()',`Driver') |
| 623 | function Driver (Men : Menu; |
| 624 | Key : Key_Code) return Driver_Result; |
| 625 | -- AKA |
| 626 | -- Driver is not inlined |
| 627 | |
| 628 | -- ANCHOR(`menu_requestname.3x') |
| 629 | -- Not Implemented: menu_request_name, menu_request_by_name |
| 630 | ------------------------------------------------------------------------------- |
| 631 | private |
| 632 | type Item is new System.Storage_Elements.Integer_Address; |
| 633 | type Menu is new System.Storage_Elements.Integer_Address; |
| 634 | |
| 635 | Null_Item : constant Item := 0; |
| 636 | Null_Menu : constant Menu := 0; |
| 637 | |
| 638 | end Terminal_Interface.Curses.Menus; |