diff options
-rw-r--r-- | usr.bin/tmux/cmd-bind-key.c | 24 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-list-keys.c | 33 | ||||
-rw-r--r-- | usr.bin/tmux/mode-key.c | 629 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 13 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 5 | ||||
-rw-r--r-- | usr.bin/tmux/window-choose.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 16 |
8 files changed, 387 insertions, 347 deletions
diff --git a/usr.bin/tmux/cmd-bind-key.c b/usr.bin/tmux/cmd-bind-key.c index cfb54491011..0170abbe5fe 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.25 2016/01/19 15:59:12 nicm Exp $ */ +/* $OpenBSD: cmd-bind-key.c,v 1.26 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -36,9 +36,9 @@ const struct cmd_entry cmd_bind_key_entry = { .name = "bind-key", .alias = "bind", - .args = { "cnrt:T:", 1, -1 }, - .usage = "[-cnr] [-t mode-table] [-T key-table] key command " - "[arguments]", + .args = { "cnrR:t:T:", 1, -1 }, + .usage = "[-cnr] [-t mode-table] [-R repeat-count] [-T key-table] key " + "command [arguments]", .flags = 0, .exec = cmd_bind_key_exec @@ -97,11 +97,12 @@ 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; + const char *tablename, *arg; const struct mode_key_table *mtab; struct mode_key_binding *mbind, mtmp; enum mode_key_cmd cmd; - const char *arg; + char *cause; + u_int repeat; tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { @@ -145,6 +146,16 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key) 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); + } + } + mtmp.key = key; mtmp.mode = !!args_has(args, 'c'); if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) == NULL) { @@ -153,6 +164,7 @@ 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); diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c index b79b78c62dc..2a033bc224d 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.35 2016/06/15 08:54:11 nicm Exp $ */ +/* $OpenBSD: cmd-list-keys.c,v 1.36 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -135,11 +135,11 @@ static enum cmd_retval cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; - const char *tablename; + const char *tablename, *key, *cmdstr, *mode; const struct mode_key_table *mtab; struct mode_key_binding *mbind; - const char *key, *cmdstr, *mode; - int width, keywidth, any_mode; + char repeat[16]; + int width, keywidth, repeatwidth, any_mode; tablename = args_get(args, 't'); if ((mtab = mode_key_findtable(tablename)) == NULL) { @@ -147,7 +147,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_ERROR); } - width = 0; + keywidth = repeatwidth = 0; any_mode = 0; RB_FOREACH(mbind, mode_key_tree, mtab->tree) { key = key_string_lookup_key(mbind->key); @@ -155,9 +155,16 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq) if (mbind->mode != 0) any_mode = 1; - keywidth = strlen(key); - if (keywidth > width) - width = keywidth; + 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) { @@ -166,11 +173,17 @@ 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", + cmdq_print(cmdq, + "bind-key -%st %s%s%s%*s %*s %s%s%s%s", mode, any_mode && *mode == '\0' ? " " : "", - mtab->name, (int) width, key, cmdstr, + 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 ? "\"": ""); diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c index a51c282d688..43fd16351f8 100644 --- a/usr.bin/tmux/mode-key.c +++ b/usr.bin/tmux/mode-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-key.c,v 1.68 2016/04/27 09:39:09 nicm Exp $ */ +/* $OpenBSD: mode-key.c,v 1.69 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -50,6 +50,7 @@ struct mode_key_entry { */ int mode; enum mode_key_cmd cmd; + u_int repeat; }; /* Edit keys command strings. */ @@ -170,341 +171,341 @@ const struct mode_key_cmdstr mode_key_cmdstr_copy[] = { /* vi editing keys. */ const struct mode_key_entry mode_key_vi_edit[] = { - { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL }, - { '\010' /* C-h */, 0, MODEKEYEDIT_BACKSPACE }, - { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE }, - { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, - { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD }, - { '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE }, - { '\n', 0, MODEKEYEDIT_ENTER }, - { '\r', 0, MODEKEYEDIT_ENTER }, - { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE }, - { KEYC_DC, 0, MODEKEYEDIT_DELETE }, - { KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN }, - { KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT }, - { KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT }, - { KEYC_UP, 0, MODEKEYEDIT_HISTORYUP }, - { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE }, - { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE }, - - { '$', 1, MODEKEYEDIT_ENDOFLINE }, - { '0', 1, MODEKEYEDIT_STARTOFLINE }, - { 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE }, - { 'B', 1, MODEKEYEDIT_PREVIOUSSPACE }, - { 'C', 1, MODEKEYEDIT_SWITCHMODECHANGELINE }, - { 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE }, - { 'E', 1, MODEKEYEDIT_NEXTSPACEEND }, - { 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE }, - { 'S', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTELINE }, - { 'W', 1, MODEKEYEDIT_NEXTSPACE }, - { 'X', 1, MODEKEYEDIT_BACKSPACE }, - { '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL }, - { '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE }, - { '\n', 1, MODEKEYEDIT_ENTER }, - { '\r', 1, MODEKEYEDIT_ENTER }, - { '^', 1, MODEKEYEDIT_STARTOFLINE }, - { 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND }, - { 'b', 1, MODEKEYEDIT_PREVIOUSWORD }, - { 'd', 1, MODEKEYEDIT_DELETELINE }, - { 'e', 1, MODEKEYEDIT_NEXTWORDEND }, - { 'h', 1, MODEKEYEDIT_CURSORLEFT }, - { 'i', 1, MODEKEYEDIT_SWITCHMODE }, - { 'j', 1, MODEKEYEDIT_HISTORYDOWN }, - { 'k', 1, MODEKEYEDIT_HISTORYUP }, - { 'l', 1, MODEKEYEDIT_CURSORRIGHT }, - { 'p', 1, MODEKEYEDIT_PASTE }, - { 's', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTE }, - { 'w', 1, MODEKEYEDIT_NEXTWORD }, - { 'x', 1, MODEKEYEDIT_DELETE }, - { KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE }, - { KEYC_DC, 1, MODEKEYEDIT_DELETE }, - { KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN }, - { KEYC_LEFT, 1, MODEKEYEDIT_CURSORLEFT }, - { KEYC_RIGHT, 1, MODEKEYEDIT_CURSORRIGHT }, - { KEYC_UP, 1, MODEKEYEDIT_HISTORYUP }, - - { 0, -1, 0 } + { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL, 1 }, + { '\010' /* C-h */, 0, MODEKEYEDIT_BACKSPACE, 1 }, + { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE, 1 }, + { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE, 1 }, + { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD, 1 }, + { '\033' /* Escape */, 0, MODEKEYEDIT_SWITCHMODE, 1 }, + { '\n', 0, MODEKEYEDIT_ENTER, 1 }, + { '\r', 0, MODEKEYEDIT_ENTER, 1 }, + { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE, 1 }, + { KEYC_DC, 0, MODEKEYEDIT_DELETE, 1 }, + { KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN, 1 }, + { KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT, 1 }, + { KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT, 1 }, + { KEYC_UP, 0, MODEKEYEDIT_HISTORYUP, 1 }, + { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE, 1 }, + { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE, 1 }, + + { '$', 1, MODEKEYEDIT_ENDOFLINE, 1 }, + { '0', 1, MODEKEYEDIT_STARTOFLINE, 1 }, + { 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE, 1 }, + { 'B', 1, MODEKEYEDIT_PREVIOUSSPACE, 1 }, + { 'C', 1, MODEKEYEDIT_SWITCHMODECHANGELINE, 1 }, + { 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE, 1 }, + { 'E', 1, MODEKEYEDIT_NEXTSPACEEND, 1 }, + { 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE, 1 }, + { 'S', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTELINE, 1 }, + { 'W', 1, MODEKEYEDIT_NEXTSPACE, 1 }, + { 'X', 1, MODEKEYEDIT_BACKSPACE, 1 }, + { '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL, 1 }, + { '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE, 1 }, + { '\n', 1, MODEKEYEDIT_ENTER, 1 }, + { '\r', 1, MODEKEYEDIT_ENTER, 1 }, + { '^', 1, MODEKEYEDIT_STARTOFLINE, 1 }, + { 'a', 1, MODEKEYEDIT_SWITCHMODEAPPEND, 1 }, + { 'b', 1, MODEKEYEDIT_PREVIOUSWORD, 1 }, + { 'd', 1, MODEKEYEDIT_DELETELINE, 1 }, + { 'e', 1, MODEKEYEDIT_NEXTWORDEND, 1 }, + { 'h', 1, MODEKEYEDIT_CURSORLEFT, 1 }, + { 'i', 1, MODEKEYEDIT_SWITCHMODE, 1 }, + { 'j', 1, MODEKEYEDIT_HISTORYDOWN, 1 }, + { 'k', 1, MODEKEYEDIT_HISTORYUP, 1 }, + { 'l', 1, MODEKEYEDIT_CURSORRIGHT, 1 }, + { 'p', 1, MODEKEYEDIT_PASTE, 1 }, + { 's', 1, MODEKEYEDIT_SWITCHMODESUBSTITUTE, 1 }, + { 'w', 1, MODEKEYEDIT_NEXTWORD, 1 }, + { 'x', 1, MODEKEYEDIT_DELETE, 1 }, + { KEYC_BSPACE, 1, MODEKEYEDIT_BACKSPACE, 1 }, + { KEYC_DC, 1, MODEKEYEDIT_DELETE, 1 }, + { KEYC_DOWN, 1, MODEKEYEDIT_HISTORYDOWN, 1 }, + { KEYC_LEFT, 1, MODEKEYEDIT_CURSORLEFT, 1 }, + { KEYC_RIGHT, 1, MODEKEYEDIT_CURSORRIGHT, 1 }, + { KEYC_UP, 1, MODEKEYEDIT_HISTORYUP, 1 }, + + { 0, -1, 0, 1 } }; struct mode_key_tree mode_key_tree_vi_edit; /* vi choice selection keys. */ const struct mode_key_entry mode_key_vi_choice[] = { - { '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '\002' /* C-b */, 0, MODEKEYCHOICE_PAGEUP }, - { '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL }, - { '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN }, - { '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN }, - { '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP }, - { '\n', 0, MODEKEYCHOICE_CHOOSE }, - { '\r', 0, MODEKEYCHOICE_CHOOSE }, - { 'j', 0, MODEKEYCHOICE_DOWN }, - { 'k', 0, MODEKEYCHOICE_UP }, - { 'q', 0, MODEKEYCHOICE_CANCEL }, - { KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST }, - { 'g', 0, MODEKEYCHOICE_STARTOFLIST }, - { 'H', 0, MODEKEYCHOICE_TOPLINE }, - { 'L', 0, MODEKEYCHOICE_BOTTOMLINE }, - { 'G', 0, MODEKEYCHOICE_ENDOFLIST }, - { KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST }, - { KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE }, - { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN }, - { KEYC_DOWN, 0, MODEKEYCHOICE_DOWN }, - { KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN }, - { KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP }, - { KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP }, - { KEYC_UP, 0, MODEKEYCHOICE_UP }, - { ' ', 0, MODEKEYCHOICE_TREE_TOGGLE }, - { KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE }, - { KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND }, - { KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL }, - { KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL }, - { KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE }, - { KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE }, - { KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP }, - { KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN }, - - { 0, -1, 0 } + { '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '\002' /* C-b */, 0, MODEKEYCHOICE_PAGEUP, 1 }, + { '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL, 1 }, + { '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN, 1 }, + { '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, + { '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP, 1 }, + { '\n', 0, MODEKEYCHOICE_CHOOSE, 1 }, + { '\r', 0, MODEKEYCHOICE_CHOOSE, 1 }, + { 'j', 0, MODEKEYCHOICE_DOWN, 1 }, + { 'k', 0, MODEKEYCHOICE_UP, 1 }, + { 'q', 0, MODEKEYCHOICE_CANCEL, 1 }, + { KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST, 1 }, + { 'g', 0, MODEKEYCHOICE_STARTOFLIST, 1 }, + { 'H', 0, MODEKEYCHOICE_TOPLINE, 1 }, + { 'L', 0, MODEKEYCHOICE_BOTTOMLINE, 1 }, + { 'G', 0, MODEKEYCHOICE_ENDOFLIST, 1 }, + { KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST, 1 }, + { KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE, 1 }, + { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN, 1 }, + { KEYC_DOWN, 0, MODEKEYCHOICE_DOWN, 1 }, + { KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, + { KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP, 1 }, + { KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP, 1 }, + { KEYC_UP, 0, MODEKEYCHOICE_UP, 1 }, + { ' ', 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, + { KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE, 1 }, + { KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND, 1 }, + { KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL, 1 }, + { KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL, 1 }, + { KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE, 1 }, + { KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, + { KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP, 1 }, + { KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN, 1 }, + + { 0, -1, 0, 1 } }; struct mode_key_tree mode_key_tree_vi_choice; /* vi copy mode keys. */ const struct mode_key_entry mode_key_vi_copy[] = { - { ' ', 0, MODEKEYCOPY_STARTSELECTION }, - { '"', 0, MODEKEYCOPY_STARTNAMEDBUFFER }, - { '$', 0, MODEKEYCOPY_ENDOFLINE }, - { ',', 0, MODEKEYCOPY_JUMPREVERSE }, - { ';', 0, MODEKEYCOPY_JUMPAGAIN }, - { '/', 0, MODEKEYCOPY_SEARCHDOWN }, - { '0', 0, MODEKEYCOPY_STARTOFLINE }, - { '1', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '2', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '3', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '4', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '5', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '6', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '7', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '8', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '9', 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { ':', 0, MODEKEYCOPY_GOTOLINE }, - { '?', 0, MODEKEYCOPY_SEARCHUP }, - { 'A', 0, MODEKEYCOPY_APPENDSELECTION }, - { 'B', 0, MODEKEYCOPY_PREVIOUSSPACE }, - { 'D', 0, MODEKEYCOPY_COPYENDOFLINE }, - { 'E', 0, MODEKEYCOPY_NEXTSPACEEND }, - { 'F', 0, MODEKEYCOPY_JUMPBACK }, - { 'G', 0, MODEKEYCOPY_HISTORYBOTTOM }, - { 'H', 0, MODEKEYCOPY_TOPLINE }, - { 'J', 0, MODEKEYCOPY_SCROLLDOWN }, - { 'K', 0, MODEKEYCOPY_SCROLLUP }, - { 'L', 0, MODEKEYCOPY_BOTTOMLINE }, - { 'M', 0, MODEKEYCOPY_MIDDLELINE }, - { 'N', 0, MODEKEYCOPY_SEARCHREVERSE }, - { 'T', 0, MODEKEYCOPY_JUMPTOBACK }, - { 'V', 0, MODEKEYCOPY_SELECTLINE }, - { 'W', 0, MODEKEYCOPY_NEXTSPACE }, - { '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE }, - { '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL }, - { '\004' /* C-d */, 0, MODEKEYCOPY_HALFPAGEDOWN }, - { '\005' /* C-e */, 0, MODEKEYCOPY_SCROLLDOWN }, - { '\006' /* C-f */, 0, MODEKEYCOPY_NEXTPAGE }, - { '\010' /* C-h */, 0, MODEKEYCOPY_LEFT }, - { '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP }, - { '\031' /* C-y */, 0, MODEKEYCOPY_SCROLLUP }, - { '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION }, - { '\n', 0, MODEKEYCOPY_COPYSELECTION }, - { '\r', 0, MODEKEYCOPY_COPYSELECTION }, - { '^', 0, MODEKEYCOPY_BACKTOINDENTATION }, - { 'b', 0, MODEKEYCOPY_PREVIOUSWORD }, - { 'e', 0, MODEKEYCOPY_NEXTWORDEND }, - { 'f', 0, MODEKEYCOPY_JUMP }, - { 'g', 0, MODEKEYCOPY_HISTORYTOP }, - { 'h', 0, MODEKEYCOPY_LEFT }, - { 'j', 0, MODEKEYCOPY_DOWN }, - { 'k', 0, MODEKEYCOPY_UP }, - { 'l', 0, MODEKEYCOPY_RIGHT }, - { 'n', 0, MODEKEYCOPY_SEARCHAGAIN }, - { 'o', 0, MODEKEYCOPY_OTHEREND }, - { 't', 0, MODEKEYCOPY_JUMPTO }, - { 'q', 0, MODEKEYCOPY_CANCEL }, - { 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE }, - { 'w', 0, MODEKEYCOPY_NEXTWORD }, - { '{', 0, MODEKEYCOPY_PREVIOUSPARAGRAPH }, - { '}', 0, MODEKEYCOPY_NEXTPARAGRAPH }, - { KEYC_BSPACE, 0, MODEKEYCOPY_LEFT }, - { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN }, - { KEYC_DOWN, 0, MODEKEYCOPY_DOWN }, - { KEYC_LEFT, 0, MODEKEYCOPY_LEFT }, - { KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE }, - { KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE }, - { KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT }, - { KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP }, - { KEYC_UP, 0, MODEKEYCOPY_UP }, - { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, - { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, - { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, - { KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, - - { 0, -1, 0 } + { ' ', 0, MODEKEYCOPY_STARTSELECTION, 1 }, + { '"', 0, MODEKEYCOPY_STARTNAMEDBUFFER, 1 }, + { '$', 0, MODEKEYCOPY_ENDOFLINE, 1 }, + { ',', 0, MODEKEYCOPY_JUMPREVERSE, 1 }, + { ';', 0, MODEKEYCOPY_JUMPAGAIN, 1 }, + { '/', 0, MODEKEYCOPY_SEARCHDOWN, 1 }, + { '0', 0, MODEKEYCOPY_STARTOFLINE, 1 }, + { '1', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '2', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '3', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '4', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '5', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '6', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '7', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '8', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '9', 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { ':', 0, MODEKEYCOPY_GOTOLINE, 1 }, + { '?', 0, MODEKEYCOPY_SEARCHUP, 1 }, + { 'A', 0, MODEKEYCOPY_APPENDSELECTION, 1 }, + { 'B', 0, MODEKEYCOPY_PREVIOUSSPACE, 1 }, + { 'D', 0, MODEKEYCOPY_COPYENDOFLINE, 1 }, + { 'E', 0, MODEKEYCOPY_NEXTSPACEEND, 1 }, + { 'F', 0, MODEKEYCOPY_JUMPBACK, 1 }, + { 'G', 0, MODEKEYCOPY_HISTORYBOTTOM, 1 }, + { 'H', 0, MODEKEYCOPY_TOPLINE, 1 }, + { 'J', 0, MODEKEYCOPY_SCROLLDOWN, 1 }, + { 'K', 0, MODEKEYCOPY_SCROLLUP, 1 }, + { 'L', 0, MODEKEYCOPY_BOTTOMLINE, 1 }, + { 'M', 0, MODEKEYCOPY_MIDDLELINE, 1 }, + { 'N', 0, MODEKEYCOPY_SEARCHREVERSE, 1 }, + { 'T', 0, MODEKEYCOPY_JUMPTOBACK, 1 }, + { 'V', 0, MODEKEYCOPY_SELECTLINE, 1 }, + { 'W', 0, MODEKEYCOPY_NEXTSPACE, 1 }, + { '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 }, + { '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL, 1 }, + { '\004' /* C-d */, 0, MODEKEYCOPY_HALFPAGEDOWN, 1 }, + { '\005' /* C-e */, 0, MODEKEYCOPY_SCROLLDOWN, 1 }, + { '\006' /* C-f */, 0, MODEKEYCOPY_NEXTPAGE, 1 }, + { '\010' /* C-h */, 0, MODEKEYCOPY_LEFT, 1 }, + { '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP, 1 }, + { '\031' /* C-y */, 0, MODEKEYCOPY_SCROLLUP, 1 }, + { '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION, 1 }, + { '\n', 0, MODEKEYCOPY_COPYSELECTION, 1 }, + { '\r', 0, MODEKEYCOPY_COPYSELECTION, 1 }, + { '^', 0, MODEKEYCOPY_BACKTOINDENTATION, 1 }, + { 'b', 0, MODEKEYCOPY_PREVIOUSWORD, 1 }, + { 'e', 0, MODEKEYCOPY_NEXTWORDEND, 1 }, + { 'f', 0, MODEKEYCOPY_JUMP, 1 }, + { 'g', 0, MODEKEYCOPY_HISTORYTOP, 1 }, + { 'h', 0, MODEKEYCOPY_LEFT, 1 }, + { 'j', 0, MODEKEYCOPY_DOWN, 1 }, + { 'k', 0, MODEKEYCOPY_UP, 1 }, + { 'l', 0, MODEKEYCOPY_RIGHT, 1 }, + { 'n', 0, MODEKEYCOPY_SEARCHAGAIN, 1 }, + { 'o', 0, MODEKEYCOPY_OTHEREND, 1 }, + { 't', 0, MODEKEYCOPY_JUMPTO, 1 }, + { 'q', 0, MODEKEYCOPY_CANCEL, 1 }, + { 'v', 0, MODEKEYCOPY_RECTANGLETOGGLE, 1 }, + { 'w', 0, MODEKEYCOPY_NEXTWORD, 1 }, + { '{', 0, MODEKEYCOPY_PREVIOUSPARAGRAPH, 1 }, + { '}', 0, MODEKEYCOPY_NEXTPARAGRAPH, 1 }, + { KEYC_BSPACE, 0, MODEKEYCOPY_LEFT, 1 }, + { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN, 1 }, + { KEYC_DOWN, 0, MODEKEYCOPY_DOWN, 1 }, + { KEYC_LEFT, 0, MODEKEYCOPY_LEFT, 1 }, + { KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE, 1 }, + { KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 }, + { KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT, 1 }, + { KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP, 1 }, + { KEYC_UP, 0, MODEKEYCOPY_UP, 1 }, + { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP, 1 }, + { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN, 1 }, + { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION, 1 }, + { KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION, 1 }, + + { 0, -1, 0, 1 } }; struct mode_key_tree mode_key_tree_vi_copy; /* emacs editing keys. */ const struct mode_key_entry mode_key_emacs_edit[] = { - { '\001' /* C-a */, 0, MODEKEYEDIT_STARTOFLINE }, - { '\002' /* C-b */, 0, MODEKEYEDIT_CURSORLEFT }, - { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL }, - { '\004' /* C-d */, 0, MODEKEYEDIT_DELETE }, - { '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE }, - { '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT }, - { '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE }, - { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE }, - { '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE }, - { '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN }, - { '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP }, - { '\024' /* C-t */, 0, MODEKEYEDIT_TRANSPOSECHARS }, - { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE }, - { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD }, - { '\031' /* C-y */, 0, MODEKEYEDIT_PASTE }, - { '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL }, - { '\n', 0, MODEKEYEDIT_ENTER }, - { '\r', 0, MODEKEYEDIT_ENTER }, - { 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD }, - { 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND }, - { 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE }, - { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE }, - { KEYC_DC, 0, MODEKEYEDIT_DELETE }, - { KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN }, - { KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT }, - { KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT }, - { KEYC_UP, 0, MODEKEYEDIT_HISTORYUP }, - { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE }, - { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE }, - - { 0, -1, 0 } + { '\001' /* C-a */, 0, MODEKEYEDIT_STARTOFLINE, 1 }, + { '\002' /* C-b */, 0, MODEKEYEDIT_CURSORLEFT, 1 }, + { '\003' /* C-c */, 0, MODEKEYEDIT_CANCEL, 1 }, + { '\004' /* C-d */, 0, MODEKEYEDIT_DELETE, 1 }, + { '\005' /* C-e */, 0, MODEKEYEDIT_ENDOFLINE, 1 }, + { '\006' /* C-f */, 0, MODEKEYEDIT_CURSORRIGHT, 1 }, + { '\010' /* C-H */, 0, MODEKEYEDIT_BACKSPACE, 1 }, + { '\011' /* Tab */, 0, MODEKEYEDIT_COMPLETE, 1 }, + { '\013' /* C-k */, 0, MODEKEYEDIT_DELETETOENDOFLINE, 1 }, + { '\016' /* C-n */, 0, MODEKEYEDIT_HISTORYDOWN, 1 }, + { '\020' /* C-p */, 0, MODEKEYEDIT_HISTORYUP, 1 }, + { '\024' /* C-t */, 0, MODEKEYEDIT_TRANSPOSECHARS, 1 }, + { '\025' /* C-u */, 0, MODEKEYEDIT_DELETELINE, 1 }, + { '\027' /* C-w */, 0, MODEKEYEDIT_DELETEWORD, 1 }, + { '\031' /* C-y */, 0, MODEKEYEDIT_PASTE, 1 }, + { '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL, 1 }, + { '\n', 0, MODEKEYEDIT_ENTER, 1 }, + { '\r', 0, MODEKEYEDIT_ENTER, 1 }, + { 'b' | KEYC_ESCAPE, 0, MODEKEYEDIT_PREVIOUSWORD, 1 }, + { 'f' | KEYC_ESCAPE, 0, MODEKEYEDIT_NEXTWORDEND, 1 }, + { 'm' | KEYC_ESCAPE, 0, MODEKEYEDIT_STARTOFLINE, 1 }, + { KEYC_BSPACE, 0, MODEKEYEDIT_BACKSPACE, 1 }, + { KEYC_DC, 0, MODEKEYEDIT_DELETE, 1 }, + { KEYC_DOWN, 0, MODEKEYEDIT_HISTORYDOWN, 1 }, + { KEYC_LEFT, 0, MODEKEYEDIT_CURSORLEFT, 1 }, + { KEYC_RIGHT, 0, MODEKEYEDIT_CURSORRIGHT, 1 }, + { KEYC_UP, 0, MODEKEYEDIT_HISTORYUP, 1 }, + { KEYC_HOME, 0, MODEKEYEDIT_STARTOFLINE, 1 }, + { KEYC_END, 0, MODEKEYEDIT_ENDOFLINE, 1 }, + + { 0, -1, 0, 1 } }; struct mode_key_tree mode_key_tree_emacs_edit; /* emacs choice selection keys. */ const struct mode_key_entry mode_key_emacs_choice[] = { - { '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX }, - { '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL }, - { '\016' /* C-n */, 0, MODEKEYCHOICE_DOWN }, - { '\020' /* C-p */, 0, MODEKEYCHOICE_UP }, - { '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN }, - { '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL }, - { '\n', 0, MODEKEYCHOICE_CHOOSE }, - { '\r', 0, MODEKEYCHOICE_CHOOSE }, - { 'q', 0, MODEKEYCHOICE_CANCEL }, - { 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP }, - { KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST }, - { '<' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTOFLIST }, - { 'R' | KEYC_ESCAPE, 0, MODEKEYCHOICE_TOPLINE }, - { '>' | KEYC_ESCAPE, 0, MODEKEYCHOICE_ENDOFLIST }, - { KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST }, - { KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE }, - { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN }, - { KEYC_DOWN, 0, MODEKEYCHOICE_DOWN }, - { KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN }, - { KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP }, - { KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP }, - { KEYC_UP, 0, MODEKEYCHOICE_UP }, - { ' ', 0, MODEKEYCHOICE_TREE_TOGGLE }, - { KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE }, - { KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND }, - { KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL }, - { KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL }, - { KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE }, - { KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE }, - { KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP }, - { KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN }, - - { 0, -1, 0 } + { '0' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '1' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '2' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '3' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '4' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '5' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '6' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '7' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '8' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '9' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTNUMBERPREFIX, 1 }, + { '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL, 1 }, + { '\016' /* C-n */, 0, MODEKEYCHOICE_DOWN, 1 }, + { '\020' /* C-p */, 0, MODEKEYCHOICE_UP, 1 }, + { '\026' /* C-v */, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, + { '\033' /* Escape */, 0, MODEKEYCHOICE_CANCEL, 1 }, + { '\n', 0, MODEKEYCHOICE_CHOOSE, 1 }, + { '\r', 0, MODEKEYCHOICE_CHOOSE, 1 }, + { 'q', 0, MODEKEYCHOICE_CANCEL, 1 }, + { 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP, 1 }, + { KEYC_HOME, 0, MODEKEYCHOICE_STARTOFLIST, 1 }, + { '<' | KEYC_ESCAPE, 0, MODEKEYCHOICE_STARTOFLIST, 1 }, + { 'R' | KEYC_ESCAPE, 0, MODEKEYCHOICE_TOPLINE, 1 }, + { '>' | KEYC_ESCAPE, 0, MODEKEYCHOICE_ENDOFLIST, 1 }, + { KEYC_END, 0, MODEKEYCHOICE_ENDOFLIST, 1 }, + { KEYC_BSPACE, 0, MODEKEYCHOICE_BACKSPACE, 1 }, + { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLDOWN, 1 }, + { KEYC_DOWN, 0, MODEKEYCHOICE_DOWN, 1 }, + { KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN, 1 }, + { KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP, 1 }, + { KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP, 1 }, + { KEYC_UP, 0, MODEKEYCHOICE_UP, 1 }, + { ' ', 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, + { KEYC_LEFT, 0, MODEKEYCHOICE_TREE_COLLAPSE, 1 }, + { KEYC_RIGHT, 0, MODEKEYCHOICE_TREE_EXPAND, 1 }, + { KEYC_LEFT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_COLLAPSE_ALL, 1 }, + { KEYC_RIGHT | KEYC_CTRL, 0, MODEKEYCHOICE_TREE_EXPAND_ALL, 1 }, + { KEYC_MOUSEDOWN1_PANE, 0, MODEKEYCHOICE_CHOOSE, 1 }, + { KEYC_MOUSEDOWN3_PANE, 0, MODEKEYCHOICE_TREE_TOGGLE, 1 }, + { KEYC_WHEELUP_PANE, 0, MODEKEYCHOICE_UP, 5 }, + { KEYC_WHEELDOWN_PANE, 0, MODEKEYCHOICE_DOWN, 5 }, + + { 0, -1, 0, 1 } }; struct mode_key_tree mode_key_tree_emacs_choice; /* emacs copy mode keys. */ const struct mode_key_entry mode_key_emacs_copy[] = { - { ' ', 0, MODEKEYCOPY_NEXTPAGE }, - { ',', 0, MODEKEYCOPY_JUMPREVERSE }, - { ';', 0, MODEKEYCOPY_JUMPAGAIN }, - { '1' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '2' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '3' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '4' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '5' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '6' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '7' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '8' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '9' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX }, - { '<' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYTOP }, - { '>' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYBOTTOM }, - { 'F', 0, MODEKEYCOPY_JUMPBACK }, - { 'N', 0, MODEKEYCOPY_SEARCHREVERSE }, - { 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE }, - { 'R', 0, MODEKEYCOPY_RECTANGLETOGGLE }, - { 'T', 0, MODEKEYCOPY_JUMPTOBACK }, - { '\000' /* C-Space */, 0, MODEKEYCOPY_STARTSELECTION }, - { '\001' /* C-a */, 0, MODEKEYCOPY_STARTOFLINE }, - { '\002' /* C-b */, 0, MODEKEYCOPY_LEFT }, - { '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL }, - { '\005' /* C-e */, 0, MODEKEYCOPY_ENDOFLINE }, - { '\006' /* C-f */, 0, MODEKEYCOPY_RIGHT }, - { '\007' /* C-g */, 0, MODEKEYCOPY_CLEARSELECTION }, - { '\013' /* C-k */, 0, MODEKEYCOPY_COPYENDOFLINE }, - { '\016' /* C-n */, 0, MODEKEYCOPY_DOWN }, - { '\020' /* C-p */, 0, MODEKEYCOPY_UP }, - { '\022' /* C-r */, 0, MODEKEYCOPY_SEARCHUP }, - { '\023' /* C-s */, 0, MODEKEYCOPY_SEARCHDOWN }, - { '\026' /* C-v */, 0, MODEKEYCOPY_NEXTPAGE }, - { '\027' /* C-w */, 0, MODEKEYCOPY_COPYSELECTION }, - { '\033' /* Escape */, 0, MODEKEYCOPY_CANCEL }, - { 'b' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSWORD }, - { 'f', 0, MODEKEYCOPY_JUMP }, - { 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORDEND }, - { 'g', 0, MODEKEYCOPY_GOTOLINE }, - { 'm' | KEYC_ESCAPE, 0, MODEKEYCOPY_BACKTOINDENTATION }, - { 'n', 0, MODEKEYCOPY_SEARCHAGAIN }, - { 'q', 0, MODEKEYCOPY_CANCEL }, - { 'r' | KEYC_ESCAPE, 0, MODEKEYCOPY_MIDDLELINE }, - { 't', 0, MODEKEYCOPY_JUMPTO }, - { 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE }, - { 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION }, - { '{' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPARAGRAPH }, - { '}' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTPARAGRAPH }, - { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN }, - { KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN }, - { KEYC_DOWN, 0, MODEKEYCOPY_DOWN }, - { KEYC_LEFT, 0, MODEKEYCOPY_LEFT }, - { KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE }, - { KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE }, - { KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT }, - { KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP }, - { KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP }, - { KEYC_UP, 0, MODEKEYCOPY_UP }, - { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP }, - { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN }, - { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION }, - { KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION }, - - { 0, -1, 0 } + { ' ', 0, MODEKEYCOPY_NEXTPAGE, 1 }, + { ',', 0, MODEKEYCOPY_JUMPREVERSE, 1 }, + { ';', 0, MODEKEYCOPY_JUMPAGAIN, 1 }, + { '1' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '2' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '3' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '4' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '5' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '6' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '7' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '8' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '9' | KEYC_ESCAPE, 0, MODEKEYCOPY_STARTNUMBERPREFIX, 1 }, + { '<' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYTOP, 1 }, + { '>' | KEYC_ESCAPE, 0, MODEKEYCOPY_HISTORYBOTTOM, 1 }, + { 'F', 0, MODEKEYCOPY_JUMPBACK, 1 }, + { 'N', 0, MODEKEYCOPY_SEARCHREVERSE, 1 }, + { 'R' | KEYC_ESCAPE, 0, MODEKEYCOPY_TOPLINE, 1 }, + { 'R', 0, MODEKEYCOPY_RECTANGLETOGGLE, 1 }, + { 'T', 0, MODEKEYCOPY_JUMPTOBACK, 1 }, + { '\000' /* C-Space */, 0, MODEKEYCOPY_STARTSELECTION, 1 }, + { '\001' /* C-a */, 0, MODEKEYCOPY_STARTOFLINE, 1 }, + { '\002' /* C-b */, 0, MODEKEYCOPY_LEFT, 1 }, + { '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL, 1 }, + { '\005' /* C-e */, 0, MODEKEYCOPY_ENDOFLINE, 1 }, + { '\006' /* C-f */, 0, MODEKEYCOPY_RIGHT, 1 }, + { '\007' /* C-g */, 0, MODEKEYCOPY_CLEARSELECTION, 1 }, + { '\013' /* C-k */, 0, MODEKEYCOPY_COPYENDOFLINE, 1 }, + { '\016' /* C-n */, 0, MODEKEYCOPY_DOWN, 1 }, + { '\020' /* C-p */, 0, MODEKEYCOPY_UP, 1 }, + { '\022' /* C-r */, 0, MODEKEYCOPY_SEARCHUP, 1 }, + { '\023' /* C-s */, 0, MODEKEYCOPY_SEARCHDOWN, 1 }, + { '\026' /* C-v */, 0, MODEKEYCOPY_NEXTPAGE, 1 }, + { '\027' /* C-w */, 0, MODEKEYCOPY_COPYSELECTION, 1 }, + { '\033' /* Escape */, 0, MODEKEYCOPY_CANCEL, 1 }, + { 'b' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSWORD, 1 }, + { 'f', 0, MODEKEYCOPY_JUMP, 1 }, + { 'f' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTWORDEND, 1 }, + { 'g', 0, MODEKEYCOPY_GOTOLINE, 1 }, + { 'm' | KEYC_ESCAPE, 0, MODEKEYCOPY_BACKTOINDENTATION, 1 }, + { 'n', 0, MODEKEYCOPY_SEARCHAGAIN, 1 }, + { 'q', 0, MODEKEYCOPY_CANCEL, 1 }, + { 'r' | KEYC_ESCAPE, 0, MODEKEYCOPY_MIDDLELINE, 1 }, + { 't', 0, MODEKEYCOPY_JUMPTO, 1 }, + { 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 }, + { 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION, 1 }, + { '{' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPARAGRAPH, 1 }, + { '}' | KEYC_ESCAPE, 0, MODEKEYCOPY_NEXTPARAGRAPH, 1 }, + { KEYC_DOWN | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLDOWN, 1 }, + { KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN, 1 }, + { KEYC_DOWN, 0, MODEKEYCOPY_DOWN, 1 }, + { KEYC_LEFT, 0, MODEKEYCOPY_LEFT, 1 }, + { KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE, 1 }, + { KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE, 1 }, + { KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT, 1 }, + { KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP, 1 }, + { KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP, 1 }, + { KEYC_UP, 0, MODEKEYCOPY_UP, 1 }, + { KEYC_WHEELUP_PANE, 0, MODEKEYCOPY_SCROLLUP, 5 }, + { KEYC_WHEELDOWN_PANE, 0, MODEKEYCOPY_SCROLLDOWN, 5 }, + { KEYC_MOUSEDRAG1_PANE, 0, MODEKEYCOPY_STARTSELECTION, 1 }, + { KEYC_MOUSEDRAGEND1_PANE, 0, MODEKEYCOPY_COPYSELECTION, 1 }, + + { 0, -1, 0, 1 } }; struct mode_key_tree mode_key_tree_emacs_copy; @@ -586,6 +587,7 @@ mode_key_init_trees(void) for (ment = mtab->table; ment->mode != -1; ment++) { mbind = xmalloc(sizeof *mbind); mbind->key = ment->key; + mbind->repeat = ment->repeat; mbind->mode = ment->mode; mbind->cmd = ment->cmd; mbind->arg = NULL; @@ -602,7 +604,8 @@ mode_key_init(struct mode_key_data *mdata, struct mode_key_tree *mtree) } enum mode_key_cmd -mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg) +mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg, + u_int *repeat) { struct mode_key_binding *mbind, mtmp; @@ -613,6 +616,8 @@ mode_key_lookup(struct mode_key_data *mdata, key_code key, const char **arg) return (MODEKEY_NONE); return (MODEKEY_OTHER); } + if (repeat != NULL) + *repeat = mbind->repeat; switch (mbind->cmd) { case MODEKEYEDIT_SWITCHMODE: diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index f31e80567a3..c14011ef492 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.149 2016/06/06 07:23:36 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.150 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -818,7 +818,7 @@ status_prompt_key(struct client *c, key_code key) size_t size, n, off, idx, bufsize; size = strlen(c->prompt_buffer); - switch (mode_key_lookup(&c->prompt_mdata, key, NULL)) { + switch (mode_key_lookup(&c->prompt_mdata, key, NULL, NULL)) { case MODEKEYEDIT_CURSORLEFT: if (c->prompt_index > 0) { c->prompt_index--; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 6abd4315835..b4c165df8f7 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.494 2016/09/04 17:37:06 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.495 2016/09/12 15:40:58 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 4 2016 $ +.Dd $Mdocdate: September 12 2016 $ .Dt TMUX 1 .Os .Sh NAME @@ -2133,6 +2133,7 @@ Commands related to key bindings are as follows: .Bl -tag -width Ds .It Xo Ic bind-key .Op Fl cnr +.Op Fl R Ar repeat-count .Op Fl t Ar mode-table .Op Fl T Ar key-table .Ar key Ar command Op Ar arguments @@ -2191,6 +2192,14 @@ is bound in the binding for command mode with .Fl c or for normal mode without. +For keys in the +.Em vi-copy +or +.Em emacs-copy +tables, +.Fl R +specifies how many times the command should be repeated. +.Pp See the .Sx WINDOWS AND PANES section and the diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 4fb24bfbcc3..995c8a3cd9d 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.643 2016/09/04 17:37:06 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.644 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -566,6 +566,7 @@ struct mode_key_data { /* Binding between a key and a command. */ struct mode_key_binding { key_code key; + u_int repeat; int mode; enum mode_key_cmd cmd; @@ -1633,7 +1634,7 @@ const struct mode_key_table *mode_key_findtable(const char *); void mode_key_init_trees(void); void mode_key_init(struct mode_key_data *, struct mode_key_tree *); enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code, - const char **); + const char **, u_int *); /* notify.c */ void notify_enable(void); diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c index 9e0f0063750..db8f18c83d2 100644 --- a/usr.bin/tmux/window-choose.c +++ b/usr.bin/tmux/window-choose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-choose.c,v 1.76 2016/04/28 07:20:26 nicm Exp $ */ +/* $OpenBSD: window-choose.c,v 1.77 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -552,7 +552,7 @@ window_choose_key(struct window_pane *wp, __unused struct client *c, items = data->list_size; if (data->input_type == WINDOW_CHOOSE_GOTO_ITEM) { - switch (mode_key_lookup(&data->mdata, key, NULL)) { + switch (mode_key_lookup(&data->mdata, key, NULL, NULL)) { case MODEKEYCHOICE_CANCEL: data->input_type = WINDOW_CHOOSE_NORMAL; window_choose_redraw_screen(wp); @@ -582,7 +582,7 @@ window_choose_key(struct window_pane *wp, __unused struct client *c, return; } - switch (mode_key_lookup(&data->mdata, key, NULL)) { + switch (mode_key_lookup(&data->mdata, key, NULL, NULL)) { case MODEKEYCHOICE_CANCEL: window_choose_fire_callback(wp, NULL); break; @@ -837,7 +837,7 @@ window_choose_key_index(struct window_choose_mode_data *data, u_int idx) int mkey; for (ptr = keys; *ptr != '\0'; ptr++) { - mkey = mode_key_lookup(&data->mdata, *ptr, NULL); + mkey = mode_key_lookup(&data->mdata, *ptr, NULL, NULL); if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER) continue; if (idx-- == 0) @@ -857,7 +857,7 @@ window_choose_index_key(struct window_choose_mode_data *data, key_code key) u_int idx = 0; for (ptr = keys; *ptr != '\0'; ptr++) { - mkey = mode_key_lookup(&data->mdata, *ptr, NULL); + mkey = mode_key_lookup(&data->mdata, *ptr, NULL, NULL); if (mkey != MODEKEY_NONE && mkey != MODEKEY_OTHER) continue; if (key == (key_code)*ptr) diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 9e0f0fe6c83..b4ba32f01b9 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.151 2016/05/23 20:03:14 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.152 2016/09/12 15:40:58 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -538,7 +538,9 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess, return; } - cmd = mode_key_lookup(&data->mdata, key, &arg); + cmd = mode_key_lookup(&data->mdata, key, &arg, &np); + if (data->numprefix > 0) + np = data->numprefix; if (cmd != MODEKEYCOPY_PREVIOUSPAGE && cmd != MODEKEYCOPY_NEXTPAGE && cmd != MODEKEYCOPY_SCROLLUP && @@ -900,11 +902,11 @@ window_copy_key_input(struct window_pane *wp, key_code key) struct screen *s = &data->screen; const char *bufdata; size_t inputlen, n, bufsize; - int np; + u_int np; struct paste_buffer *pb; u_char ch; - switch (mode_key_lookup(&data->mdata, key, NULL)) { + switch (mode_key_lookup(&data->mdata, key, NULL, &np)) { case MODEKEYEDIT_CANCEL: data->numprefix = -1; return (-1); @@ -932,10 +934,8 @@ window_copy_key_input(struct window_pane *wp, key_code key) data->inputstr[inputlen + n] = '\0'; break; case MODEKEYEDIT_ENTER: - np = data->numprefix; - if (np <= 0) - np = 1; - + if (data->numprefix > 0) + np = data->numprefix; switch (data->inputtype) { case WINDOW_COPY_OFF: case WINDOW_COPY_JUMPFORWARD: |