The menu engine in newRPL retains the basic concepts of the one used in userRPL but provides new features such as help messages and dynamic menu appearance.
The most important command used to display a custom menu is TMENU
which displays the menu on the active menu area. It accepts either an integer or a list: the former is used to display a preset system menu but here we will discuss about the latter, which allows to display a fully customized menu.
The menu is structured as a list of items, where each item defines a softkey:
{ Item_1 ... Item_n }
If more than 6 items exist, the menu will be split in pages of 5 softkeys each, and the rightmost softkey of each page will turn into a NXT…
key to display a new page; as usual, pressing any shift and NXT…
will display the previous page.
Each item can be a single object or a three elements list: in the first case the offect depends on the type of the object:
Vars
menu;Units
menu;XEQ
'ted when the softkey is pressed. The label on the key is created decompiling the object for display. No help is displayed when long-pressed.In the second case, each element of the list takes care of an aspect of the softkey:
{ <Display> <Action> <Help> }
The <Display>
object can be either a single object or a two elements list; if it is a single object:
XEQ
'ted and its output is used as label;_
delimiter and displayed;
If <Display>
object is a two elements list:
{ <Display> <Decoration> }
the <Display>
part works exactly as above while the <Decoration>
part is an integer interpreted as a binary number:
The <Action>
object is optional and can be either a single object, a three or a five elements list; if it is a single object:
XEQ
'ted or its name will be inserted in the editor if the command line is active;Vars
menu;Units
menu;XEQ
'ted.and all these actions will happen whether the softkey is pressed unshifted, shifted or hold-shifted.
If the <Action>
object is a three elements list:
{ <Normal_Action> <Left-Shift_Action> <Right-Shift_Action> }
the user can define three separate actions for unshifted and shifted softkeys.
If the <Action>
object is a five elements list:
{ <Normal_Action> <Left-Shift_Action> <Right-Shift_Action> <Left-Shift-Hold_Action> <Right-Shift-Hold_Action> }
the user can define five separate actions for unshifted, shifted and hold-shifted softkeys.
The <Help>
object is an optional string that will be displayed in the help area when the softkey is long-pressed; a line break can be inserted using the RS-DOT key combination in Alpha mode.
newRPL has two menu areas available to the user which can be exploited to create a multilevel menu structure. Since newRPL allows the user to choose either MENU 1 or MENU 2 as active area, it is more convenient to refer to the two menus not in absolute terms but in chronological terms; in other words, three commands are available to display a custom menu:
TMENU
which displays the menu on the active menu area as controlled by flag -11;TMENULST
which displays the menu on the area that was used last, be it the active or the secondary area;TMENUOTHR
which displays the menu on the area that was not used last, be it the active or the secondary area.In this way an application can easily create a multilevel menu hierarchy and have both levels displayed on the screen at once. Of course, such a structure must be traversed also backwards, therefore three suitable commands are provided:
MENUBK
which displays the previous menu on the active menu area;MENUBKLST
which displays the previous menu on the area that was used last;MENUBKOTHR
which displays the previous menu on the area that was not used last.Finally, to retrieve on the stack the definitions of the custom menus the following commands are provided:
RCLMENU
to recall the active menu;RCLMENULST
to recall the menu that was used last;RCLMENUOTHR
to recall the menu that was not used last.The following programs build a 3-levels menu: the resulting program is just an empty shell, but demonstrates effectively the following techniques:
Program L1
– The top level menu
{ { { "File" 1 } :: L2 TMENULST ; "File operations" } { { "Edit" 0 } :: ; "Edit file" } { { "Search" 0 } :: ; "Search text" } { "" } { "" } { { "Quit" 0 } :: #00040000h TMENUOTHR #04402000h TMENU ; "Quit application" } }
File
menu recalls the second level menu, which will be displayed in the same area occupied by the top level menu;Edit
and Search
are dummy entries;<Action>
nor <Help>
object;Quit
restores MAIN and Vars
menus.—-
Program L2
– The second level menu
{ { { "New" 0 } :: ; "Create new file" } { { "Open" 0 } :: ; "Open existing file" } { { "Save" 1 } :: L3 TMENUOTHR ; "Save file" } { "" } { "" } { "Back" :: { } TMENUOTHR MENUBKLST ; "Back to Main menu" } }
Save
opens the third level menu in the other area, leaving the second level menu still on the screen;Back
cleans any third level menu that could have been displayed and restores the top level menu in the same area.
Program L3
– The third level menu
{ { "Save" :: ; "Save file" } { "As..." :: ; "Save with another name" } { "Copy" :: ; "Save a duplicate" } { "" } { "" } { "Back" :: { } TMENULST MENUBKOTHR ; "Back to Main menu" } }
Back
clears the third level menu and restores the previous menu in the other area which incidentally is the top level menu.
Program MAIN
– Putting everything together
« { } TMENULST { } TMENUOTHR L1 TMENU »