summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-list-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-10-11 07:23:35 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-10-11 07:23:35 +0000
commit758ea0cffd351072e698144d32997c28c24d727a (patch)
tree8fac6d6cf66504f830563c5dfafe18891ef27ec0 /usr.bin/tmux/cmd-list-keys.c
parent32374aba9f526a266212ad87350c6c78bfbc7c33 (diff)
Fundamental change to how copy mode key bindings work:
The vi-copy and emacs-copy mode key tables are gone, and instead copy mode commands are bound in one of two normal key tables ("copy-mode" or "copy-mode-vi"). Keys are bound to "send-keys -X copy-mode-command". So: bind -temacs-copy C-Up scroll-up bind -temacs-copy -R5 WheelUpPane scroll-up Becomes: bind -Tcopy-mode C-Up send -X scroll-up bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up This allows the full command parser and command set to be used - for example, we can use the normal command prompt for searching, jumping, and so on instead of a custom one: bind -Tcopy-mode C-r command-prompt -p'search up' "send -X search-backward '%%'" command-prompt also gets a -1 option to only require on key press, which is needed for jumping. The plan is to get rid of mode keys entirely, so more to come eventually.
Diffstat (limited to 'usr.bin/tmux/cmd-list-keys.c')
-rw-r--r--usr.bin/tmux/cmd-list-keys.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c
index 2a033bc224d..da6c4eb6518 100644
--- a/usr.bin/tmux/cmd-list-keys.c
+++ b/usr.bin/tmux/cmd-list-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-keys.c,v 1.36 2016/09/12 15:40:58 nicm Exp $ */
+/* $OpenBSD: cmd-list-keys.c,v 1.37 2016/10/11 07:23:34 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -138,8 +138,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
const char *tablename, *key, *cmdstr, *mode;
const struct mode_key_table *mtab;
struct mode_key_binding *mbind;
- char repeat[16];
- int width, keywidth, repeatwidth, any_mode;
+ int width, keywidth, any_mode;
tablename = args_get(args, 't');
if ((mtab = mode_key_findtable(tablename)) == NULL) {
@@ -147,7 +146,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
- keywidth = repeatwidth = 0;
+ keywidth = 0;
any_mode = 0;
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
key = key_string_lookup_key(mbind->key);
@@ -158,13 +157,6 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
width = strlen(key);
if (width > keywidth)
keywidth = width;
-
- if (mbind->repeat != 1) {
- snprintf(repeat, sizeof repeat, "%u", mbind->repeat);
- width = strlen(repeat);
- if (width > repeatwidth)
- repeatwidth = width;
- }
}
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
@@ -173,20 +165,12 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
mode = "";
if (mbind->mode != 0)
mode = "c";
- snprintf(repeat, sizeof repeat, "%u", mbind->repeat);
cmdstr = mode_key_tostring(mtab->cmdstr, mbind->cmd);
if (cmdstr != NULL) {
- cmdq_print(cmdq,
- "bind-key -%st %s%s%s%*s %*s %s%s%s%s",
+ cmdq_print(cmdq, "bind-key -%st %s%s %*s %s",
mode, any_mode && *mode == '\0' ? " " : "",
mtab->name,
- mbind->repeat != 1 ? " -R " :
- (repeatwidth == 0 ? "" : " "),
- repeatwidth, mbind->repeat != 1 ? repeat : "",
- (int)keywidth, key, cmdstr,
- mbind->arg != NULL ? " \"" : "",
- mbind->arg != NULL ? mbind->arg : "",
- mbind->arg != NULL ? "\"": "");
+ (int)keywidth, key, cmdstr);
}
}