mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-23 00:23:08 +01:00
Add a transpose-chars command in edit mode (C-t in emacs mode only). From Kalle
Olavi Niemitalo.
This commit is contained in:
parent
c089e19020
commit
61b7dc522d
@ -57,6 +57,7 @@ struct mode_key_cmdstr mode_key_cmdstr_edit[] = {
|
||||
{ MODEKEYEDIT_STARTOFLINE, "start-of-line" },
|
||||
{ MODEKEYEDIT_SWITCHMODE, "switch-mode" },
|
||||
{ MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" },
|
||||
{ MODEKEYEDIT_TRANSPOSECHARS, "transpose-chars" },
|
||||
|
||||
{ 0, NULL }
|
||||
};
|
||||
@ -200,6 +201,7 @@ const struct mode_key_entry mode_key_emacs_edit[] = {
|
||||
{ '\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 },
|
||||
{ '\031' /* C-y */, 0, MODEKEYEDIT_PASTE },
|
||||
{ '\033' /* Escape */, 0, MODEKEYEDIT_CANCEL },
|
||||
|
14
status.c
14
status.c
@ -763,7 +763,7 @@ void
|
||||
status_prompt_key(struct client *c, int key)
|
||||
{
|
||||
struct paste_buffer *pb;
|
||||
char *s, *first, *last, word[64];
|
||||
char *s, *first, *last, word[64], swapc;
|
||||
size_t size, n, off, idx;
|
||||
|
||||
size = strlen(c->prompt_buffer);
|
||||
@ -933,6 +933,18 @@ status_prompt_key(struct client *c, int key)
|
||||
|
||||
c->flags |= CLIENT_STATUS;
|
||||
break;
|
||||
case MODEKEYEDIT_TRANSPOSECHARS:
|
||||
idx = c->prompt_index;
|
||||
if (idx < size)
|
||||
idx++;
|
||||
if (idx >= 2) {
|
||||
swapc = c->prompt_buffer[idx - 2];
|
||||
c->prompt_buffer[idx - 2] = c->prompt_buffer[idx - 1];
|
||||
c->prompt_buffer[idx - 1] = swapc;
|
||||
c->prompt_index = idx;
|
||||
c->flags |= CLIENT_STATUS;
|
||||
}
|
||||
break;
|
||||
case MODEKEYEDIT_ENTER:
|
||||
if (*c->prompt_buffer != '\0')
|
||||
status_prompt_add_history(c);
|
||||
|
1
tmux.1
1
tmux.1
@ -497,6 +497,7 @@ The following keys are supported as appropriate for the mode:
|
||||
.It Li "Search forward" Ta "/" Ta "C-s"
|
||||
.It Li "Start of line" Ta "0" Ta "C-a"
|
||||
.It Li "Start selection" Ta "Space" Ta "C-Space"
|
||||
.It Li "Transpose chars" Ta "" Ta "C-t"
|
||||
.El
|
||||
.Pp
|
||||
These key bindings are defined in a set of named tables:
|
||||
|
Loading…
Reference in New Issue
Block a user