From 9023845d500cbaf6be4ce5c20794d11445c8e120 Mon Sep 17 00:00:00 2001 From: Hannu Nyman Date: Wed, 10 Nov 2021 20:25:15 +0200 Subject: [PATCH] nano: enable showing line numbers with M-N (Alt-n) Backport new upstream patch to enable toggling the display of the line numbers with the shortcut key M-N (Alt-n). Also the cmdline option "-l" works. Signed-off-by: Hannu Nyman --- ...oggling-line-numbers-when-enabled-al.patch | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 utils/nano/patches/0001-bindings-allow-toggling-line-numbers-when-enabled-al.patch diff --git a/utils/nano/patches/0001-bindings-allow-toggling-line-numbers-when-enabled-al.patch b/utils/nano/patches/0001-bindings-allow-toggling-line-numbers-when-enabled-al.patch new file mode 100644 index 0000000000..ee546c73b6 --- /dev/null +++ b/utils/nano/patches/0001-bindings-allow-toggling-line-numbers-when-enabled-al.patch @@ -0,0 +1,48 @@ +From 3a94a0bb89363ef8768546973aab051cd5bf4622 Mon Sep 17 00:00:00 2001 +From: Benno Schulenberg +Date: Wed, 10 Nov 2021 09:20:56 +0100 +Subject: [PATCH] bindings: allow toggling line numbers (when enabled) also in + tiny version + +As a special case, and because it doesn't need any feedback on the +status bar nor other calls, add a special function and key binding +to allow the user to flip the LINE_NUMBERS flag also in a tiny nano. + +This fixes https://savannah.gnu.org/bugs/?61441. +Reported-by: Hannu Nyman +--- + src/global.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +--- a/src/global.c ++++ b/src/global.c +@@ -554,6 +554,14 @@ functionptrtype interpret(int *keycode) + } + #endif /* ENABLE_BROWSER || ENABLE_HELP */ + ++#if defined(NANO_TINY) && defined(ENABLE_LINENUMBERS) ++/* Allow toggling line numbers (when enabled) also in the tiny version. */ ++void toggle_numbers(void) ++{ ++ TOGGLE(LINE_NUMBERS); ++} ++#endif ++ + /* These two tags are used elsewhere too, so they are global. */ + /* TRANSLATORS: Try to keep the next two strings at most 10 characters. */ + const char *exit_tag = N_("Exit"); +@@ -1250,9 +1258,13 @@ void shortcut_init(void) + add_to_sclist(MMAIN|MBROWSER|MHELP, "M-W", 0, do_findnext, 0); + add_to_sclist(MMAIN|MBROWSER|MHELP, "M-Q", 0, do_findprevious, 0); + #ifdef NANO_TINY ++#ifdef ENABLE_LINENUMBERS ++ add_to_sclist(MMAIN, "M-N", 0, toggle_numbers, 0); ++#else + add_to_sclist(MMAIN, "M-B", 0, to_prev_word, 0); +- add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0); + add_to_sclist(MMAIN, "M-N", 0, to_next_word, 0); ++#endif ++ add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0); + add_to_sclist(MMAIN, "M-F", 0, to_next_word, 0); + #else + add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0); -- 2.30.2