From patchwork Wed Jul 13 05:10:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 647699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rq6NH5Wvpz9srZ for ; Wed, 13 Jul 2016 15:10:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=IflnGtA1; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rq6NH3LnczDqHB for ; Wed, 13 Jul 2016 15:10:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=IflnGtA1; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rq6N8115LzDqFP for ; Wed, 13 Jul 2016 15:10:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=IflnGtA1; dkim-atps=neutral Received: from skellige.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 49622143F74; Wed, 13 Jul 2016 13:10:13 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1468386613; bh=9hE81GnOvnpvcZPWd2Uvhs/mQ1E3xlAWGeBaZsRicjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IflnGtA1r8mykCva/CKAinQe5KGHtgxOfo4mfwo1FqgXIXsStTfxUVyvcaDGzmp6s 3HxElUHCqMrGOHXQpsOsqqzDUdRlF6MJ8b0AVSSb9D88tbNDugwbGj0eKLAZP3bAJl BiMndWZXGg4DffimFGpK3Eo1vCrArbHRkJ5UF/bY= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH V2 2/2] ui/ncurses: Update keybindings for subsets Date: Wed, 13 Jul 2016 15:10:04 +1000 Message-Id: <20160713051004.31358-2-sam@mendozajonas.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160713051004.31358-1-sam@mendozajonas.com> References: <20160713051004.31358-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" 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 --- ui/ncurses/nc-config-help.c | 6 ++++-- ui/ncurses/nc-widgets.c | 23 ++++------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/ui/ncurses/nc-config-help.c b/ui/ncurses/nc-config-help.c index 23bcd9d..a0cbb20 100644 --- a/ui/ncurses/nc-config-help.c +++ b/ui/ncurses/nc-config-help.c @@ -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 \ -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. \ diff --git a/ui/ncurses/nc-widgets.c b/ui/ncurses/nc-widgets.c index c5c4cec..50909ab 100644 --- a/ui/ncurses/nc-widgets.c +++ b/ui/ncurses/nc-widgets.c @@ -162,21 +162,6 @@ static bool key_is_select(int key) 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))) @@ -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; - 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); @@ -538,10 +523,10 @@ static bool subset_process_key(struct nc_widget *w, FORM *form, int key) if (opt_idx < 0) return false; - if (key_is_minus(key)) + if (key == KEY_DC || key == KEY_BACKSPACE) subset_delete_active(subset, opt_idx); - if (key_is_left(key)){ + if (key == '-') { 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; } - if (key_is_right(key)){ + if (key == '+') { if (opt_idx >= subset->n_active - 1) return true;