Rename all readline commands to lowercase and remove R_ prefix

This commit is contained in:
ridiculousfish
2019-03-23 17:32:39 -07:00
parent 9187458d51
commit e7d7eff0ee
4 changed files with 268 additions and 268 deletions

View File

@@ -2999,8 +2999,8 @@ static void test_input() {
auto evt = input_readch(); auto evt = input_readch();
if (!evt.is_readline()) { if (!evt.is_readline()) {
err(L"Event is not a readline"); err(L"Event is not a readline");
} else if (evt.get_readline() != readline_cmd_t::R_DOWN_LINE) { } else if (evt.get_readline() != readline_cmd_t::down_line) {
err(L"Expected to read char R_DOWN_LINE"); err(L"Expected to read char down_line");
} }
} }

View File

@@ -72,64 +72,64 @@ struct input_function_metadata_t {
}; };
static const input_function_metadata_t input_function_metadata[] = { static const input_function_metadata_t input_function_metadata[] = {
{readline_cmd_t::R_BEGINNING_OF_LINE, L"beginning-of-line"}, {readline_cmd_t::beginning_of_line, L"beginning-of-line"},
{readline_cmd_t::R_END_OF_LINE, L"end-of-line"}, {readline_cmd_t::end_of_line, L"end-of-line"},
{readline_cmd_t::R_FORWARD_CHAR, L"forward-char"}, {readline_cmd_t::forward_char, L"forward-char"},
{readline_cmd_t::R_BACKWARD_CHAR, L"backward-char"}, {readline_cmd_t::backward_char, L"backward-char"},
{readline_cmd_t::R_FORWARD_WORD, L"forward-word"}, {readline_cmd_t::forward_word, L"forward-word"},
{readline_cmd_t::R_BACKWARD_WORD, L"backward-word"}, {readline_cmd_t::backward_word, L"backward-word"},
{readline_cmd_t::R_FORWARD_BIGWORD, L"forward-bigword"}, {readline_cmd_t::forward_bigword, L"forward-bigword"},
{readline_cmd_t::R_BACKWARD_BIGWORD, L"backward-bigword"}, {readline_cmd_t::backward_bigword, L"backward-bigword"},
{readline_cmd_t::R_HISTORY_SEARCH_BACKWARD, L"history-search-backward"}, {readline_cmd_t::history_search_backward, L"history-search-backward"},
{readline_cmd_t::R_HISTORY_SEARCH_FORWARD, L"history-search-forward"}, {readline_cmd_t::history_search_forward, L"history-search-forward"},
{readline_cmd_t::R_DELETE_CHAR, L"delete-char"}, {readline_cmd_t::delete_char, L"delete-char"},
{readline_cmd_t::R_BACKWARD_DELETE_CHAR, L"backward-delete-char"}, {readline_cmd_t::backward_delete_char, L"backward-delete-char"},
{readline_cmd_t::R_KILL_LINE, L"kill-line"}, {readline_cmd_t::kill_line, L"kill-line"},
{readline_cmd_t::R_YANK, L"yank"}, {readline_cmd_t::yank, L"yank"},
{readline_cmd_t::R_YANK_POP, L"yank-pop"}, {readline_cmd_t::yank_POP, L"yank-pop"},
{readline_cmd_t::R_COMPLETE, L"complete"}, {readline_cmd_t::complete, L"complete"},
{readline_cmd_t::R_COMPLETE_AND_SEARCH, L"complete-and-search"}, {readline_cmd_t::complete_AND_SEARCH, L"complete-and-search"},
{readline_cmd_t::R_PAGER_TOGGLE_SEARCH, L"pager-toggle-search"}, {readline_cmd_t::pager_toggle_search, L"pager-toggle-search"},
{readline_cmd_t::R_BEGINNING_OF_HISTORY, L"beginning-of-history"}, {readline_cmd_t::beginning_of_history, L"beginning-of-history"},
{readline_cmd_t::R_END_OF_HISTORY, L"end-of-history"}, {readline_cmd_t::end_of_history, L"end-of-history"},
{readline_cmd_t::R_BACKWARD_KILL_LINE, L"backward-kill-line"}, {readline_cmd_t::backward_kill_line, L"backward-kill-line"},
{readline_cmd_t::R_KILL_WHOLE_LINE, L"kill-whole-line"}, {readline_cmd_t::kill_whole_line, L"kill-whole-line"},
{readline_cmd_t::R_KILL_WORD, L"kill-word"}, {readline_cmd_t::kill_word, L"kill-word"},
{readline_cmd_t::R_KILL_BIGWORD, L"kill-bigword"}, {readline_cmd_t::kill_bigword, L"kill-bigword"},
{readline_cmd_t::R_BACKWARD_KILL_WORD, L"backward-kill-word"}, {readline_cmd_t::backward_kill_word, L"backward-kill-word"},
{readline_cmd_t::R_BACKWARD_KILL_PATH_COMPONENT, L"backward-kill-path-component"}, {readline_cmd_t::backward_kill_path_component, L"backward-kill-path-component"},
{readline_cmd_t::R_BACKWARD_KILL_BIGWORD, L"backward-kill-bigword"}, {readline_cmd_t::backward_kill_bigword, L"backward-kill-bigword"},
{readline_cmd_t::R_HISTORY_TOKEN_SEARCH_BACKWARD, L"history-token-search-backward"}, {readline_cmd_t::history_token_search_backward, L"history-token-search-backward"},
{readline_cmd_t::R_HISTORY_TOKEN_SEARCH_FORWARD, L"history-token-search-forward"}, {readline_cmd_t::history_token_search_forward, L"history-token-search-forward"},
{readline_cmd_t::R_SELF_INSERT, L"self-insert"}, {readline_cmd_t::self_insert, L"self-insert"},
{readline_cmd_t::R_TRANSPOSE_CHARS, L"transpose-chars"}, {readline_cmd_t::transpose_chars, L"transpose-chars"},
{readline_cmd_t::R_TRANSPOSE_WORDS, L"transpose-words"}, {readline_cmd_t::transpose_words, L"transpose-words"},
{readline_cmd_t::R_UPCASE_WORD, L"upcase-word"}, {readline_cmd_t::upcase_word, L"upcase-word"},
{readline_cmd_t::R_DOWNCASE_WORD, L"downcase-word"}, {readline_cmd_t::downcase_word, L"downcase-word"},
{readline_cmd_t::R_CAPITALIZE_WORD, L"capitalize-word"}, {readline_cmd_t::capitalize_word, L"capitalize-word"},
{readline_cmd_t::R_VI_ARG_DIGIT, L"vi-arg-digit"}, {readline_cmd_t::vi_arg_digit, L"vi-arg-digit"},
{readline_cmd_t::R_VI_DELETE_TO, L"vi-delete-to"}, {readline_cmd_t::vi_delete_to, L"vi-delete-to"},
{readline_cmd_t::R_EXECUTE, L"execute"}, {readline_cmd_t::execute, L"execute"},
{readline_cmd_t::R_BEGINNING_OF_BUFFER, L"beginning-of-buffer"}, {readline_cmd_t::beginning_of_buffer, L"beginning-of-buffer"},
{readline_cmd_t::R_END_OF_BUFFER, L"end-of-buffer"}, {readline_cmd_t::end_of_buffer, L"end-of-buffer"},
{readline_cmd_t::R_REPAINT, L"repaint"}, {readline_cmd_t::repaint, L"repaint"},
{readline_cmd_t::R_FORCE_REPAINT, L"force-repaint"}, {readline_cmd_t::force_repaint, L"force-repaint"},
{readline_cmd_t::R_UP_LINE, L"up-line"}, {readline_cmd_t::up_line, L"up-line"},
{readline_cmd_t::R_DOWN_LINE, L"down-line"}, {readline_cmd_t::down_line, L"down-line"},
{readline_cmd_t::R_SUPPRESS_AUTOSUGGESTION, L"suppress-autosuggestion"}, {readline_cmd_t::suppress_autosuggestion, L"suppress-autosuggestion"},
{readline_cmd_t::R_ACCEPT_AUTOSUGGESTION, L"accept-autosuggestion"}, {readline_cmd_t::accept_autosuggestion, L"accept-autosuggestion"},
{readline_cmd_t::R_BEGIN_SELECTION, L"begin-selection"}, {readline_cmd_t::begin_selection, L"begin-selection"},
{readline_cmd_t::R_SWAP_SELECTION_START_STOP, L"swap-selection-start-stop"}, {readline_cmd_t::swap_selection_start_stop, L"swap-selection-start-stop"},
{readline_cmd_t::R_END_SELECTION, L"end-selection"}, {readline_cmd_t::end_selection, L"end-selection"},
{readline_cmd_t::R_KILL_SELECTION, L"kill-selection"}, {readline_cmd_t::kill_selection, L"kill-selection"},
{readline_cmd_t::R_FORWARD_JUMP, L"forward-jump"}, {readline_cmd_t::forward_jump, L"forward-jump"},
{readline_cmd_t::R_BACKWARD_JUMP, L"backward-jump"}, {readline_cmd_t::backward_jump, L"backward-jump"},
{readline_cmd_t::R_FORWARD_JUMP_TILL, L"forward-jump-till"}, {readline_cmd_t::forward_jump_till, L"forward-jump-till"},
{readline_cmd_t::R_BACKWARD_JUMP_TILL, L"backward-jump-till"}, {readline_cmd_t::backward_jump_till, L"backward-jump-till"},
{readline_cmd_t::R_REPEAT_JUMP, L"repeat-jump"}, {readline_cmd_t::repeat_jump, L"repeat-jump"},
{readline_cmd_t::R_REVERSE_REPEAT_JUMP, L"repeat-jump-reverse"}, {readline_cmd_t::reverse_repeat_jump, L"repeat-jump-reverse"},
{readline_cmd_t::R_AND, L"and"}, {readline_cmd_t::func_and, L"and"},
{readline_cmd_t::R_CANCEL, L"cancel"}}; {readline_cmd_t::cancel, L"cancel"}};
static_assert(sizeof(input_function_metadata) / sizeof(input_function_metadata[0]) == static_assert(sizeof(input_function_metadata) / sizeof(input_function_metadata[0]) ==
input_function_count, input_function_count,
@@ -185,10 +185,10 @@ void input_set_bind_mode(const wcstring &bm) {
/// Returns the arity of a given input function. /// Returns the arity of a given input function.
static int input_function_arity(readline_cmd_t function) { static int input_function_arity(readline_cmd_t function) {
switch (function) { switch (function) {
case readline_cmd_t::R_FORWARD_JUMP: case readline_cmd_t::forward_jump:
case readline_cmd_t::R_BACKWARD_JUMP: case readline_cmd_t::backward_jump:
case readline_cmd_t::R_FORWARD_JUMP_TILL: case readline_cmd_t::forward_jump_till:
case readline_cmd_t::R_BACKWARD_JUMP_TILL: case readline_cmd_t::backward_jump_till:
return 1; return 1;
default: default:
return 0; return 0;
@@ -481,12 +481,12 @@ char_event_t input_readch(bool allow_commands) {
if (evt.is_readline()) { if (evt.is_readline()) {
switch (evt.get_readline()) { switch (evt.get_readline()) {
case readline_cmd_t::R_SELF_INSERT: { case readline_cmd_t::self_insert: {
// Issue #1595: ensure we only insert characters, not readline functions. The // Issue #1595: ensure we only insert characters, not readline functions. The
// common case is that this will be empty. // common case is that this will be empty.
return input_read_characters_no_readline(); return input_read_characters_no_readline();
} }
case readline_cmd_t::R_AND: { case readline_cmd_t::func_and: {
if (input_function_status) { if (input_function_status) {
return input_readch(); return input_readch();
} }

View File

@@ -10,70 +10,70 @@
#include "maybe.h" #include "maybe.h"
enum class readline_cmd_t { enum class readline_cmd_t {
R_BEGINNING_OF_LINE = INPUT_COMMON_BASE, beginning_of_line = INPUT_COMMON_BASE,
R_END_OF_LINE, end_of_line,
R_FORWARD_CHAR, forward_char,
R_BACKWARD_CHAR, backward_char,
R_FORWARD_WORD, forward_word,
R_BACKWARD_WORD, backward_word,
R_FORWARD_BIGWORD, forward_bigword,
R_BACKWARD_BIGWORD, backward_bigword,
R_HISTORY_SEARCH_BACKWARD, history_search_backward,
R_HISTORY_SEARCH_FORWARD, history_search_forward,
R_DELETE_CHAR, delete_char,
R_BACKWARD_DELETE_CHAR, backward_delete_char,
R_KILL_LINE, kill_line,
R_YANK, yank,
R_YANK_POP, yank_POP,
R_COMPLETE, complete,
R_COMPLETE_AND_SEARCH, complete_AND_SEARCH,
R_PAGER_TOGGLE_SEARCH, pager_toggle_search,
R_BEGINNING_OF_HISTORY, beginning_of_history,
R_END_OF_HISTORY, end_of_history,
R_BACKWARD_KILL_LINE, backward_kill_line,
R_KILL_WHOLE_LINE, kill_whole_line,
R_KILL_WORD, kill_word,
R_KILL_BIGWORD, kill_bigword,
R_BACKWARD_KILL_WORD, backward_kill_word,
R_BACKWARD_KILL_PATH_COMPONENT, backward_kill_path_component,
R_BACKWARD_KILL_BIGWORD, backward_kill_bigword,
R_HISTORY_TOKEN_SEARCH_BACKWARD, history_token_search_backward,
R_HISTORY_TOKEN_SEARCH_FORWARD, history_token_search_forward,
R_SELF_INSERT, self_insert,
R_TRANSPOSE_CHARS, transpose_chars,
R_TRANSPOSE_WORDS, transpose_words,
R_UPCASE_WORD, upcase_word,
R_DOWNCASE_WORD, downcase_word,
R_CAPITALIZE_WORD, capitalize_word,
R_VI_ARG_DIGIT, vi_arg_digit,
R_VI_DELETE_TO, vi_delete_to,
R_EXECUTE, execute,
R_BEGINNING_OF_BUFFER, beginning_of_buffer,
R_END_OF_BUFFER, end_of_buffer,
R_REPAINT, repaint,
R_FORCE_REPAINT, force_repaint,
R_UP_LINE, up_line,
R_DOWN_LINE, down_line,
R_SUPPRESS_AUTOSUGGESTION, suppress_autosuggestion,
R_ACCEPT_AUTOSUGGESTION, accept_autosuggestion,
R_BEGIN_SELECTION, begin_selection,
R_SWAP_SELECTION_START_STOP, swap_selection_start_stop,
R_END_SELECTION, end_selection,
R_KILL_SELECTION, kill_selection,
R_FORWARD_JUMP, forward_jump,
R_BACKWARD_JUMP, backward_jump,
R_FORWARD_JUMP_TILL, forward_jump_till,
R_BACKWARD_JUMP_TILL, backward_jump_till,
R_AND, func_and,
R_CANCEL, cancel,
R_REPEAT_JUMP, repeat_jump,
R_REVERSE_REPEAT_JUMP, reverse_repeat_jump,
}; };
// The range of key codes for inputrc-style keyboard functions. // The range of key codes for inputrc-style keyboard functions.
enum { enum {
R_BEGIN_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::R_BEGINNING_OF_LINE), R_BEGIN_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::beginning_of_line),
R_END_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::R_REVERSE_REPEAT_JUMP) + 1 R_END_INPUT_FUNCTIONS = static_cast<int>(readline_cmd_t::reverse_repeat_jump) + 1
}; };
/// Represents an event on the character input stream. /// Represents an event on the character input stream.

View File

@@ -1034,61 +1034,61 @@ void reader_force_exit() {
static bool command_ends_paging(readline_cmd_t c, bool focused_on_search_field) { static bool command_ends_paging(readline_cmd_t c, bool focused_on_search_field) {
using rl = readline_cmd_t; using rl = readline_cmd_t;
switch (c) { switch (c) {
case rl::R_HISTORY_SEARCH_BACKWARD: case rl::history_search_backward:
case rl::R_HISTORY_SEARCH_FORWARD: case rl::history_search_forward:
case rl::R_HISTORY_TOKEN_SEARCH_BACKWARD: case rl::history_token_search_backward:
case rl::R_HISTORY_TOKEN_SEARCH_FORWARD: case rl::history_token_search_forward:
case rl::R_ACCEPT_AUTOSUGGESTION: case rl::accept_autosuggestion:
case rl::R_CANCEL: { case rl::cancel: {
// These commands always end paging. // These commands always end paging.
return true; return true;
} }
case rl::R_COMPLETE: case rl::complete:
case rl::R_COMPLETE_AND_SEARCH: case rl::complete_AND_SEARCH:
case rl::R_BACKWARD_CHAR: case rl::backward_char:
case rl::R_FORWARD_CHAR: case rl::forward_char:
case rl::R_UP_LINE: case rl::up_line:
case rl::R_DOWN_LINE: case rl::down_line:
case rl::R_REPAINT: case rl::repaint:
case rl::R_SUPPRESS_AUTOSUGGESTION: case rl::suppress_autosuggestion:
case rl::R_BEGINNING_OF_HISTORY: case rl::beginning_of_history:
case rl::R_END_OF_HISTORY: { case rl::end_of_history: {
// These commands never end paging. // These commands never end paging.
return false; return false;
} }
case rl::R_EXECUTE: { case rl::execute: {
// R_EXECUTE does end paging, but only executes if it was not paging. So it's handled // execute does end paging, but only executes if it was not paging. So it's handled
// specially. // specially.
return false; return false;
} }
case rl::R_BEGINNING_OF_LINE: case rl::beginning_of_line:
case rl::R_END_OF_LINE: case rl::end_of_line:
case rl::R_FORWARD_WORD: case rl::forward_word:
case rl::R_BACKWARD_WORD: case rl::backward_word:
case rl::R_FORWARD_BIGWORD: case rl::forward_bigword:
case rl::R_BACKWARD_BIGWORD: case rl::backward_bigword:
case rl::R_DELETE_CHAR: case rl::delete_char:
case rl::R_BACKWARD_DELETE_CHAR: case rl::backward_delete_char:
case rl::R_KILL_LINE: case rl::kill_line:
case rl::R_YANK: case rl::yank:
case rl::R_YANK_POP: case rl::yank_POP:
case rl::R_BACKWARD_KILL_LINE: case rl::backward_kill_line:
case rl::R_KILL_WHOLE_LINE: case rl::kill_whole_line:
case rl::R_KILL_WORD: case rl::kill_word:
case rl::R_KILL_BIGWORD: case rl::kill_bigword:
case rl::R_BACKWARD_KILL_WORD: case rl::backward_kill_word:
case rl::R_BACKWARD_KILL_PATH_COMPONENT: case rl::backward_kill_path_component:
case rl::R_BACKWARD_KILL_BIGWORD: case rl::backward_kill_bigword:
case rl::R_SELF_INSERT: case rl::self_insert:
case rl::R_TRANSPOSE_CHARS: case rl::transpose_chars:
case rl::R_TRANSPOSE_WORDS: case rl::transpose_words:
case rl::R_UPCASE_WORD: case rl::upcase_word:
case rl::R_DOWNCASE_WORD: case rl::downcase_word:
case rl::R_CAPITALIZE_WORD: case rl::capitalize_word:
case rl::R_VI_ARG_DIGIT: case rl::vi_arg_digit:
case rl::R_VI_DELETE_TO: case rl::vi_delete_to:
case rl::R_BEGINNING_OF_BUFFER: case rl::beginning_of_buffer:
case rl::R_END_OF_BUFFER: case rl::end_of_buffer:
// These commands operate on the search field if that's where the focus is. // These commands operate on the search field if that's where the focus is.
return !focused_on_search_field; return !focused_on_search_field;
default: default:
@@ -1099,12 +1099,12 @@ static bool command_ends_paging(readline_cmd_t c, bool focused_on_search_field)
/// Indicates if the given command ends the history search. /// Indicates if the given command ends the history search.
static bool command_ends_history_search(readline_cmd_t c) { static bool command_ends_history_search(readline_cmd_t c) {
switch (c) { switch (c) {
case readline_cmd_t::R_HISTORY_SEARCH_BACKWARD: case readline_cmd_t::history_search_backward:
case readline_cmd_t::R_HISTORY_SEARCH_FORWARD: case readline_cmd_t::history_search_forward:
case readline_cmd_t::R_HISTORY_TOKEN_SEARCH_BACKWARD: case readline_cmd_t::history_token_search_backward:
case readline_cmd_t::R_HISTORY_TOKEN_SEARCH_FORWARD: case readline_cmd_t::history_token_search_forward:
case readline_cmd_t::R_REPAINT: case readline_cmd_t::repaint:
case readline_cmd_t::R_FORCE_REPAINT: case readline_cmd_t::force_repaint:
return false; return false;
default: default:
return true; return true;
@@ -2491,7 +2491,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
using rl = readline_cmd_t; using rl = readline_cmd_t;
switch (c) { switch (c) {
// Go to beginning of line. // Go to beginning of line.
case rl::R_BEGINNING_OF_LINE: { case rl::beginning_of_line: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
while (el->position > 0 && el->text.at(el->position - 1) != L'\n') { while (el->position > 0 && el->text.at(el->position - 1) != L'\n') {
update_buff_pos(el, el->position - 1); update_buff_pos(el, el->position - 1);
@@ -2500,7 +2500,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_END_OF_LINE: { case rl::end_of_line: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
if (el->position < el->size()) { if (el->position < el->size()) {
const wchar_t *buff = el->text.c_str(); const wchar_t *buff = el->text.c_str();
@@ -2514,22 +2514,22 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_BEGINNING_OF_BUFFER: { case rl::beginning_of_buffer: {
update_buff_pos(&command_line, 0); update_buff_pos(&command_line, 0);
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_END_OF_BUFFER: { case rl::end_of_buffer: {
update_buff_pos(&command_line, command_line.size()); update_buff_pos(&command_line, command_line.size());
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_CANCEL: { case rl::cancel: {
// The only thing we can cancel right now is paging, which we handled up above. // The only thing we can cancel right now is paging, which we handled up above.
break; break;
} }
case rl::R_FORCE_REPAINT: case rl::force_repaint:
case rl::R_REPAINT: { case rl::repaint: {
if (!rls.coalescing_repaints) { if (!rls.coalescing_repaints) {
rls.coalescing_repaints = true; rls.coalescing_repaints = true;
exec_prompt(); exec_prompt();
@@ -2539,21 +2539,21 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_COMPLETE: case rl::complete:
case rl::R_COMPLETE_AND_SEARCH: { case rl::complete_AND_SEARCH: {
if (!complete_func) break; if (!complete_func) break;
// Use the command line only; it doesn't make sense to complete in any other line. // Use the command line only; it doesn't make sense to complete in any other line.
editable_line_t *el = &command_line; editable_line_t *el = &command_line;
if (is_navigating_pager_contents() || if (is_navigating_pager_contents() ||
(!rls.comp_empty && rls.last_cmd == rl::R_COMPLETE)) { (!rls.comp_empty && rls.last_cmd == rl::complete)) {
// The user typed R_COMPLETE more than once in a row. If we are not yet fully // The user typed complete more than once in a row. If we are not yet fully
// disclosed, then become so; otherwise cycle through our available completions. // disclosed, then become so; otherwise cycle through our available completions.
if (current_page_rendering.remaining_to_disclose > 0) { if (current_page_rendering.remaining_to_disclose > 0) {
pager.set_fully_disclosed(true); pager.set_fully_disclosed(true);
reader_repaint_needed(); reader_repaint_needed();
} else { } else {
select_completion_in_direction(c == rl::R_COMPLETE ? direction_next select_completion_in_direction(c == rl::complete ? direction_next
: direction_prev); : direction_prev);
} }
} else { } else {
@@ -2613,11 +2613,11 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
cycle_command_line = el->text; cycle_command_line = el->text;
cycle_cursor_pos = el->position; cycle_cursor_pos = el->position;
bool cont_after_prefix_insertion = (c == rl::R_COMPLETE_AND_SEARCH); bool cont_after_prefix_insertion = (c == rl::complete_AND_SEARCH);
rls.comp_empty = handle_completions(rls.comp, cont_after_prefix_insertion); rls.comp_empty = handle_completions(rls.comp, cont_after_prefix_insertion);
// Show the search field if requested and if we printed a list of completions. // Show the search field if requested and if we printed a list of completions.
if (c == rl::R_COMPLETE_AND_SEARCH && !rls.comp_empty && !pager.empty()) { if (c == rl::complete_AND_SEARCH && !rls.comp_empty && !pager.empty()) {
pager.set_search_field_shown(true); pager.set_search_field_shown(true);
select_completion_in_direction(direction_next); select_completion_in_direction(direction_next);
reader_repaint_needed(); reader_repaint_needed();
@@ -2625,7 +2625,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_PAGER_TOGGLE_SEARCH: { case rl::pager_toggle_search: {
if (!pager.empty()) { if (!pager.empty()) {
// Toggle search, and begin navigating if we are now searching. // Toggle search, and begin navigating if we are now searching.
bool sfs = pager.is_search_field_shown(); bool sfs = pager.is_search_field_shown();
@@ -2638,7 +2638,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_KILL_LINE: { case rl::kill_line: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
const wchar_t *buff = el->text.c_str(); const wchar_t *buff = el->text.c_str();
const wchar_t *begin = &buff[el->position]; const wchar_t *begin = &buff[el->position];
@@ -2650,11 +2650,11 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
size_t len = end - begin; size_t len = end - begin;
if (len) { if (len) {
kill(el, begin - buff, len, KILL_APPEND, rls.last_cmd != rl::R_KILL_LINE); kill(el, begin - buff, len, KILL_APPEND, rls.last_cmd != rl::kill_line);
} }
break; break;
} }
case rl::R_BACKWARD_KILL_LINE: { case rl::backward_kill_line: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
if (el->position <= 0) { if (el->position <= 0) {
break; break;
@@ -2673,10 +2673,10 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
assert(end >= begin); assert(end >= begin);
size_t len = std::max<size_t>(end - begin, 1); size_t len = std::max<size_t>(end - begin, 1);
begin = end - len; begin = end - len;
kill(el, begin - buff, len, KILL_PREPEND, rls.last_cmd != rl::R_BACKWARD_KILL_LINE); kill(el, begin - buff, len, KILL_PREPEND, rls.last_cmd != rl::backward_kill_line);
break; break;
} }
case rl::R_KILL_WHOLE_LINE: { case rl::kill_whole_line: {
// We match the emacs behavior here: "kills the entire line including the following // We match the emacs behavior here: "kills the entire line including the following
// newline". // newline".
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
@@ -2702,17 +2702,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
assert(end >= begin); assert(end >= begin);
if (end > begin) { if (end > begin) {
kill(el, begin, end - begin, KILL_APPEND, rls.last_cmd != rl::R_KILL_WHOLE_LINE); kill(el, begin, end - begin, KILL_APPEND, rls.last_cmd != rl::kill_whole_line);
} }
break; break;
} }
case rl::R_YANK: { case rl::yank: {
wcstring yank_str = kill_yank(); wcstring yank_str = kill_yank();
insert_string(active_edit_line(), yank_str); insert_string(active_edit_line(), yank_str);
rls.yank_len = yank_str.size(); rls.yank_len = yank_str.size();
break; break;
} }
case rl::R_YANK_POP: { case rl::yank_POP: {
if (rls.yank_len) { if (rls.yank_len) {
for (size_t i = 0; i < rls.yank_len; i++) remove_backward(); for (size_t i = 0; i < rls.yank_len; i++) remove_backward();
@@ -2722,11 +2722,11 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_BACKWARD_DELETE_CHAR: { case rl::backward_delete_char: {
remove_backward(); remove_backward();
break; break;
} }
case rl::R_DELETE_CHAR: { case rl::delete_char: {
// Remove the current character in the character buffer and on the screen using // Remove the current character in the character buffer and on the screen using
// syntax highlighting, etc. // syntax highlighting, etc.
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
@@ -2738,7 +2738,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
// Evaluate. If the current command is unfinished, or if the charater is escaped // Evaluate. If the current command is unfinished, or if the charater is escaped
// using a backslash, insert a newline. // using a backslash, insert a newline.
case rl::R_EXECUTE: { case rl::execute: {
// If the user hits return while navigating the pager, it only clears the pager. // If the user hits return while navigating the pager, it only clears the pager.
if (is_navigating_pager_contents()) { if (is_navigating_pager_contents()) {
clear_pager(); clear_pager();
@@ -2821,14 +2821,14 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
break; break;
} }
case rl::R_HISTORY_SEARCH_BACKWARD: case rl::history_search_backward:
case rl::R_HISTORY_TOKEN_SEARCH_BACKWARD: case rl::history_token_search_backward:
case rl::R_HISTORY_SEARCH_FORWARD: case rl::history_search_forward:
case rl::R_HISTORY_TOKEN_SEARCH_FORWARD: { case rl::history_token_search_forward: {
if (history_search.is_at_end()) { if (history_search.is_at_end()) {
const editable_line_t *el = &command_line; const editable_line_t *el = &command_line;
bool by_token = (c == rl::R_HISTORY_TOKEN_SEARCH_BACKWARD) || bool by_token = (c == rl::history_token_search_backward) ||
(c == rl::R_HISTORY_TOKEN_SEARCH_FORWARD); (c == rl::history_token_search_forward);
if (by_token) { if (by_token) {
// Searching by token. // Searching by token.
const wchar_t *begin, *end; const wchar_t *begin, *end;
@@ -2855,7 +2855,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
if (history_search.active()) { if (history_search.active()) {
history_search_direction_t dir = history_search_direction_t dir =
(c == rl::R_HISTORY_SEARCH_BACKWARD || c == rl::R_HISTORY_TOKEN_SEARCH_BACKWARD) (c == rl::history_search_backward || c == rl::history_token_search_backward)
? history_search_direction_t::backward ? history_search_direction_t::backward
: history_search_direction_t::forward; : history_search_direction_t::forward;
history_search.move_in_direction(dir); history_search.move_in_direction(dir);
@@ -2863,7 +2863,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_BACKWARD_CHAR: { case rl::backward_char: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
if (is_navigating_pager_contents()) { if (is_navigating_pager_contents()) {
select_completion_in_direction(direction_west); select_completion_in_direction(direction_west);
@@ -2873,7 +2873,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_FORWARD_CHAR: { case rl::forward_char: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
if (is_navigating_pager_contents()) { if (is_navigating_pager_contents()) {
select_completion_in_direction(direction_east); select_completion_in_direction(direction_east);
@@ -2885,42 +2885,42 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_BACKWARD_KILL_WORD: case rl::backward_kill_word:
case rl::R_BACKWARD_KILL_PATH_COMPONENT: case rl::backward_kill_path_component:
case rl::R_BACKWARD_KILL_BIGWORD: { case rl::backward_kill_bigword: {
move_word_style_t style = move_word_style_t style =
(c == rl::R_BACKWARD_KILL_BIGWORD (c == rl::backward_kill_bigword
? move_word_style_whitespace ? move_word_style_whitespace
: c == rl::R_BACKWARD_KILL_PATH_COMPONENT ? move_word_style_path_components : c == rl::backward_kill_path_component ? move_word_style_path_components
: move_word_style_punctuation); : move_word_style_punctuation);
// Is this the same killring item as the last kill? // Is this the same killring item as the last kill?
bool newv = (rls.last_cmd != rl::R_BACKWARD_KILL_WORD && bool newv = (rls.last_cmd != rl::backward_kill_word &&
rls.last_cmd != rl::R_BACKWARD_KILL_PATH_COMPONENT && rls.last_cmd != rl::backward_kill_path_component &&
rls.last_cmd != rl::R_BACKWARD_KILL_BIGWORD); rls.last_cmd != rl::backward_kill_bigword);
move_word(active_edit_line(), MOVE_DIR_LEFT, true /* erase */, style, newv); move_word(active_edit_line(), MOVE_DIR_LEFT, true /* erase */, style, newv);
break; break;
} }
case rl::R_KILL_WORD: case rl::kill_word:
case rl::R_KILL_BIGWORD: { case rl::kill_bigword: {
// The "bigword" functions differ only in that they move to the next whitespace, not // The "bigword" functions differ only in that they move to the next whitespace, not
// punctuation. // punctuation.
auto move_style = auto move_style =
(c == rl::R_KILL_WORD) ? move_word_style_punctuation : move_word_style_whitespace; (c == rl::kill_word) ? move_word_style_punctuation : move_word_style_whitespace;
move_word(active_edit_line(), MOVE_DIR_RIGHT, true /* erase */, move_style, move_word(active_edit_line(), MOVE_DIR_RIGHT, true /* erase */, move_style,
rls.last_cmd != c /* same kill item if same movement */); rls.last_cmd != c /* same kill item if same movement */);
break; break;
} }
case rl::R_BACKWARD_WORD: case rl::backward_word:
case rl::R_BACKWARD_BIGWORD: { case rl::backward_bigword: {
auto move_style = (c == rl::R_BACKWARD_WORD) ? move_word_style_punctuation auto move_style = (c == rl::backward_word) ? move_word_style_punctuation
: move_word_style_whitespace; : move_word_style_whitespace;
move_word(active_edit_line(), MOVE_DIR_LEFT, false /* do not erase */, move_style, move_word(active_edit_line(), MOVE_DIR_LEFT, false /* do not erase */, move_style,
false); false);
break; break;
} }
case rl::R_FORWARD_WORD: case rl::forward_word:
case rl::R_FORWARD_BIGWORD: { case rl::forward_bigword: {
auto move_style = (c == rl::R_FORWARD_WORD) ? move_word_style_punctuation auto move_style = (c == rl::forward_word) ? move_word_style_punctuation
: move_word_style_whitespace; : move_word_style_whitespace;
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
if (el->position < el->size()) { if (el->position < el->size()) {
@@ -2930,9 +2930,9 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_BEGINNING_OF_HISTORY: case rl::beginning_of_history:
case rl::R_END_OF_HISTORY: { case rl::end_of_history: {
bool up = (c == rl::R_BEGINNING_OF_HISTORY); bool up = (c == rl::beginning_of_history);
if (is_navigating_pager_contents()) { if (is_navigating_pager_contents()) {
select_completion_in_direction(up ? direction_page_north : direction_page_south); select_completion_in_direction(up ? direction_page_north : direction_page_south);
} else { } else {
@@ -2945,12 +2945,12 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_UP_LINE: case rl::up_line:
case rl::R_DOWN_LINE: { case rl::down_line: {
if (is_navigating_pager_contents()) { if (is_navigating_pager_contents()) {
// We are already navigating pager contents. // We are already navigating pager contents.
selection_direction_t direction; selection_direction_t direction;
if (c == rl::R_DOWN_LINE) { if (c == rl::down_line) {
// Down arrow is always south. // Down arrow is always south.
direction = direction_south; direction = direction_south;
} else if (selection_is_at_top()) { } else if (selection_is_at_top()) {
@@ -2965,7 +2965,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
select_completion_in_direction(direction); select_completion_in_direction(direction);
} else if (!pager.empty()) { } else if (!pager.empty()) {
// We pressed a direction with a non-empty pager, begin navigation. // We pressed a direction with a non-empty pager, begin navigation.
select_completion_in_direction(c == rl::R_DOWN_LINE ? direction_south select_completion_in_direction(c == rl::down_line ? direction_south
: direction_north); : direction_north);
} else { } else {
// Not navigating the pager contents. // Not navigating the pager contents.
@@ -2973,7 +2973,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
int line_old = parse_util_get_line_from_offset(el->text, el->position); int line_old = parse_util_get_line_from_offset(el->text, el->position);
int line_new; int line_new;
if (c == rl::R_UP_LINE) if (c == rl::up_line)
line_new = line_old - 1; line_new = line_old - 1;
else else
line_new = line_old + 1; line_new = line_old + 1;
@@ -3007,17 +3007,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_SUPPRESS_AUTOSUGGESTION: { case rl::suppress_autosuggestion: {
suppress_autosuggestion = true; suppress_autosuggestion = true;
autosuggestion.clear(); autosuggestion.clear();
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_ACCEPT_AUTOSUGGESTION: { case rl::accept_autosuggestion: {
accept_autosuggestion(true); accept_autosuggestion(true);
break; break;
} }
case rl::R_TRANSPOSE_CHARS: { case rl::transpose_chars: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
if (el->size() < 2) { if (el->size() < 2) {
break; break;
@@ -3037,7 +3037,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_TRANSPOSE_WORDS: { case rl::transpose_words: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
size_t len = el->size(); size_t len = el->size();
const wchar_t *buff = el->text.c_str(); const wchar_t *buff = el->text.c_str();
@@ -3077,9 +3077,9 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
break; break;
} }
case rl::R_UPCASE_WORD: case rl::upcase_word:
case rl::R_DOWNCASE_WORD: case rl::downcase_word:
case rl::R_CAPITALIZE_WORD: { case rl::capitalize_word: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
// For capitalize_word, whether we've capitalized a character so far. // For capitalize_word, whether we've capitalized a character so far.
bool capitalized_first = false; bool capitalized_first = false;
@@ -3093,10 +3093,10 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
// We always change the case; this decides whether we go uppercase (true) or // We always change the case; this decides whether we go uppercase (true) or
// lowercase (false). // lowercase (false).
bool make_uppercase; bool make_uppercase;
if (c == rl::R_CAPITALIZE_WORD) if (c == rl::capitalize_word)
make_uppercase = !capitalized_first && iswalnum(chr); make_uppercase = !capitalized_first && iswalnum(chr);
else else
make_uppercase = (c == rl::R_UPCASE_WORD); make_uppercase = (c == rl::upcase_word);
// Apply the operation and then record what we did. // Apply the operation and then record what we did.
if (make_uppercase) if (make_uppercase)
@@ -3112,11 +3112,11 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_BEGIN_SELECTION: case rl::begin_selection:
case rl::R_END_SELECTION: { case rl::end_selection: {
sel_start_pos = command_line.position; sel_start_pos = command_line.position;
sel_stop_pos = command_line.position; sel_stop_pos = command_line.position;
if (c == rl::R_BEGIN_SELECTION) { if (c == rl::begin_selection) {
sel_active = true; sel_active = true;
sel_begin_pos = command_line.position; sel_begin_pos = command_line.position;
} else { } else {
@@ -3125,7 +3125,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
break; break;
} }
case rl::R_SWAP_SELECTION_START_STOP: { case rl::swap_selection_start_stop: {
if (!sel_active) break; if (!sel_active) break;
size_t tmp = sel_begin_pos; size_t tmp = sel_begin_pos;
sel_begin_pos = command_line.position; sel_begin_pos = command_line.position;
@@ -3134,22 +3134,22 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
update_buff_pos(el, tmp); update_buff_pos(el, tmp);
break; break;
} }
case rl::R_KILL_SELECTION: { case rl::kill_selection: {
bool newv = (rls.last_cmd != rl::R_KILL_SELECTION); bool newv = (rls.last_cmd != rl::kill_selection);
size_t start, len; size_t start, len;
if (reader_get_selection(&start, &len)) { if (reader_get_selection(&start, &len)) {
kill(&command_line, start, len, KILL_APPEND, newv); kill(&command_line, start, len, KILL_APPEND, newv);
} }
break; break;
} }
case rl::R_FORWARD_JUMP: case rl::forward_jump:
case rl::R_BACKWARD_JUMP: case rl::backward_jump:
case rl::R_FORWARD_JUMP_TILL: case rl::forward_jump_till:
case rl::R_BACKWARD_JUMP_TILL: { case rl::backward_jump_till: {
auto direction = (c == rl::R_FORWARD_JUMP || c == rl::R_FORWARD_JUMP_TILL) auto direction = (c == rl::forward_jump || c == rl::forward_jump_till)
? jump_direction_t::forward ? jump_direction_t::forward
: jump_direction_t::backward; : jump_direction_t::backward;
auto precision = (c == rl::R_FORWARD_JUMP || c == rl::R_BACKWARD_JUMP) auto precision = (c == rl::forward_jump || c == rl::backward_jump)
? jump_precision_t::to ? jump_precision_t::to
: jump_precision_t::till; : jump_precision_t::till;
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
@@ -3160,7 +3160,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_REPEAT_JUMP: { case rl::repeat_jump: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
bool success = false; bool success = false;
@@ -3172,7 +3172,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
reader_repaint_needed(); reader_repaint_needed();
break; break;
} }
case rl::R_REVERSE_REPEAT_JUMP: { case rl::reverse_repeat_jump: {
editable_line_t *el = active_edit_line(); editable_line_t *el = active_edit_line();
bool success = false; bool success = false;
jump_direction_t original_dir, dir; jump_direction_t original_dir, dir;
@@ -3196,14 +3196,14 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
} }
// Some commands should have been handled internally by input_readch(). // Some commands should have been handled internally by input_readch().
case rl::R_SELF_INSERT: { case rl::self_insert: {
DIE("self-insert should have been handled by input_readch"); DIE("self-insert should have been handled by input_readch");
} }
case rl::R_AND: { case rl::func_and: {
DIE("self-insert should have been handled by input_readch"); DIE("self-insert should have been handled by input_readch");
} }
case rl::R_VI_ARG_DIGIT: case rl::vi_arg_digit:
case rl::R_VI_DELETE_TO: { case rl::vi_delete_to: {
// TODO: what needs to happen with these? // TODO: what needs to happen with these?
break; break;
} }
@@ -3278,16 +3278,16 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
assert((event_needing_handling->is_char() || event_needing_handling->is_readline()) && assert((event_needing_handling->is_char() || event_needing_handling->is_readline()) &&
"Should have a char or readline"); "Should have a char or readline");
if (rls.last_cmd != rl::R_YANK && rls.last_cmd != rl::R_YANK_POP) { if (rls.last_cmd != rl::yank && rls.last_cmd != rl::yank_POP) {
rls.yank_len = 0; rls.yank_len = 0;
} }
if (event_needing_handling->is_readline()) { if (event_needing_handling->is_readline()) {
readline_cmd_t readline_cmd = event_needing_handling->get_readline(); readline_cmd_t readline_cmd = event_needing_handling->get_readline();
// If we get something other than a repaint, then stop coalescing them. // If we get something other than a repaint, then stop coalescing them.
if (readline_cmd != rl::R_REPAINT) rls.coalescing_repaints = false; if (readline_cmd != rl::repaint) rls.coalescing_repaints = false;
if (readline_cmd == rl::R_CANCEL && is_navigating_pager_contents()) { if (readline_cmd == rl::cancel && is_navigating_pager_contents()) {
set_command_line_and_position(&command_line, cycle_command_line, cycle_cursor_pos); set_command_line_and_position(&command_line, cycle_command_line, cycle_cursor_pos);
} }