mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
command and binding for transpose-chars
This commit is contained in:
parent
9f0775c873
commit
f32dfe2da6
@ -113,6 +113,7 @@ static const wchar_t * const name_arr[] =
|
|||||||
L"history-token-search-backward",
|
L"history-token-search-backward",
|
||||||
L"history-token-search-forward",
|
L"history-token-search-forward",
|
||||||
L"self-insert",
|
L"self-insert",
|
||||||
|
L"transpose-chars",
|
||||||
L"null",
|
L"null",
|
||||||
L"eof",
|
L"eof",
|
||||||
L"vi-arg-digit",
|
L"vi-arg-digit",
|
||||||
@ -197,6 +198,7 @@ static const wchar_t code_arr[] =
|
|||||||
R_HISTORY_TOKEN_SEARCH_BACKWARD,
|
R_HISTORY_TOKEN_SEARCH_BACKWARD,
|
||||||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||||
R_SELF_INSERT,
|
R_SELF_INSERT,
|
||||||
|
R_TRANSPOSE_CHARS,
|
||||||
R_NULL,
|
R_NULL,
|
||||||
R_EOF,
|
R_EOF,
|
||||||
R_VI_ARG_DIGIT,
|
R_VI_ARG_DIGIT,
|
||||||
|
1
input.h
1
input.h
@ -42,6 +42,7 @@ enum
|
|||||||
R_HISTORY_TOKEN_SEARCH_BACKWARD,
|
R_HISTORY_TOKEN_SEARCH_BACKWARD,
|
||||||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||||
R_SELF_INSERT,
|
R_SELF_INSERT,
|
||||||
|
R_TRANSPOSE_CHARS,
|
||||||
R_VI_ARG_DIGIT,
|
R_VI_ARG_DIGIT,
|
||||||
R_VI_DELETE_TO,
|
R_VI_DELETE_TO,
|
||||||
R_EXECUTE,
|
R_EXECUTE,
|
||||||
|
27
reader.cpp
27
reader.cpp
@ -3542,6 +3542,33 @@ const wchar_t *reader_readline(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case R_TRANSPOSE_CHARS:
|
||||||
|
{
|
||||||
|
if (data->command_length() < 2) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the cursor is at the end, transpose the last two characters of the line */
|
||||||
|
if (data->buff_pos == data->command_length())
|
||||||
|
{
|
||||||
|
data->buff_pos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Drag the character before the cursor forward over the character at the cursor, moving
|
||||||
|
the cursor forward as well.
|
||||||
|
*/
|
||||||
|
if (data->buff_pos > 0)
|
||||||
|
{
|
||||||
|
wchar_t tmp = data->command_line[data->buff_pos];
|
||||||
|
data->command_line[data->buff_pos] = data->command_line[data->buff_pos-1];
|
||||||
|
data->command_line[data->buff_pos-1] = tmp;
|
||||||
|
data->buff_pos++;
|
||||||
|
reader_repaint();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Other, if a normal character, we add it to the command */
|
/* Other, if a normal character, we add it to the command */
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -67,6 +67,7 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
|
|||||||
bind \cn history-search-forward
|
bind \cn history-search-forward
|
||||||
bind \cf forward-char
|
bind \cf forward-char
|
||||||
bind \cb backward-char
|
bind \cb backward-char
|
||||||
|
bind \ct transpose-chars
|
||||||
bind \e\x7f backward-kill-word
|
bind \e\x7f backward-kill-word
|
||||||
bind \eb backward-word
|
bind \eb backward-word
|
||||||
bind \ef forward-word
|
bind \ef forward-word
|
||||||
|
Loading…
x
Reference in New Issue
Block a user