[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH 2/2] bindings: add easier keystrokes for the linenum
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH 2/2] bindings: add easier keystrokes for the linenumber and softwrap toggles |
Date: |
Fri, 5 Apr 2019 12:11:36 +0200 |
For most people, M-N and M-S are simpler to type than M-# and M-$,
and more mnemonic.
---
doc/nano.texi | 12 ++++++------
src/global.c | 7 +++++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/doc/nano.texi b/doc/nano.texi
index 615fb0eb..a3dc64fb 100644
--- a/doc/nano.texi
+++ b/doc/nano.texi
@@ -648,12 +648,18 @@ The following global toggles are available:
@item Mouse Support
@kbd{Meta-M} toggles the @option{-m} (@option{--mouse}) command-line option.
address@hidden Line Numbers
address@hidden toggles the @option{-l} (@option{--linenumbers}) command-line
option.
+
@item Tabs To Spaces
@kbd{Meta-O} toggles the @option{-E} (@option{--tabstospaces}) command-line
option.
@item Whitespace Display
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
address@hidden Soft Wrapping
address@hidden toggles the @option{-$} (@option{--softwrap}) command-line
option.
+
@item Expert/No Help
@kbd{Meta-X} toggles the @option{-x} (@option{--nohelp}) command-line option.
@@ -664,12 +670,6 @@ The following global toggles are available:
@item Suspension
@kbd{Meta-Z} toggles the @option{-z} (@option{--suspend}) command-line option.
address@hidden Line Numbers
address@hidden toggles the @option{-l} (@option{--linenumbers}) command-line
option.
-
address@hidden Soft Wrapping
address@hidden toggles the @option{-$} (@option{--softwrap}) command-line
option.
-
@end table
diff --git a/src/global.c b/src/global.c
index d4de51df..7265b86a 100644
--- a/src/global.c
+++ b/src/global.c
@@ -397,7 +397,6 @@ void add_to_sclist(int menus, const char *scstring, const
int keycode,
sclist = s;
else
tailsc->next = s;
- tailsc = s;
s->next = NULL;
/* Fill in the data. */
@@ -405,11 +404,13 @@ void add_to_sclist(int menus, const char *scstring, const
int keycode,
s->func = func;
#ifndef NANO_TINY
s->toggle = toggle;
- if (toggle)
+ if (toggle && tailsc->toggle != toggle)
s->ordinal = ++counter;
#endif
assign_keyinfo(s, scstring, keycode);
+ tailsc = s;
+
#ifdef DEBUG
fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus
%x\n", s->keycode, scstring, s->menus);
#endif
@@ -1256,8 +1257,10 @@ void shortcut_init(void)
/* Group of "Appearance" toggles. */
add_to_sclist(MMAIN, "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);
#ifdef ENABLE_LINENUMBERS
+ add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, LINE_NUMBERS);
add_to_sclist(MMAIN, "M-#", 0, do_toggle_void, LINE_NUMBERS);
#endif
add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
--
2.20.1