MENU -- Menu Boxes 1) Usage | OBJECT mnu[MENU]; A MENU instance has no state, but all information required for creating menu is passed to it using arguments. There is only one singe method called SELECT. When a SELECT message is sent to an instance of MENU, the menu described in the argument list will be displayed on the screen. The terminal will be put into raw mode while the menu is displayed. The user can then select an item from the menu or close the menu without chosing an item. When closed, the menu will not be removed from the screen. The MENU class uses color set and frame set structures described in the 'common data structures' section. 2) Methods 2.1 SELECT | MNU.SELECT(x, y, default, cs, fs, items) | ! Num,Num,Num,Bvec,Bvec,Vec => Num MNU.SELECT() draws the menu described in the ITEMS argument at the position specified in the X and Y arguments on the terminal screen. The DEFAULT argument specifies the position of the menu item which will be selected when the menu is created. The assertion | 0 <= DEFAULT < number of items must hold. CS is a CSET structure holding the color set and FS is a FSET structure holding the frame drawing character set. They are described in the section 'common data structures'. Colors are used as follows: C_BACKGROUND menu background C_FRAME menu frame C_TEXT menu text C_SELECT selection bar The menu description passed to SELECT in the ITEMS argument is a table containing two-element structures of the form [ hotkey, "item text" ] where HOTKEY is a character and the item text is a string. The last item must be zero. For example, the following menu description would create a simple Yes/No choice: | [ | [ 'y', " Yes " ], | [ 'n', " No" ], | 0 | ] When using the frame set "++++-|", the menu would look like this: | +-------+ | | _Yes_ | | | _No__ | | +-------+ The following keys may be used in menues (^X denotes [control]+[X], K_X denotes ttyctl.K_X): Key Alt. Description --- ---- ----------- K_DOWN ^N move to next item K_UP ^P move to previous item K_RIGHT ENTER select item under menu bar K_LEFT ESC cancel selection When a hotkey (as defined in the ITEMS vector) is pressed, this is equal to moving the menu bar over the respective item and pressing ENTER. When an item has been selected, its position in the item list will be returned. When canceling a selection, -1 will be returned. 2.2 SCRSELECT | MNU.SCRSELECT(x, y, default, size, cs, fs, items) | ! Num,Num,Num,Num,Bvec,Bvec,Vec => Num MNU.SCRSELECT is equal to MNU.SELECT except for the additional SIZE parameter. This parameter may be set to a maximum vertical size of the menu. Only up to SIZE items will be displayed. When more items are specified, the content of the menu will be scrolled if necessary. When SIZE=0, SCRSELECT is equal to SELECT. 3) Common Data Structures 3.1 CSET -- Color Sets The color set structure CSET, which is implemented in the FILEBOX, FORM, MENU, and PROMPT classes, has the following members: Member Used for... C_BACKGROUND box backgrounds C_FRAME drawing box frames C_TEXT writing text C_SOTEXT writing higlighted text C_SELECT drawing the selection bar For the exact usage of this structure, see the description of the classes which use it. The CSET structure has the same layout in all classes. Therefore, one and the same color set may be used in file boxes, forms, menues, and prompt boxes. 3.2 FSET -- Frame Character Sets The frame character set structure FSET, which is implemented in the FILEBOX, FORM, and MENU classes, has the following members: F_UL upper left corner F_UR upper right corner F_LL lower left corner F_LR lower right corner F_HL horizontal lines F_VL vertical lines NOTICE: FSET is a packed structure. To define one, use var fs::FSET; and to access its members, use fs::F_UL, fs::F_UR, etc. EXAMPLE: Using the FSET structure PACKED"1234-|" would result in a box of the form | 1----------2 | | | | | | | 3----------4 The FSET structure has the same layout in all classes. Therefore, one and the same frame character set may be used in file boxes, forms, and menues.