Asmmenu - display menu for shell script


usage: from within script (menu definition at end of script)
execute: asmmenu $0 <-- this gives AsmMenu the
script file location.

introduction:
AsmMenu is a very easy to use menu system for shell
scripts. The caller only needs to identify the button
size and then make a text map of the buttons in the
pattern they are to be displayed. Reviewing the
example below should explain the setup needed.

operation:
----------
Asmmenu extracts a menu definition from the executing
shell script. Only one menu definition can be placed
in the shell script and it must be at the end and built
as described below. AsmMenu reads the shell script and
displays the menu it finds. When a button is pushed the
code for that button is returned to the calling shell
script and AsmMenu exits.

This design works because shell scripts can be told to
exit and ignore any data that follows. We can then
use the end of the script file to define our menu.

inputs
------
AsmMenu finds the calling shell script and
scans to the end looking for a menu definition.
Each menu definition begins with: buttonsize: x,y
Next, it expects to find box titles identified
as: header: "text goes here"
Multiple headers are possible. The rest of a menu
definition is a visual button layout separated by
tabs.

Example of a menu definition:

#set button size to 2 rows long and 15 columns wide
buttonsize: 2,15
header: "this is a sample header"

<tab> hello I am <tab> i'm a
<tab> button 1 <tab> button

<tab> row2 <tab> yet another
<tab> button <tab> button

summary of menu options:
buttonsize: x,y <-- size for all buttons
header: " " <-- header. max number headers = 8
each header starts with: header:
color1: <-- alternate color set #1
Can be before or after header: defs
clear: <-- clear display after selection
Place after buttonsize: and before
first tab

output
------

When selected, the buttons return a code
indicating its position. All first
row buttons start with -1-. Second tier
buttons start with -2-, etc. Next, the
button column is included within the code.
Thus, 12 indicates row 1 column 2. Thus,
the above example returns codes showing
button position as follows:

11 12

21 22

If AsmMenu encounters an error it will
return -1. It will also display a message.

limitations
-----------

The maximum number of text rows in a single button
is 4. The maximum number of columns in a single
button is 200 or the screen size. The maximum
number of buttons is 49. The maximum number or
buttons on a line is 9. The maximum number of
button rows is 9.

AsmMenu only runs on the Linux console or in
a terminal and only on X86 processors. It can
be used within X-windows by utilizing a terminal
program such as xterm,rxvt, or konsole.
For most terminals the following will work:

xterm -e script

example shell script
--------------------

#Shell script to call asmmenu and capture
#the return code

asmmenu $0
if [ $? = 11 ]; then
echo "button row 1 column 1"
else
echo "some other button"
fi
exit
#------------------------------------
#single button menu
buttonsize: 1,4
header: "the menu"
<tab> test

DEPENDENCIES

Optional compile dependency: AsmLib





Fork me on GitHub