summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/menu.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2022-08-04 12:06:10 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2022-08-04 12:06:10 +0000
commit664ad131fb32be9773c332aaa87b5bc0521c4086 (patch)
tree49d3e0a5e86fb80d7b3d6189369d8a7fcb66d758 /usr.bin/tmux/menu.c
parent0e01bd6659a1b8cef1966b9b4ca20a79f0587bf5 (diff)
Change g and G to go to top and bottom of menu, GitHub issue 3286.
Diffstat (limited to 'usr.bin/tmux/menu.c')
-rw-r--r--usr.bin/tmux/menu.c65
1 files changed, 51 insertions, 14 deletions
diff --git a/usr.bin/tmux/menu.c b/usr.bin/tmux/menu.c
index 2b379a2553b..6db916f29e9 100644
--- a/usr.bin/tmux/menu.c
+++ b/usr.bin/tmux/menu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: menu.c,v 1.46 2022/06/16 13:27:39 nicm Exp $ */
+/* $OpenBSD: menu.c,v 1.47 2022/08/04 12:06:09 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -323,27 +323,64 @@ menu_key_cb(struct client *c, void *data, struct key_event *event)
} while ((name == NULL || *name == '-') && md->choice != old);
c->flags |= CLIENT_REDRAWOVERLAY;
return (0);
- case 'g':
case KEYC_PPAGE:
case '\002': /* C-b */
- if (md->choice > 5)
- md->choice -= 5;
- else
+ if (md->choice < 6)
md->choice = 0;
- while (md->choice != count && (name == NULL || *name == '-'))
- md->choice++;
- if (md->choice == count)
- md->choice = -1;
+ else {
+ i = 5;
+ while (i > 0) {
+ md->choice--;
+ name = menu->items[md->choice].name;
+ if (md->choice != 0 &&
+ (name != NULL && *name != '-'))
+ i--;
+ else if (md->choice == 0)
+ break;
+ }
+ }
c->flags |= CLIENT_REDRAWOVERLAY;
break;
- case 'G':
case KEYC_NPAGE:
- if (md->choice > count - 6)
+ if (md->choice > count - 6) {
md->choice = count - 1;
- else
- md->choice += 5;
- while (md->choice != -1 && (name == NULL || *name == '-'))
+ name = menu->items[md->choice].name;
+ } else {
+ i = 5;
+ while (i > 0) {
+ md->choice++;
+ name = menu->items[md->choice].name;
+ if (md->choice != count - 1 &&
+ (name != NULL && *name != '-'))
+ i++;
+ else if (md->choice == count - 1)
+ break;
+ }
+ }
+ while (name == NULL || *name == '-') {
md->choice--;
+ name = menu->items[md->choice].name;
+ }
+ c->flags |= CLIENT_REDRAWOVERLAY;
+ break;
+ case 'g':
+ case KEYC_HOME:
+ md->choice = 0;
+ name = menu->items[md->choice].name;
+ while (name == NULL || *name == '-') {
+ md->choice++;
+ name = menu->items[md->choice].name;
+ }
+ c->flags |= CLIENT_REDRAWOVERLAY;
+ break;
+ case 'G':
+ case KEYC_END:
+ md->choice = count - 1;
+ name = menu->items[md->choice].name;
+ while (name == NULL || *name == '-') {
+ md->choice--;
+ name = menu->items[md->choice].name;
+ }
c->flags |= CLIENT_REDRAWOVERLAY;
break;
case '\006': /* C-f */