-
Notifications
You must be signed in to change notification settings - Fork 50
Examples of menus
pgen edited this page Sep 6, 2018
·
3 revisions
-
Examples 1
Here is how to create a trivial embedded menu to illustrate the concept
$ cat menu1
" 1 Item 1" " 2 Item 2" " 3 Item 3" " 4 Item 4" - " 0 Exit"
$ cat menu1.sh
#!/bin/sh ENTRY=999 while [ $ENTRY -ne 0 ]; do LINE=$(smenu -d -n 0 -l -F -s /"QUIT$" -D o:0 n:2 i:1 d:" " \ -E'/^-$/ /' -e '^-$' < menu1) read ENTRY DUMMY <<< $LINE case $ENTRY in [1-4]) echo "The menu entry $ENTRY has been selected" ;; 0) ;; esac done exit 0
The result:
-
Examples 2
The same, but horizontal this time. The only difference with the previous example is the smenu call with different options.
$ cat menu2.sh
#!/bin/sh . . . . . . . . . . . . . . . . . . . . . . . . . . . LINE=$(smenu -d -n 0 -l -F -D o:0 n:2 i:1 d:" " \ -1 Exit -e '^-$' -E'/^-$/ /' -e '^-$' \ < menu2) . . . . . . . . . . . . . . . . . . . . . . . . . . . exit 0
The result:
-
Example 3
Now a matrix version.
$ cat menu3
" 1 Item 1" " 2 Item 2" " 3 Item 3" " 4 Item 4" - " 0 Exit"
$ cat menu3.sh
#!/bin/sh . . . . . . . . . . . . . . . . . . . . . . . . . . . LINE=$(smenu -d -n 0 -c -F -D o:0 n:2 i:1 d:" " \ -1 Exit -e '^-$' -E'/^-$/ /' -e '^-$' \ < menu3) . . . . . . . . . . . . . . . . . . . . . . . . . . . exit 0
The result:
To restart the animations, refresh the page (shift refresh on Netscape based browsers).
smenu illustrated concepts and examples: