mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: DU HUANPENG <do_not_rep1y@163.com>
To: barebox@lists.infradead.org
Cc: Du Huanpeng <u74147@gmail.com>
Subject: [PATCH] menu: add vi like key support
Date: Fri, 15 Apr 2016 12:02:24 +0800	[thread overview]
Message-ID: <1460692944-18946-1-git-send-email-do_not_rep1y@163.com> (raw)

From: Du Huanpeng <u74147@gmail.com>

add vi like key support:
        j: down
        k: up
  <Space>: select

Signed-off-by: Du Huanpeng <u74147@gmail.com>
---
 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

             reply	other threads:[~2016-04-15  4:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15  4:02 DU HUANPENG [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-04-19  4:02 DU HUANPENG
2016-04-19  6:13 ` Sascha Hauer
2016-04-15  4:06 DU HUANPENG
2016-04-15  4:01 DU HUANPENG
2016-04-15  3:37 DU HUANPENG

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460692944-18946-1-git-send-email-do_not_rep1y@163.com \
    --to=do_not_rep1y@163.com \
    --cc=barebox@lists.infradead.org \
    --cc=u74147@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox