mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
add support for downcase-word, upcase-word and capitalise-word
This commit is contained in:
parent
a1020b3e61
commit
cd1c2f74d3
4 changed files with 50 additions and 1 deletions
|
@ -115,6 +115,9 @@ static const wchar_t * const name_arr[] =
|
||||||
L"self-insert",
|
L"self-insert",
|
||||||
L"transpose-chars",
|
L"transpose-chars",
|
||||||
L"transpose-words",
|
L"transpose-words",
|
||||||
|
L"upcase-word",
|
||||||
|
L"downcase-word",
|
||||||
|
L"capitalize-word",
|
||||||
L"null",
|
L"null",
|
||||||
L"eof",
|
L"eof",
|
||||||
L"vi-arg-digit",
|
L"vi-arg-digit",
|
||||||
|
@ -201,6 +204,9 @@ static const wchar_t code_arr[] =
|
||||||
R_SELF_INSERT,
|
R_SELF_INSERT,
|
||||||
R_TRANSPOSE_CHARS,
|
R_TRANSPOSE_CHARS,
|
||||||
R_TRANSPOSE_WORDS,
|
R_TRANSPOSE_WORDS,
|
||||||
|
R_UPCASE_WORD,
|
||||||
|
R_DOWNCASE_WORD,
|
||||||
|
R_CAPITALIZE_WORD,
|
||||||
R_NULL,
|
R_NULL,
|
||||||
R_EOF,
|
R_EOF,
|
||||||
R_VI_ARG_DIGIT,
|
R_VI_ARG_DIGIT,
|
||||||
|
|
3
input.h
3
input.h
|
@ -44,6 +44,9 @@ enum
|
||||||
R_SELF_INSERT,
|
R_SELF_INSERT,
|
||||||
R_TRANSPOSE_CHARS,
|
R_TRANSPOSE_CHARS,
|
||||||
R_TRANSPOSE_WORDS,
|
R_TRANSPOSE_WORDS,
|
||||||
|
R_UPCASE_WORD,
|
||||||
|
R_DOWNCASE_WORD,
|
||||||
|
R_CAPITALIZE_WORD,
|
||||||
R_VI_ARG_DIGIT,
|
R_VI_ARG_DIGIT,
|
||||||
R_VI_DELETE_TO,
|
R_VI_DELETE_TO,
|
||||||
R_EXECUTE,
|
R_EXECUTE,
|
||||||
|
|
38
reader.cpp
38
reader.cpp
|
@ -3790,7 +3790,43 @@ const wchar_t *reader_readline(void)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case R_UPCASE_WORD:
|
||||||
|
{
|
||||||
|
size_t pos = data->buff_pos;
|
||||||
|
move_word(MOVE_DIR_RIGHT, false, move_word_style_punctuation, false);
|
||||||
|
for (; pos < data->buff_pos; pos++)
|
||||||
|
data->command_line.at(pos) = towupper(data->command_line.at(pos));
|
||||||
|
reader_repaint();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case R_DOWNCASE_WORD:
|
||||||
|
{
|
||||||
|
size_t pos = data->buff_pos;
|
||||||
|
move_word(MOVE_DIR_RIGHT, false, move_word_style_punctuation, false);
|
||||||
|
for (; pos < data->buff_pos; pos++)
|
||||||
|
data->command_line.at(pos) = towlower(data->command_line.at(pos));
|
||||||
|
reader_repaint();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case R_CAPITALIZE_WORD:
|
||||||
|
{
|
||||||
|
size_t pos = data->buff_pos;
|
||||||
|
bool capitalized_first = false;
|
||||||
|
move_word(MOVE_DIR_RIGHT, false, move_word_style_punctuation, false);
|
||||||
|
for (; pos < data->buff_pos; pos++) {
|
||||||
|
if (iswalnum(data->command_line.at(pos)) && !capitalized_first) {
|
||||||
|
data->command_line.at(pos) = towupper(data->command_line.at(pos));
|
||||||
|
capitalized_first = true;
|
||||||
|
} else
|
||||||
|
data->command_line.at(pos) = towlower(data->command_line.at(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:
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,10 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
|
||||||
bind \cb backward-char
|
bind \cb backward-char
|
||||||
bind \ct transpose-chars
|
bind \ct transpose-chars
|
||||||
bind \et transpose-words
|
bind \et transpose-words
|
||||||
|
bind \eu upcase-word
|
||||||
|
# This clashes with __fish_list_current_token
|
||||||
|
# bind \el downcase-word
|
||||||
|
bind \ec capitalize-word
|
||||||
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…
Reference in a new issue