From 5103bfe6b8ee8a0b3d5aa12baca89471b4f9820d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 28 Sep 2019 12:24:54 +0200 Subject: [PATCH] bindings: add a dedicated keycode for for when a region is marked In this way the keycode cannot be unbound from the 'indent' function, so pressing 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. --- src/global.c | 2 +- src/nano.h | 3 +++ src/winio.c | 8 ++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/global.c b/src/global.c index 1360fce9..77262669 100644 --- 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 index 101729ae..bc05a19c 100644 --- 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 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 index a672e2b8..c0dd49f4 100644 --- a/src/winio.c +++ b/src/winio.c @@ -658,12 +658,8 @@ int parse_kbinput(WINDOW *win) #ifndef NANO_TINY /* When 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) {