summaryrefslogtreecommitdiffstats
path: root/cmd-bind-key.c
diff options
context:
space:
mode:
authornicm <nicm>2016-10-11 07:23:34 +0000
committernicm <nicm>2016-10-11 07:23:34 +0000
commit76d6d3641f271be1756e41494960d96714e7ee58 (patch)
treeff2b551953111d90ed5f32919fe2f3b329357bc1 /cmd-bind-key.c
parent8b804fb5894b6717de36c5c9c96f7fd29b14a864 (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 'cmd-bind-key.c')
-rw-r--r--cmd-bind-key.c51
1 files changed, 6 insertions, 45 deletions
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);
}