Add new pager-toggle-search input function

This adds a new input binding pager-toggle-search which toggles the
search field on and off when the pager is showing.
This commit is contained in:
ridiculousfish 2018-01-30 09:39:04 -08:00
parent f135c53196
commit d0d7bb75cd
5 changed files with 14 additions and 0 deletions

View File

@ -33,6 +33,7 @@ This section is for changes merged to the `major` branch that are not also merge
- `funced` now has a `-s` and `--save` option to automatically save the edited function after successfully editing (#4668).
- Arguments to `end` are now errors, instead of being silently ignored.
- Pager navigation has been improved. Most notably, moving down now wraps around, moving up from the commandline now jumps to the last element and moving right and left now reverse each other even when wrapping around (#4680).
- A new input binding `pager-toggle-search` toggles the search field in the completions pager on and off.
## Other significant changes
- Command substitution output is now limited to 10 MB by default (#3822).

View File

@ -120,6 +120,8 @@ The following special input functions are available:
- `kill-word`, move the next word to the killring
- `pager-toggle-search`, toggles the search field if the completions pager is visible.
- `suppress-autosuggestion`, remove the current autosuggestion
- `swap-selection-start-stop`, go to the other end of the highlighted text without changing the selection

View File

@ -84,6 +84,7 @@ static const input_function_metadata_t input_function_metadata[] = {
{R_YANK_POP, L"yank-pop"},
{R_COMPLETE, L"complete"},
{R_COMPLETE_AND_SEARCH, L"complete-and-search"},
{R_PAGER_TOGGLE_SEARCH, L"pager-toggle-search"},
{R_BEGINNING_OF_HISTORY, L"beginning-of-history"},
{R_END_OF_HISTORY, L"end-of-history"},
{R_BACKWARD_KILL_LINE, L"backward-kill-line"},

View File

@ -32,6 +32,7 @@ enum {
R_YANK_POP,
R_COMPLETE,
R_COMPLETE_AND_SEARCH,
R_PAGER_TOGGLE_SEARCH,
R_BEGINNING_OF_HISTORY,
R_END_OF_HISTORY,
R_BACKWARD_KILL_LINE,

View File

@ -2591,6 +2591,15 @@ const wchar_t *reader_readline(int nchars) {
}
break;
}
case R_PAGER_TOGGLE_SEARCH: {
if (data->is_navigating_pager_contents()) {
bool sfs = data->pager.is_search_field_shown();
data->pager.set_search_field_shown(!sfs);
data->pager.set_fully_disclosed(true);
reader_repaint_needed();
}
break;
}
case R_KILL_LINE: {
editable_line_t *el = data->active_edit_line();
const wchar_t *buff = el->text.c_str();