]> git.ozlabs.org Git - petitboot/commit
ui/ncurses: Allow multiple hot key handlers per pmenu
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Mon, 18 Dec 2017 05:39:50 +0000 (16:39 +1100)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 10 Jan 2018 02:34:54 +0000 (13:34 +1100)
commit2dfbd9811d1e14911a6476850aada94b88a0dbdd
tree721429d3d18b8b2fdbf568b63fd99c774f27c421
parenta2d5a3e3cb55fe3583acaae44fabc7c3d7f8df50
ui/ncurses: Allow multiple hot key handlers per pmenu

The main menu and plugin menu are separate screens but they share the
pmenu_process_key() handler. This means all the key shortcuts intended
for the main menu can also be used in the plugin menu, which is
particularly odd for "add new boot option" for example.

To work around this extend the 'hot_key' functionality in pmenu to allow
multiple handlers. This allows all pmenus to have the usual navigation
and action keys, and then add extra handlers as needed. For example,
ps3_mm_init() needs main menu shortcuts as well as some PS3-specific
shortcuts, whereas plugin_menu_init() only needs the generic key
handler.

This changes the functionality of pmenu_process_key() such that if a
hot_key_fn successfully handles a key, pmenu_process_key() returns
instead of continuing to process the key. This does not affect the
current usage.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
ui/ncurses/nc-cui.c
ui/ncurses/nc-menu.c
ui/ncurses/nc-menu.h
ui/ncurses/ps3-main.c