From 76d6d3641f271be1756e41494960d96714e7ee58 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 11 Oct 2016 07:23:34 +0000 Subject: 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. --- cmd-bind-key.c | 51 ++++++--------------------------------------------- 1 file changed, 6 insertions(+), 45 deletions(-) (limited to 'cmd-bind-key.c') diff --git a/cmd-bind-key.c b/cmd-bind-key.c index bcc179c3..69314788 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -36,8 +36,8 @@ const struct cmd_entry cmd_bind_key_entry = { .name = "bind-key", .alias = "bind", - .args = { "cnrR:t:T:", 1, -1 }, - .usage = "[-cnr] [-t mode-table] [-R repeat-count] [-T key-table] key " + .args = { "cnrt:T:", 1, -1 }, + .usage = "[-cnr] [-t mode-table] [-T key-table] key " "command [arguments]", .flags = 0, @@ -97,12 +97,10 @@ static enum cmd_retval cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) { struct args *args = self->args; - const char *tablename, *arg; + const char *tablename; const struct mode_key_table *mtab; struct mode_key_binding *mbind, mtmp; enum mode_key_cmd cmd; - char *cause; - u_int repeat; tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { @@ -116,44 +114,9 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) return (CMD_RETURN_ERROR); } - switch (cmd) { - case MODEKEYCOPY_APPENDSELECTION: - case MODEKEYCOPY_COPYSELECTION: - case MODEKEYCOPY_STARTNAMEDBUFFER: - if (args->argc == 2) - arg = NULL; - else { - arg = args->argv[2]; - if (strcmp(arg, "-x") != 0) { - cmdq_error(cmdq, "unknown argument"); - return (CMD_RETURN_ERROR); - } - } - break; - case MODEKEYCOPY_COPYPIPE: - if (args->argc != 3) { - cmdq_error(cmdq, "no argument given"); - return (CMD_RETURN_ERROR); - } - arg = args->argv[2]; - break; - default: - if (args->argc != 2) { - cmdq_error(cmdq, "no argument allowed"); - return (CMD_RETURN_ERROR); - } - arg = NULL; - break; - } - - repeat = 1; - if (args_has(args, 'R')) { - repeat = args_strtonum(args, 'R', 1, SHRT_MAX, &cause); - if (cause != NULL) { - cmdq_error(cmdq, "repeat count %s", cause); - free(cause); - return (CMD_RETURN_ERROR); - } + if (args->argc != 2) { + cmdq_error(cmdq, "no argument allowed"); + return (CMD_RETURN_ERROR); } mtmp.key = key; @@ -164,8 +127,6 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) mbind->mode = mtmp.mode; RB_INSERT(mode_key_tree, mtab->tree, mbind); } - mbind->repeat = repeat; mbind->cmd = cmd; - mbind->arg = arg != NULL ? xstrdup(arg) : NULL; return (CMD_RETURN_NORMAL); } -- cgit v1.2.3