mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 17:01:55 +08:00
Implement nextd-or-forward-word and prevd-or-backward-word in C++
This commit is contained in:
parent
4746137a61
commit
fb73a4b2e2
@ -583,7 +583,8 @@ Unlike other shells, fish does not have aliases or special prompt syntax. Functi
|
||||
You can list the names of all functions with the :ref:`functions <cmd-functions>` builtin (note the plural!). fish starts out with a number of functions::
|
||||
|
||||
> functions
|
||||
N_, abbr, alias, bg, cd, cdh, contains_seq, delete-or-exit, dirh, dirs, disown, down-or-search, edit_command_buffer, export, fg, fish_add_path, fish_breakpoint_prompt, fish_clipboard_copy, fish_clipboard_paste, fish_config, fish_default_key_bindings, fish_default_mode_prompt, fish_git_prompt, fish_hg_prompt, fish_hybrid_key_bindings, fish_indent, fish_is_root_user, fish_job_summary, fish_key_reader, fish_md5, fish_mode_prompt, fish_npm_helper, fish_opt, fish_print_git_action, fish_print_hg_root, fish_prompt, fish_sigtrap_handler, fish_svn_prompt, fish_title, fish_update_completions, fish_vcs_prompt, fish_vi_cursor, fish_vi_key_bindings, funced, funcsave, grep, help, history, hostname, isatty, kill, la, ll, ls, man, nextd, nextd-or-forward-word, open, popd, prevd, prevd-or-backward-word, prompt_hostname, prompt_pwd, psub, pushd, realpath, seq, setenv, suspend, trap, type, umask, up-or-search, vared, wait
|
||||
N_, abbr, alias, bg, cd, cdh, contains_seq, delete-or-exit, dirh, dirs, disown, down-or-search, edit_command_buffer, export, fg, fish_add_path, fish_breakpoint_prompt, fish_clipboard_copy, fish_clipboard_paste, fish_config, fish_default_key_bindings, fish_default_mode_prompt, fish_git_prompt, fish_hg_prompt, fish_hybrid_key_bindings, fish_indent, fish_is_root_user, fish_job_summary, fish_key_reader, fish_md5, fish_mode_prompt, fish_npm_helper, fish_opt, fish_print_git_action, fish_print_hg_root, fish_prompt, fish_sigtrap_handler, fish_svn_prompt, fish_title, fish_update_completions, fish_vcs_prompt, fish_vi_cursor, fish_vi_key_bindings, funced, funcsave, grep, help, history, hostname, isatty, kill, la, ll, ls, man, nextd, open, popd, prevd, prompt_hostname, prompt_pwd, psub, pushd, realpath, seq, setenv, suspend, trap, type, umask, up-or-search, vared, wait
|
||||
|
||||
|
||||
|
||||
You can see the source for any function by passing its name to ``functions``::
|
||||
|
@ -1,9 +0,0 @@
|
||||
function nextd-or-forward-word
|
||||
set -l cmd (commandline)
|
||||
if test -z "$cmd"
|
||||
nextd
|
||||
commandline -f repaint
|
||||
else
|
||||
commandline -f forward-word
|
||||
end
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
function prevd-or-backward-word
|
||||
set -l cmd (commandline)
|
||||
if test -z "$cmd"
|
||||
prevd
|
||||
commandline -f repaint
|
||||
else
|
||||
commandline -f backward-word
|
||||
end
|
||||
end
|
@ -143,8 +143,10 @@ static constexpr const input_function_metadata_t input_function_metadata[] = {
|
||||
{L"kill-selection", readline_cmd_t::kill_selection},
|
||||
{L"kill-whole-line", readline_cmd_t::kill_whole_line},
|
||||
{L"kill-word", readline_cmd_t::kill_word},
|
||||
{L"nextd-or-forward-word", readline_cmd_t::nextd_or_forward_word},
|
||||
{L"or", readline_cmd_t::func_or},
|
||||
{L"pager-toggle-search", readline_cmd_t::pager_toggle_search},
|
||||
{L"prevd-or-backward-word", readline_cmd_t::prevd_or_backward_word},
|
||||
{L"redo", readline_cmd_t::redo},
|
||||
{L"repaint", readline_cmd_t::repaint},
|
||||
{L"repaint-mode", readline_cmd_t::repaint_mode},
|
||||
|
@ -19,6 +19,8 @@ enum class readline_cmd_t {
|
||||
backward_word,
|
||||
forward_bigword,
|
||||
backward_bigword,
|
||||
nextd_or_forward_word,
|
||||
prevd_or_backward_word,
|
||||
history_search_backward,
|
||||
history_search_forward,
|
||||
history_prefix_search_backward,
|
||||
|
@ -1462,6 +1462,8 @@ static bool command_ends_paging(readline_cmd_t c, bool focused_on_search_field)
|
||||
case rl::backward_word:
|
||||
case rl::forward_bigword:
|
||||
case rl::backward_bigword:
|
||||
case rl::nextd_or_forward_word:
|
||||
case rl::prevd_or_backward_word:
|
||||
case rl::delete_char:
|
||||
case rl::backward_delete_char:
|
||||
case rl::kill_line:
|
||||
@ -3510,7 +3512,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
||||
break;
|
||||
}
|
||||
case rl::backward_word:
|
||||
case rl::backward_bigword: {
|
||||
case rl::backward_bigword:
|
||||
case rl::prevd_or_backward_word: {
|
||||
if (c == rl::prevd_or_backward_word && command_line.empty()) {
|
||||
auto last_statuses = parser().get_last_statuses();
|
||||
(void)parser().eval(L"prevd", io_chain_t{});
|
||||
parser().set_last_statuses(std::move(last_statuses));
|
||||
force_exec_prompt_and_repaint = true;
|
||||
inputter.queue_char(readline_cmd_t::repaint);
|
||||
break;
|
||||
}
|
||||
|
||||
auto move_style =
|
||||
(c == rl::backward_word) ? move_word_style_punctuation : move_word_style_whitespace;
|
||||
move_word(active_edit_line(), MOVE_DIR_LEFT, false /* do not erase */, move_style,
|
||||
@ -3518,7 +3530,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
||||
break;
|
||||
}
|
||||
case rl::forward_word:
|
||||
case rl::forward_bigword: {
|
||||
case rl::forward_bigword:
|
||||
case rl::nextd_or_forward_word: {
|
||||
if (c == rl::nextd_or_forward_word && command_line.empty()) {
|
||||
auto last_statuses = parser().get_last_statuses();
|
||||
(void)parser().eval(L"nextd", io_chain_t{});
|
||||
parser().set_last_statuses(std::move(last_statuses));
|
||||
force_exec_prompt_and_repaint = true;
|
||||
inputter.queue_char(readline_cmd_t::repaint);
|
||||
break;
|
||||
}
|
||||
|
||||
auto move_style =
|
||||
(c == rl::forward_word) ? move_word_style_punctuation : move_word_style_whitespace;
|
||||
editable_line_t *el = active_edit_line();
|
||||
|
Loading…
x
Reference in New Issue
Block a user