1 | -- A translation of com32/cmenu/simple.c into Lua |
---|
2 | |
---|
3 | local m = require "cmenu" |
---|
4 | local sl = require "syslinux" |
---|
5 | |
---|
6 | m.init() |
---|
7 | m.set_window_size(1, 1, 23, 78) |
---|
8 | local testing = m.add_named_menu("testing", " Testing ") |
---|
9 | -- demonstrate identifying (named) submenu by number: |
---|
10 | m.add_item("Self Loop", "Go to testing", m.action.SUBMENU, nil, testing) |
---|
11 | m.add_item("Memory Test", "Perform extensive memory testing", m.action.RUN, "memtest") |
---|
12 | m.add_item("Exit this menu", "Go one level up", m.action.EXITMENU, "exit") |
---|
13 | |
---|
14 | local rescue = m.add_menu(" Rescue Options ") |
---|
15 | m.add_item("Linux Rescue", "linresc", m.action.RUN, "linresc") |
---|
16 | m.add_item("Dos Rescue", "dosresc", m.action.RUN, "dosresc") |
---|
17 | m.add_item("Windows Rescue", "winresc", m.action.RUN, "winresc") |
---|
18 | m.add_item("Exit this menu", "Go one level up", m.action.EXITMENU, "exit") |
---|
19 | |
---|
20 | m.add_named_menu("main", " Main Menu ") |
---|
21 | m.add_item("Prepare", "prep", m.action.RUN, "prep") |
---|
22 | m.add_item("Rescue options...", "Troubleshoot a system", m.action.SUBMENU, nil, rescue) |
---|
23 | -- demonstrate identifying submenu by name: |
---|
24 | m.add_item("Testing...", "Options to test hardware", m.action.SUBMENU, "testing") |
---|
25 | m.add_item("Exit to prompt", "Exit the menu system", m.action.EXITMENU, "exit") |
---|
26 | |
---|
27 | -- demonstrate finding menu explicitly: |
---|
28 | local action, data = m.showmenus(m.find_menu_num("main")) |
---|
29 | |
---|
30 | if action == m.action.RUN then |
---|
31 | sl.run_command (data) |
---|
32 | else |
---|
33 | print (action, data) |
---|
34 | end |
---|