nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit d1957819c484c77a3bad030b9b182fa8bd95d14a
parent 7993fc8b124eeab82af4c600857bc1f373da0bf5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 24 Dec 2019 11:39:16 +0100

bindings: show either "^/" or "^-" in the help lines, instead of "^_"

The "^_" has always been poorly legible (the underscore melting into
the bottom of the terminal) and difficult to type (Shift+Ctrl+minus).
The "^/" is both more readable and easier to type.

In terminal emulators, "^/" is shown, but on a Linux console "^-",
as ^/ does a backspace in the default console key mapping.

Also, allow using "^-" when rebinding ^_ in a nanorc file.

This addresses https://savannah.gnu.org/bugs/?57393.

Diffstat:
Msrc/global.c | 14+++++++++++---
Msyntax/nanohelp.nanorc | 2+-
Msyntax/nanorc.nanorc | 4++--
3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -384,7 +384,7 @@ int keycode_from_string(const char *keystring) { if (keystring[0] == '^') { if (keystring[2] == '\0') { - if (keystring[1] == '/') + if (keystring[1] == '/' || keystring[1] == '-') return 31; if (keystring[1] <= '_') return keystring[1] - 64; @@ -1192,6 +1192,12 @@ void shortcut_init(void) N_("Next Linter message"), WITHORSANS(nextlint_gist), TOGETHER, VIEW); #endif +#ifdef __linux__ +#define SLASH_OR_DASH (on_a_vt) ? "^-" : "^/" +#else +#define SLASH_OR_DASH "^/" +#endif + /* Link key combos to functions in certain menus. */ add_to_sclist(MMOST|MBROWSER, "^M", '\r', do_enter, 0); add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0); @@ -1233,8 +1239,9 @@ void shortcut_init(void) add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0); #endif add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0); - add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0); + add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn_void, 0); add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0); + add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0); add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0); add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0); add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^V", 0, do_page_down, 0); @@ -1455,8 +1462,9 @@ void shortcut_init(void) add_to_sclist(MBROWSER, "End", KEY_END, to_last_file, 0); add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, to_first_file, 0); add_to_sclist(MBROWSER, "^End", CONTROL_END, to_last_file, 0); - add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0); + add_to_sclist(MBROWSER, SLASH_OR_DASH, 0, goto_dir, 0); add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0); + add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0); #endif if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE)) add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0); diff --git a/syntax/nanohelp.nanorc b/syntax/nanohelp.nanorc @@ -4,7 +4,7 @@ syntax nanohelp # Key combos: -color cyan "\^[]/4-8@A-Z\^_`◀▶▲▼]" "[◀▶▲▼]" "\<(M|S[Hh]-[Mm])-." "\<F([1-9]|1[0-9]|2[0-4])" +color cyan "\^[]/4-8@A-Z\^_`◀▶▲▼-]" "[◀▶▲▼]" "\<(M|S[Hh]-[Mm])-." "\<F([1-9]|1[0-9]|2[0-4])" color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>" # Quoted indicators: diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc @@ -11,8 +11,8 @@ color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure color yellow "^[[:blank:]]*set[[:blank:]]+((error|function|key|number|prompt|scroller|selected|spotlight|status|stripe|title)color)[[:blank:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>" color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+" color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>" -color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)" -color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)" +color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)" +color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)" color brightgreen "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*" color brightgreen "^[[:blank:]]*(syntax[[:blank:]]+[^[:space:]]+|(formatter|linter)[[:blank:]]+.+)" color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"