mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/1] menu: add number key support
Date: Sun,  5 Aug 2012 07:06:00 +0200	[thread overview]
Message-ID: <1344143160-14103-1-git-send-email-plagnioj@jcrosoft.com> (raw)

Allow to use the number key to jump to entry.
if already on a entry % number_key jump to the next +10 one if exit

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/menu.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/common/menu.c b/common/menu.c
index 9f536d6..97c6b18 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -314,6 +314,23 @@ int menu_show(struct menu *m)
 		m->auto_select = -1;
 
 		switch (ch) {
+		case '0' ... '9': {
+			struct menu_entry *me;
+			int num = ch - '0';
+			int next_num = m->selected->num + 10;
+			if (!num)
+				num = 10;
+
+			if (ch_previous == ch && next_num <= m->nb_entries)
+				num = next_num;
+
+			me = menu_entry_get_by_num(m, num);
+			if (me) {
+				m->selected = me;
+				repaint = 1;
+			}
+			break;
+		}
 		case KEY_UP:
 			m->selected = list_entry(m->selected->list.prev, struct menu_entry,
 						 list);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2012-08-05  5:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-05  5:06 Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-08-09  6:40 ` Sascha Hauer

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=1344143160-14103-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /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