diff options
author | Ferenc Wágner <wferi@niif.hu> | 2014-03-02 09:11:46 +0100 |
---|---|---|
committer | Ferenc Wágner <wferi@niif.hu> | 2014-03-02 09:16:32 +0100 |
commit | e8b8413c806db83350c3f2d51c3b55bebdd3074e (patch) | |
tree | 389113bdb0cb7d2c3932f52e95723972e1a6550d | |
parent | 7e6aa0662469fbc910c10afd4b3b0567e4e8eaad (diff) | |
download | syslinux-e8b8413c806db83350c3f2d51c3b55bebdd3074e.tar.gz syslinux-e8b8413c806db83350c3f2d51c3b55bebdd3074e.tar.xz syslinux-e8b8413c806db83350c3f2d51c3b55bebdd3074e.zip |
lua: add demo of the cmenu binding (the simple example)
-rw-r--r-- | com32/lua/test/simplemenu.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/com32/lua/test/simplemenu.lua b/com32/lua/test/simplemenu.lua new file mode 100644 index 00000000..ea86d11c --- /dev/null +++ b/com32/lua/test/simplemenu.lua @@ -0,0 +1,34 @@ +-- A translation of com32/cmenu/simple.c into Lua + +local m = require "cmenu" +local sl = require "syslinux" + +m.init() +m.set_window_size(1, 1, 23, 78) +local testing = m.add_named_menu("testing", " Testing ") +-- demonstrate identifying (named) submenu by number: +m.add_item("Self Loop", "Go to testing", m.action.SUBMENU, nil, testing) +m.add_item("Memory Test", "Perform extensive memory testing", m.action.RUN, "memtest") +m.add_item("Exit this menu", "Go one level up", m.action.EXITMENU, "exit") + +local rescue = m.add_menu(" Rescue Options ") +m.add_item("Linux Rescue", "linresc", m.action.RUN, "linresc") +m.add_item("Dos Rescue", "dosresc", m.action.RUN, "dosresc") +m.add_item("Windows Rescue", "winresc", m.action.RUN, "winresc") +m.add_item("Exit this menu", "Go one level up", m.action.EXITMENU, "exit") + +m.add_named_menu("main", " Main Menu ") +m.add_item("Prepare", "prep", m.action.RUN, "prep") +m.add_item("Rescue options...", "Troubleshoot a system", m.action.SUBMENU, nil, rescue) +-- demonstrate identifying submenu by name: +m.add_item("Testing...", "Options to test hardware", m.action.SUBMENU, "testing") +m.add_item("Exit to prompt", "Exit the menu system", m.action.EXITMENU, "exit") + +-- demonstrate finding menu explicitly: +local action, data = m.showmenus(m.find_menu_num("main")) + +if action == m.action.RUN then + sl.run_command (data) +else + print (action, data) +end |