From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from m50-138.163.com ([123.125.50.138]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aquaU-000507-GU for barebox@lists.infradead.org; Fri, 15 Apr 2016 03:38:31 +0000 From: DU HUANPENG Date: Fri, 15 Apr 2016 11:37:59 +0800 Message-Id: <1460691479-18617-1-git-send-email-do_not_rep1y@163.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] menu: add vi like key support To: barebox@lists.infradead.org Cc: Du Huanpeng From: Du Huanpeng add vi like key support: j: down k: up : select Signed-off-by: Du Huanpeng --- common/menu.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/common/menu.c b/common/menu.c index 54f2c71..51b4cfc 100644 --- a/common/menu.c +++ b/common/menu.c @@ -327,6 +327,7 @@ int menu_show(struct menu *m) } break; } + case 'k': case BB_KEY_UP: m->selected = list_entry(m->selected->list.prev, struct menu_entry, list); @@ -336,6 +337,7 @@ int menu_show(struct menu *m) } repaint = 1; break; + case 'j': case BB_KEY_DOWN: m->selected = list_entry(m->selected->list.next, struct menu_entry, list); @@ -346,13 +348,13 @@ int menu_show(struct menu *m) repaint = 1; break; case ' ': - if (m->selected->type != MENU_ENTRY_BOX) - break; - m->selected->box_state = !m->selected->box_state; - if (m->selected->action) - m->selected->action(m, m->selected); - repaint = 1; - break; + if (m->selected->type == MENU_ENTRY_BOX) { + m->selected->box_state = !m->selected->box_state; + if (m->selected->action) + m->selected->action(m, m->selected); + repaint = 1; + } + /* no break */ case BB_KEY_ENTER: if (ch_previous == BB_KEY_RETURN) break; -- 1.9.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox