Sync OpenBSD patchset 1039:

Add A and I keys for vi status line editing.
This commit is contained in:
Tiago Cunha 2012-03-07 13:37:44 +00:00
parent e7c7024907
commit 32a6092f71
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
* two sets of bindings to be swapped between. A couple of editing commands
* (MODEKEYEDIT_SWITCHMODE and MODEKEYEDIT_SWITCHMODEAPPEND) are special-cased
* to do this.
* (MODEKEYEDIT_SWITCHMODE, MODEKEYEDIT_SWITCHMODEAPPEND,
* MODEKEYEDIT_SWITCHMODEAPPENDLINE, and MODEKEYEDIT_SWITCHMODEBEGINLINE)
* are special-cased to do this.
*/
/* Edit keys command strings. */
@ -64,6 +65,8 @@ const struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
{ MODEKEYEDIT_STARTOFLINE, "start-of-line" },
{ MODEKEYEDIT_SWITCHMODE, "switch-mode" },
{ MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" },
{ MODEKEYEDIT_SWITCHMODEAPPENDLINE, "switch-mode-append-line" },
{ MODEKEYEDIT_SWITCHMODEBEGINLINE, "switch-mode-begin-line" },
{ MODEKEYEDIT_TRANSPOSECHARS, "transpose-chars" },
{ 0, NULL }
@ -151,9 +154,11 @@ const struct mode_key_entry mode_key_vi_edit[] = {
{ '$', 1, MODEKEYEDIT_ENDOFLINE },
{ '0', 1, MODEKEYEDIT_STARTOFLINE },
{ 'A', 1, MODEKEYEDIT_SWITCHMODEAPPENDLINE },
{ 'B', 1, MODEKEYEDIT_PREVIOUSSPACE },
{ 'D', 1, MODEKEYEDIT_DELETETOENDOFLINE },
{ 'E', 1, MODEKEYEDIT_NEXTSPACEEND },
{ 'I', 1, MODEKEYEDIT_SWITCHMODEBEGINLINE },
{ 'W', 1, MODEKEYEDIT_NEXTSPACE },
{ 'X', 1, MODEKEYEDIT_BACKSPACE },
{ '\003' /* C-c */, 1, MODEKEYEDIT_CANCEL },
@ -496,6 +501,8 @@ mode_key_lookup(struct mode_key_data *mdata, int key)
switch (mbind->cmd) {
case MODEKEYEDIT_SWITCHMODE:
case MODEKEYEDIT_SWITCHMODEAPPEND:
case MODEKEYEDIT_SWITCHMODEAPPENDLINE:
case MODEKEYEDIT_SWITCHMODEBEGINLINE:
mdata->mode = 1 - mdata->mode;
/* FALLTHROUGH */
default:

View File

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

2
tmux.h
View File

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