Add A and I keys for vi status line editing.

This commit is contained in:
Nicholas Marriott 2012-03-04 07:38:11 +00:00
parent 8b68ea1462
commit 30f4c30ca3
3 changed files with 17 additions and 2 deletions

View File

@ -35,8 +35,9 @@
* *
* vi command mode is handled by having a mode flag in the struct which allows * vi command mode is handled by having a mode flag in the struct which allows
* two sets of bindings to be swapped between. A couple of editing commands * two sets of bindings to be swapped between. A couple of editing commands
* (MODEKEYEDIT_SWITCHMODE and MODEKEYEDIT_SWITCHMODEAPPEND) are special-cased * (MODEKEYEDIT_SWITCHMODE, MODEKEYEDIT_SWITCHMODEAPPEND,
* to do this. * MODEKEYEDIT_SWITCHMODEAPPENDLINE, and MODEKEYEDIT_SWITCHMODEBEGINLINE)
* are special-cased to do this.
*/ */
/* Edit keys command strings. */ /* Edit keys command strings. */
@ -64,6 +65,8 @@ const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
{ MODEKEYEDIT_STARTOFLINE, "start-of-line" }, { MODEKEYEDIT_STARTOFLINE, "start-of-line" },
{ MODEKEYEDIT_SWITCHMODE, "switch-mode" }, { MODEKEYEDIT_SWITCHMODE, "switch-mode" },
{ MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" }, { MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" },
{ MODEKEYEDIT_SWITCHMODEAPPENDLINE, "switch-mode-append-line" },
{ MODEKEYEDIT_SWITCHMODEBEGINLINE, "switch-mode-begin-line" },
{ MODEKEYEDIT_TRANSPOSECHARS, "transpose-chars" }, { MODEKEYEDIT_TRANSPOSECHARS, "transpose-chars" },
{ 0, NULL } { 0, NULL }
@ -151,9 +154,11 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ '$', 1, MODEKEYEDIT_ENDOFLINE }, { '$', 1, MODEKEYEDIT_ENDOFLINE },
{ '0', 1, MODEKEYEDIT_STARTOFLINE }, { '0', 1, MODEKEYEDIT_STARTOFLINE },
{ 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE },
{ 'B', 1, MODEKEYEDIT_PREVIOUSSPACE }, { 'B', 1, MODEKEYEDIT_PREVIOUSSPACE },
{ 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE }, { 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE },
{ 'E', 1, MODEKEYEDIT_NEXTSPACEEND }, { 'E', 1, MODEKEYEDIT_NEXTSPACEEND },
{ 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE },
{ 'W', 1, MODEKEYEDIT_NEXTSPACE }, { 'W', 1, MODEKEYEDIT_NEXTSPACE },
{ 'X', 1, MODEKEYEDIT_BACKSPACE }, { 'X', 1, MODEKEYEDIT_BACKSPACE },
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL }, { '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
@ -496,6 +501,8 @@ mode_key_lookup(struct mode_key_data *mdata, int key)
switch (mbind->cmd) { switch (mbind->cmd) {
case MODEKEYEDIT_SWITCHMODE: case MODEKEYEDIT_SWITCHMODE:
case MODEKEYEDIT_SWITCHMODEAPPEND: case MODEKEYEDIT_SWITCHMODEAPPEND:
case MODEKEYEDIT_SWITCHMODEAPPENDLINE:
case MODEKEYEDIT_SWITCHMODEBEGINLINE:
mdata->mode = 1 - mdata->mode; mdata->mode = 1 - mdata->mode;
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:

View File

@ -1038,12 +1038,18 @@ status_prompt_key(struct client *c, int key)
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
} }
break; break;
case MODEKEYEDIT_SWITCHMODEBEGINLINE:
c->flags |= CLIENT_STATUS;
/* FALLTHROUGH */
case MODEKEYEDIT_STARTOFLINE: case MODEKEYEDIT_STARTOFLINE:
if (c->prompt_index != 0) { if (c->prompt_index != 0) {
c->prompt_index = 0; c->prompt_index = 0;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
} }
break; break;
case MODEKEYEDIT_SWITCHMODEAPPENDLINE:
c->flags |= CLIENT_STATUS;
/* FALLTHROUGH */
case MODEKEYEDIT_ENDOFLINE: case MODEKEYEDIT_ENDOFLINE:
if (c->prompt_index != size) { if (c->prompt_index != size) {
c->prompt_index = size; c->prompt_index = size;

2
tmux.h
View File

@ -457,6 +457,8 @@ enum mode_key_cmd {
MODEKEYEDIT_STARTOFLINE, MODEKEYEDIT_STARTOFLINE,
MODEKEYEDIT_SWITCHMODE, MODEKEYEDIT_SWITCHMODE,
MODEKEYEDIT_SWITCHMODEAPPEND, MODEKEYEDIT_SWITCHMODEAPPEND,
MODEKEYEDIT_SWITCHMODEAPPENDLINE,
MODEKEYEDIT_SWITCHMODEBEGINLINE,
MODEKEYEDIT_TRANSPOSECHARS, MODEKEYEDIT_TRANSPOSECHARS,
/* Menu (choice) keys. */ /* Menu (choice) keys. */