]> git.ozlabs.org Git - petitboot/commitdiff
ui/ncurses: Update keybindings for subsets
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 12 Jul 2016 04:18:18 +0000 (14:18 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 13 Jul 2016 05:09:09 +0000 (15:09 +1000)
We now use KEY_LEFT and KEY_RIGHT for general navigation; update
subset_process_key() to use the following keybindings:

Reorder items up/down: Minus/Plus keys (-/+)
Delete item: Delete or Backspace

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
ui/ncurses/nc-config-help.c
ui/ncurses/nc-widgets.c

index 23bcd9d8bc8ed24cb53c9c9311513a56db23dd81..a0cbb200a1e8a6409774767e3162cbb2fd20bfec 100644 (file)
@@ -5,8 +5,10 @@ Autoboot: Specify which devices to autoboot from.\n"
 "\n"
 "By selecting the 'Add Device' button new devices can be added to the autoboot \
 list, either by UUID, MAC address, or device type. Once added to the boot \
 "\n"
 "By selecting the 'Add Device' button new devices can be added to the autoboot \
 list, either by UUID, MAC address, or device type. Once added to the boot \
-order, the priority of devices can be changed with the 'left' and 'right' keys \
-Devices can be individually removed from the boot order with the minus key. \
+order, the priority of devices can be changed with the '-' (minus) and \
+'+' (plus) keys. \
+Devices can be individually removed from the boot order with the 'delete' or \
+'backspace' keys. \
 Use this option if you have multiple operating system images installed.\n"
 "\n"
 "To autoboot from any device, select the 'Clear & Boot Any' button. \
 Use this option if you have multiple operating system images installed.\n"
 "\n"
 "To autoboot from any device, select the 'Clear & Boot Any' button. \
index c5c4cec6faad311473802b3700ef7207d2e7b58a..50909ab6c4af459261cb681995ff4bfe35f1ee35 100644 (file)
@@ -162,21 +162,6 @@ static bool key_is_select(int key)
        return key == ' ' || key == '\r' || key == '\n' || key == KEY_ENTER;
 }
 
        return key == ' ' || key == '\r' || key == '\n' || key == KEY_ENTER;
 }
 
-static bool key_is_minus(int key)
-{
-       return key == 055;
-}
-
-static bool key_is_left(int key)
-{
-       return key == KEY_LEFT;
-}
-
-static bool key_is_right(int key)
-{
-       return key == KEY_RIGHT;
-}
-
 static bool process_key_nop(struct nc_widget *widget __attribute__((unused)),
                FORM *form __attribute((unused)),
                int key __attribute__((unused)))
 static bool process_key_nop(struct nc_widget *widget __attribute__((unused)),
                FORM *form __attribute((unused)),
                int key __attribute__((unused)))
@@ -522,7 +507,7 @@ static bool subset_process_key(struct nc_widget *w, FORM *form, int key)
        int i, val, opt_idx = -1;
        FIELD *field;
 
        int i, val, opt_idx = -1;
        FIELD *field;
 
-       if (!key_is_minus(key) && !key_is_left(key) && !key_is_right(key))
+       if (key != '-' && key != '+' && key != KEY_DC && key != KEY_BACKSPACE)
                return false;
 
        field = current_field(form);
                return false;
 
        field = current_field(form);
@@ -538,10 +523,10 @@ static bool subset_process_key(struct nc_widget *w, FORM *form, int key)
        if (opt_idx < 0)
                return false;
 
        if (opt_idx < 0)
                return false;
 
-       if (key_is_minus(key))
+       if (key == KEY_DC || key == KEY_BACKSPACE)
                subset_delete_active(subset, opt_idx);
 
                subset_delete_active(subset, opt_idx);
 
-       if (key_is_left(key)){
+       if (key == '-') {
                if (opt_idx == 0)
                        return true;
 
                if (opt_idx == 0)
                        return true;
 
@@ -550,7 +535,7 @@ static bool subset_process_key(struct nc_widget *w, FORM *form, int key)
                subset->active[opt_idx - 1] = val;
        }
 
                subset->active[opt_idx - 1] = val;
        }
 
-       if (key_is_right(key)){
+       if (key == '+') {
                if (opt_idx >= subset->n_active - 1)
                        return true;
 
                if (opt_idx >= subset->n_active - 1)
                        return true;