commit 5103bfe6b8ee8a0b3d5aa12baca89471b4f9820d
parent cfd17f57229d73cacfd2f5569768994bc3d4b569
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 28 Sep 2019 12:24:54 +0200
bindings: add a dedicated keycode for <Tab> for when a region is marked
In this way the keycode cannot be unbound from the 'indent' function,
so pressing <Tab> on a marked region will always indent the region.
This fixes https://savannah.gnu.org/bugs/?56960.
Bug existed since the "tabbing" of a marked region was introduced,
in version 2.9.2, commit 09958ebd.
Diffstat:
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/global.c b/src/global.c
@@ -1146,7 +1146,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-6", 0, copy_text, 0);
add_to_sclist(MMAIN, "M-^", 0, copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
- add_to_sclist(MMAIN, "Tab", TAB_CODE, do_indent, 0);
+ add_to_sclist(MMAIN, "Tab", INDENT_KEY, do_indent, 0);
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
add_to_sclist(MMAIN, "Sh-Tab", SHIFT_TAB, do_unindent, 0);
add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
diff --git a/src/nano.h b/src/nano.h
@@ -605,6 +605,9 @@ enum
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
+/* A special keycode for when <Tab> is pressed while the mark is on. */
+#define INDENT_KEY 0x4F1
+
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
diff --git a/src/winio.c b/src/winio.c
@@ -658,12 +658,8 @@ int parse_kbinput(WINDOW *win)
#ifndef NANO_TINY
/* When <Tab> is pressed while the mark is on, do an indent. */
- if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN) {
- const keystruct *command = first_sc_for(MMAIN, do_indent);
-
- meta_key = command->meta;
- return command->keycode;
- }
+ if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN)
+ return INDENT_KEY;
#endif
switch (retval) {