commit d8249917c38acc57c3e0f410bac760f185606459
parent 054cafa138326fba8d44e605f9828d62997e8262
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 31 May 2020 20:04:15 +0200
bindings: allow toggling the help lines at several prompts and in browser
Now the help lines can be toggled not only while editing, but also at
the Read (^R), Write (^O), Execute (^T), Search (^W), Replace (M-R),
Goto (^/), and Yesno prompts, and also in the file browser and when
searching for a file name. The help lines cannot be toggled in the
help viewer, nor when searching in a help text, nor in the linter,
as these three things force the help lines to be on.
Furthermore, the 'nohelp' function can be rebound in all relevant
menus (default binding: M-X).
This fulfills https://savannah.gnu.org/bugs/?58471.
Diffstat:
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/browser.c b/src/browser.c
@@ -169,6 +169,12 @@ char *do_browser(char *path)
#else
say_there_is_no_help();
#endif
+#ifndef NANO_TINY
+ } else if (func == do_toggle_void) {
+ TOGGLE(NO_HELP);
+ window_init();
+ kbinput = KEY_WINCH;
+#endif
} else if (func == do_search_forward) {
do_filesearch(FORWARD);
} else if (func == do_search_backward) {
diff --git a/src/global.c b/src/global.c
@@ -1345,7 +1345,7 @@ void shortcut_init(void)
#ifndef NANO_TINY
/* Group of "Appearance" toggles. */
- add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
+ add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SOFTWRAP);
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
diff --git a/src/prompt.c b/src/prompt.c
@@ -515,6 +515,14 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
#ifndef NANO_TINY
else if (func == do_nothing)
finished = FALSE;
+ else if (func == do_toggle_void) {
+ TOGGLE(NO_HELP);
+ window_init();
+ focusing = FALSE;
+ refresh_func();
+ bottombars(currmenu);
+ finished = FALSE;
+ }
#endif
/* If we have a shortcut with an associated function, break out if
@@ -741,6 +749,15 @@ int do_yesno_prompt(bool all, const char *msg)
#endif /* ENABLE_MOUSE */
else if (func_from_key(&kbinput) == full_refresh)
full_refresh();
+#ifndef NANO_TINY
+ else if (func_from_key(&kbinput) == do_toggle_void) {
+ TOGGLE(NO_HELP);
+ window_init();
+ titlebar(NULL);
+ focusing = FALSE;
+ edit_refresh();
+ }
+#endif
else
beep();
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -816,10 +816,12 @@ void parse_binding(char *ptr, bool dobind)
goto free_things;
/* Limit the given menu to those where the function exists;
- * first handle four special cases, then the general case. */
+ * first handle five special cases, then the general case. */
if (is_universal(newsc->func))
menu &= MMOST|MBROWSER;
#ifndef NANO_TINY
+ else if (newsc->func == do_toggle_void && newsc->toggle == NO_HELP)
+ menu &= (MMOST|MBROWSER|MYESNO) & ~MFINDINHELP;
else if (newsc->func == do_toggle_void)
menu &= MMAIN;
#endif