This is an old revision of the document!
Creating customized menus
The menu engine in newRPL retains the basic concepts of the one used in userRPL but provides new features such as help messages and dynamical 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 full customized menu.
The menu structure
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:
- an identifier or a directory will have all the properties of an entry in the
Vars
menu; - a unit with the numerical part equal to 1 will have all the properties of an entry in the
Units
menu; - a command will work as expected and will display an help message (if any) when long-pressed;
- a string will be displayed without quotes and returned on the stack whenthe softkey is pressed. No help is displayed when long-pressed;
- any other object will be
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
The <Display>
object can be either a single object or a two elements list; if it is a single object:
- a program leaving 1 object on the stack is
XEQ
'ted and its output is used as label; - a graphic object will be displayed as-is;
- a string will be displayed without quotes;
- a unit with the numerical part equal to 1 will be stripped of the numerical part and the
_
delimiter and displayed; - any other object will be decompiled for display and shown on the label.
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:
- if bit 0 is set, the label will be shown with its first character shaded, as directories or top-level menus;
- other bits are ignored.
The ACTION object
The <Action>
object can be either a single object, a three or a five elements list; if it is a single object:
- A command or operator will be
XEQ
'ted or its name will be inserted in the editor if the command line is active; - an identifier or a directory will have all the properties of an entry in the
Vars
menu; - a unit will have all the properties of an entry in the
Units
menu; - any other object will be
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
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.
Menus and sub-menus
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:
- the already mentioned
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.