summaryrefslogtreecommitdiffstats
path: root/ui/ncurses
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-07-18 12:28:43 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-22 09:04:59 +0800
commit5d955dcc4f9a699bc84fe25ff337d51103f845ac (patch)
treee10f531f1915ae1c242809f260600e0e32dff13a /ui/ncurses
parenta685c78f33418c109313a6fc4ea25bb8b90a8111 (diff)
downloadtalos-petitboot-5d955dcc4f9a699bc84fe25ff337d51103f845ac.tar.gz
talos-petitboot-5d955dcc4f9a699bc84fe25ff337d51103f845ac.zip
ui/ncurses: allow tab/backtab to skip through a widget's fields
Since we may have a long list of devices on the configuration screen, we'd like a way to jump between widgets. This change repeats the PREV_FIELD/NEXT_FIELD driver request on these events. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/ncurses')
-rw-r--r--ui/ncurses/nc-widgets.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/ui/ncurses/nc-widgets.c b/ui/ncurses/nc-widgets.c
index bd78927..5592db9 100644
--- a/ui/ncurses/nc-widgets.c
+++ b/ui/ncurses/nc-widgets.c
@@ -689,19 +689,26 @@ static void widget_focus_change(struct nc_widget *widget, FIELD *field,
bool widgetset_process_key(struct nc_widgetset *set, int key)
{
struct nc_widget *widget;
- FIELD *field;
+ FIELD *field, *tmp;
int req = 0;
+ bool tab;
field = current_field(set->form);
assert(field);
+ tab = false;
+
/* handle field change events */
switch (key) {
case KEY_BTAB:
+ tab = true;
+ /* fall through */
case KEY_UP:
req = REQ_PREV_FIELD;
break;
case '\t':
+ tab = true;
+ /* fall through */
case KEY_DOWN:
req = REQ_NEXT_FIELD;
break;
@@ -717,8 +724,18 @@ bool widgetset_process_key(struct nc_widgetset *set, int key)
if (req) {
widget_focus_change(widget, field, false);
form_driver(set->form, req);
- form_driver(set->form, REQ_END_FIELD);
+
+ /* if we're doing a tabbed-field-change, skip until we
+ * see the next widget */
+ tmp = field;
field = current_field(set->form);
+
+ for (; tab && tmp != field && field_userptr(field) == widget;) {
+ form_driver(set->form, req);
+ field = current_field(set->form);
+ }
+
+ form_driver(set->form, REQ_END_FIELD);
widget = field_userptr(field);
widget_focus_change(widget, field, true);
if (widget->field_focus)
OpenPOWER on IntegriCloud