reader: Add delete-or-exit bind function
This is an important binding and should therefore be in C++.
This commit is contained in:
parent
c392a05db0
commit
d415350aaf
@ -132,6 +132,7 @@ static const input_function_metadata_t input_function_metadata[] = {
|
||||
{readline_cmd_t::reverse_repeat_jump, L"repeat-jump-reverse"},
|
||||
{readline_cmd_t::func_and, L"and"},
|
||||
{readline_cmd_t::expand_abbr, L"expand-abbr"},
|
||||
{readline_cmd_t::delete_or_exit, L"delete-or-exit"},
|
||||
{readline_cmd_t::cancel, L"cancel"}};
|
||||
|
||||
static_assert(sizeof(input_function_metadata) / sizeof(input_function_metadata[0]) ==
|
||||
|
@ -66,6 +66,7 @@ enum class readline_cmd_t {
|
||||
backward_jump_till,
|
||||
func_and,
|
||||
expand_abbr,
|
||||
delete_or_exit,
|
||||
cancel,
|
||||
repeat_jump,
|
||||
// NOTE: This one has to be last.
|
||||
|
@ -1010,6 +1010,7 @@ static bool command_ends_paging(readline_cmd_t c, bool focused_on_search_field)
|
||||
case rl::history_token_search_backward:
|
||||
case rl::history_token_search_forward:
|
||||
case rl::accept_autosuggestion:
|
||||
case rl::delete_or_exit:
|
||||
case rl::cancel: {
|
||||
// These commands always end paging.
|
||||
return true;
|
||||
@ -2456,6 +2457,17 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
||||
reader_repaint_needed();
|
||||
break;
|
||||
}
|
||||
case rl::delete_or_exit: {
|
||||
if (!command_line.text.empty()) {
|
||||
command_line.position = 0;
|
||||
command_line.text = L"";
|
||||
update_buff_pos(&command_line, 0);
|
||||
reader_repaint_needed();
|
||||
} else {
|
||||
reader_set_end_loop(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rl::cancel: {
|
||||
// The only thing we can cancel right now is paging, which we handled up above.
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user