summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-bind-key.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-01-27 08:53:13 +0000
committernicm <nicm@openbsd.org>2020-01-27 08:53:13 +0000
commitc88774048f0a7e9ace7afc00ed0f4ed84ad7cf1b (patch)
tree3160aa1947a1f3d3d327e485c1a78d16de585943 /usr.bin/tmux/cmd-bind-key.c
parentChange so that assignments may be specified alone - a command isn't (diff)
downloadwireguard-openbsd-c88774048f0a7e9ace7afc00ed0f4ed84ad7cf1b.tar.xz
wireguard-openbsd-c88774048f0a7e9ace7afc00ed0f4ed84ad7cf1b.zip
Add support for adding a note to a key binding (with bind-key -N) and
use this to add descriptions to the default key bindings. A new -N flag to list-keys shows key bindings with notes rather than the default bind-key command used to create them. Change the default ? binding to use this to show a readable summary of keys. Also extend command-prompt to return the name of the key pressed and add a default binding (/) to show the note for the next key pressed Suggested by Alex Tremblay in GitHub issue 2000.
Diffstat (limited to 'usr.bin/tmux/cmd-bind-key.c')
-rw-r--r--usr.bin/tmux/cmd-bind-key.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-bind-key.c b/usr.bin/tmux/cmd-bind-key.c
index e5c6ca2878b..136d260c5e4 100644
--- a/usr.bin/tmux/cmd-bind-key.c
+++ b/usr.bin/tmux/cmd-bind-key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-bind-key.c,v 1.34 2019/05/27 12:16:27 nicm Exp $ */
+/* $OpenBSD: cmd-bind-key.c,v 1.35 2020/01/27 08:53:13 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_bind_key_entry = {
.name = "bind-key",
.alias = "bind",
- .args = { "cnrT:", 2, -1 },
- .usage = "[-cnr] [-T key-table] key "
+ .args = { "cnrN:T:", 2, -1 },
+ .usage = "[-cnr] [-T key-table] [-N note] key "
"command [arguments]",
.flags = CMD_AFTERHOOK,
@@ -46,10 +46,10 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
key_code key;
- const char *tablename;
+ const char *tablename, *note;
struct cmd_parse_result *pr;
char **argv = args->argv;
- int argc = args->argc;
+ int argc = args->argc, repeat;
key = key_string_lookup_string(argv[0]);
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
@@ -63,6 +63,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
tablename = "root";
else
tablename = "prefix";
+ repeat = args_has(args, 'r');
if (argc == 2)
pr = cmd_parse_from_string(argv[1], NULL);
@@ -79,6 +80,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
case CMD_PARSE_SUCCESS:
break;
}
- key_bindings_add(tablename, key, args_has(args, 'r'), pr->cmdlist);
+ note = args_get(args, 'N');
+ key_bindings_add(tablename, key, note, repeat, pr->cmdlist);
return (CMD_RETURN_NORMAL);
}