diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-16 15:06:04 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-16 15:06:04 +0000 |
commit | aec0e0b0f049b106bfbc47265d210feabe384985 (patch) | |
tree | 0eed7e321078e041a967ecf9257da6b629e948f3 /usr.bin/tmux/menu.c | |
parent | e0d5e2766c2dde6fe92876de0e45419382fe76c3 (diff) |
Improve command prompt completion:
- Show a menu with completions if there are multiple.
- Don't complete argument stuff (options, layouts) at start of text.
- For -t and -s, if there is no : then complete sessions but if there is
a :, show a menu of all windows in the session rather than trying to
complete the window name which is a bit useless if there are
duplicates.
Diffstat (limited to 'usr.bin/tmux/menu.c')
-rw-r--r-- | usr.bin/tmux/menu.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.bin/tmux/menu.c b/usr.bin/tmux/menu.c index 01f61d23172..5acd4ad6441 100644 --- a/usr.bin/tmux/menu.c +++ b/usr.bin/tmux/menu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: menu.c,v 1.25 2020/05/16 15:01:31 nicm Exp $ */ +/* $OpenBSD: menu.c,v 1.26 2020/05/16 15:06:03 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -240,6 +240,16 @@ menu_key_cb(struct client *c, struct key_event *event) } while ((name == NULL || *name == '-') && md->choice != old); c->flags |= CLIENT_REDRAWOVERLAY; return (0); + case KEYC_BSPACE: + if (~md->flags & MENU_TAB) + break; + return (1); + case '\011': /* Tab */ + if (~md->flags & MENU_TAB) + break; + if (md->choice == count - 1) + return (1); + /* FALLTHROUGH */ case KEYC_DOWN: case 'j': if (old == -1) @@ -253,6 +263,31 @@ menu_key_cb(struct client *c, 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 + md->choice = 0; + while (md->choice != count && (name == NULL || *name == '-')) + md->choice++; + if (md->choice == count) + md->choice = -1; + c->flags |= CLIENT_REDRAWOVERLAY; + break; + case 'G': + case KEYC_NPAGE: + if (md->choice > count - 6) + md->choice = count - 1; + else + md->choice += 5; + while (md->choice != -1 && (name == NULL || *name == '-')) + md->choice--; + c->flags |= CLIENT_REDRAWOVERLAY; + break; + case '\006': /* C-f */ + break; case '\r': goto chosen; case '\033': /* Escape */ |