Add space movement keys for vi mode in the status line from Ben Boeckel.

This commit is contained in:
Nicholas Marriott 2012-01-20 19:10:29 +00:00
parent 299a8fd4a3
commit e6519d3e27
3 changed files with 25 additions and 4 deletions

View File

@ -54,9 +54,12 @@ const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
{ MODEKEYEDIT_ENTER, "enter" }, { MODEKEYEDIT_ENTER, "enter" },
{ MODEKEYEDIT_HISTORYDOWN, "history-down" }, { MODEKEYEDIT_HISTORYDOWN, "history-down" },
{ MODEKEYEDIT_HISTORYUP, "history-up" }, { MODEKEYEDIT_HISTORYUP, "history-up" },
{ MODEKEYEDIT_NEXTSPACE, "next-space" },
{ MODEKEYEDIT_NEXTSPACEEND, "next-space-end" },
{ MODEKEYEDIT_NEXTWORD, "next-word" }, { MODEKEYEDIT_NEXTWORD, "next-word" },
{ MODEKEYEDIT_NEXTWORDEND, "next-word-end" }, { MODEKEYEDIT_NEXTWORDEND, "next-word-end" },
{ MODEKEYEDIT_PASTE, "paste" }, { MODEKEYEDIT_PASTE, "paste" },
{ MODEKEYEDIT_PREVIOUSSPACE, "previous-space" },
{ MODEKEYEDIT_PREVIOUSWORD, "previous-word" }, { MODEKEYEDIT_PREVIOUSWORD, "previous-word" },
{ MODEKEYEDIT_STARTOFLINE, "start-of-line" }, { MODEKEYEDIT_STARTOFLINE, "start-of-line" },
{ MODEKEYEDIT_SWITCHMODE, "switch-mode" }, { MODEKEYEDIT_SWITCHMODE, "switch-mode" },
@ -148,7 +151,10 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ '$', 1, MODEKEYEDIT_ENDOFLINE }, { '$', 1, MODEKEYEDIT_ENDOFLINE },
{ '0', 1, MODEKEYEDIT_STARTOFLINE }, { '0', 1, MODEKEYEDIT_STARTOFLINE },
{ 'B', 1, MODEKEYEDIT_PREVIOUSSPACE },
{ 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE }, { 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE },
{ 'E', 1, MODEKEYEDIT_NEXTSPACEEND },
{ 'W', 1, MODEKEYEDIT_NEXTSPACE },
{ 'X', 1, MODEKEYEDIT_BACKSPACE }, { 'X', 1, MODEKEYEDIT_BACKSPACE },
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL }, { '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
{ '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE }, { '\010' /* C-h */, 1, MODEKEYEDIT_BACKSPACE },

View File

@ -978,7 +978,7 @@ status_prompt_key(struct client *c, int key)
struct paste_buffer *pb; struct paste_buffer *pb;
char *s, *first, *last, word[64], swapc; char *s, *first, *last, word[64], swapc;
const char *histstr; const char *histstr;
const char *wsep; const char *wsep = NULL;
u_char ch; u_char ch;
size_t size, n, off, idx; size_t size, n, off, idx;
@ -1124,7 +1124,11 @@ status_prompt_key(struct client *c, int key)
c->prompt_index = idx; c->prompt_index = idx;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_NEXTSPACE:
wsep = " ";
/* FALLTHROUGH */
case MODEKEYEDIT_NEXTWORD: case MODEKEYEDIT_NEXTWORD:
if (wsep == NULL)
wsep = options_get_string(oo, "word-separators"); wsep = options_get_string(oo, "word-separators");
/* Find a separator. */ /* Find a separator. */
@ -1143,7 +1147,11 @@ status_prompt_key(struct client *c, int key)
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_NEXTSPACEEND:
wsep = " ";
/* FALLTHROUGH */
case MODEKEYEDIT_NEXTWORDEND: case MODEKEYEDIT_NEXTWORDEND:
if (wsep == NULL)
wsep = options_get_string(oo, "word-separators"); wsep = options_get_string(oo, "word-separators");
/* Find a word. */ /* Find a word. */
@ -1162,7 +1170,11 @@ status_prompt_key(struct client *c, int key)
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
break; break;
case MODEKEYEDIT_PREVIOUSSPACE:
wsep = " ";
/* FALLTHROUGH */
case MODEKEYEDIT_PREVIOUSWORD: case MODEKEYEDIT_PREVIOUSWORD:
if (wsep == NULL)
wsep = options_get_string(oo, "word-separators"); wsep = options_get_string(oo, "word-separators");
/* Find a non-separator. */ /* Find a non-separator. */

3
tmux.h
View File

@ -447,9 +447,12 @@ enum mode_key_cmd {
MODEKEYEDIT_ENTER, MODEKEYEDIT_ENTER,
MODEKEYEDIT_HISTORYDOWN, MODEKEYEDIT_HISTORYDOWN,
MODEKEYEDIT_HISTORYUP, MODEKEYEDIT_HISTORYUP,
MODEKEYEDIT_NEXTSPACE,
MODEKEYEDIT_NEXTSPACEEND,
MODEKEYEDIT_NEXTWORD, MODEKEYEDIT_NEXTWORD,
MODEKEYEDIT_NEXTWORDEND, MODEKEYEDIT_NEXTWORDEND,
MODEKEYEDIT_PASTE, MODEKEYEDIT_PASTE,
MODEKEYEDIT_PREVIOUSSPACE,
MODEKEYEDIT_PREVIOUSWORD, MODEKEYEDIT_PREVIOUSWORD,
MODEKEYEDIT_STARTOFLINE, MODEKEYEDIT_STARTOFLINE,
MODEKEYEDIT_SWITCHMODE, MODEKEYEDIT_SWITCHMODE,