You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

  1. From 3a94a0bb89363ef8768546973aab051cd5bf4622 Mon Sep 17 00:00:00 2001
  2. From: Benno Schulenberg <bensberg@telfort.nl>
  3. Date: Wed, 10 Nov 2021 09:20:56 +0100
  4. Subject: [PATCH] bindings: allow toggling line numbers (when enabled) also in
  5. tiny version
  6. As a special case, and because it doesn't need any feedback on the
  7. status bar nor other calls, add a special function and key binding
  8. to allow the user to flip the LINE_NUMBERS flag also in a tiny nano.
  9. This fixes https://savannah.gnu.org/bugs/?61441.
  10. Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
  11. ---
  12. src/global.c | 14 +++++++++++++-
  13. 1 file changed, 13 insertions(+), 1 deletion(-)
  14. --- a/src/global.c
  15. +++ b/src/global.c
  16. @@ -554,6 +554,14 @@ functionptrtype interpret(int *keycode)
  17. }
  18. #endif /* ENABLE_BROWSER || ENABLE_HELP */
  19. +#if defined(NANO_TINY) && defined(ENABLE_LINENUMBERS)
  20. +/* Allow toggling line numbers (when enabled) also in the tiny version. */
  21. +void toggle_numbers(void)
  22. +{
  23. + TOGGLE(LINE_NUMBERS);
  24. +}
  25. +#endif
  26. +
  27. /* These two tags are used elsewhere too, so they are global. */
  28. /* TRANSLATORS: Try to keep the next two strings at most 10 characters. */
  29. const char *exit_tag = N_("Exit");
  30. @@ -1250,9 +1258,13 @@ void shortcut_init(void)
  31. add_to_sclist(MMAIN|MBROWSER|MHELP, "M-W", 0, do_findnext, 0);
  32. add_to_sclist(MMAIN|MBROWSER|MHELP, "M-Q", 0, do_findprevious, 0);
  33. #ifdef NANO_TINY
  34. +#ifdef ENABLE_LINENUMBERS
  35. + add_to_sclist(MMAIN, "M-N", 0, toggle_numbers, 0);
  36. +#else
  37. add_to_sclist(MMAIN, "M-B", 0, to_prev_word, 0);
  38. - add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
  39. add_to_sclist(MMAIN, "M-N", 0, to_next_word, 0);
  40. +#endif
  41. + add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
  42. add_to_sclist(MMAIN, "M-F", 0, to_next_word, 0);
  43. #else
  44. add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);