From d0d7bb75cdcb2aae692c719de41ee7f5d4736c77 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 30 Jan 2018 09:39:04 -0800 Subject: [PATCH] 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. --- CHANGELOG.md | 1 + doc_src/bind.txt | 2 ++ src/input.cpp | 1 + src/input_common.h | 1 + src/reader.cpp | 9 +++++++++ 5 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f074b791..652b84076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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). diff --git a/doc_src/bind.txt b/doc_src/bind.txt index c3ec3e367..94ee19b6d 100644 --- a/doc_src/bind.txt +++ b/doc_src/bind.txt @@ -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 diff --git a/src/input.cpp b/src/input.cpp index 4dd9c768f..9c2464509 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -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"}, diff --git a/src/input_common.h b/src/input_common.h index 896c820dc..617ff4157 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -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, diff --git a/src/reader.cpp b/src/reader.cpp index 21af60de7..a8b5282f3 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -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();