From 009fb2fae65b35de99cb50a6ce79d767bb2d1ec9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 27 Jun 2020 10:03:07 +0200 Subject: [PATCH] tweaks: make three hard-bindings of special keys more efficiently Instead of calling a function that tries to find the relevant operation, just add three hidden hard-bindings at the end of the shortcuts list. They are hidden because we don't want them to show up in the help text, because we don't know what to call them (as a Cancel and Suspend key don't exist on normal keyboards) or naming the key would be confusing (Sh-Ins is grabbed by the desktop manager and doesn't reach nano). --- src/global.c | 5 +++++ src/help.c | 2 +- src/winio.c | 18 ++++-------------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/global.c b/src/global.c index 66549e5a..329590a7 100644 --- a/src/global.c +++ b/src/global.c @@ -1476,6 +1476,11 @@ void shortcut_init(void) #ifdef ENABLE_SPELLER add_to_sclist(MMAIN, "F12", KEY_F(12), do_spell, 0); #endif +#if defined(KEY_CANCEL) && defined(KEY_SUSPEND) && defined(KEY_SIC) + add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0); + add_to_sclist(MMAIN|MEXECUTE, "", KEY_SUSPEND, do_suspend_void, 0); + add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile_void, 0); +#endif #ifndef NANO_TINY /* Catch and ignore bracketed paste marker keys. */ add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", BRACKETED_PASTE_MARKER, do_nothing, 0); diff --git a/src/help.c b/src/help.c index edbd5bb4..a4263add 100644 --- a/src/help.c +++ b/src/help.c @@ -512,7 +512,7 @@ void help_init(void) /* Show the first two shortcuts (if any) for each function. */ for (s = sclist; s != NULL; s = s->next) { - if ((s->menus & currmenu) && s->func == f->func) { + if ((s->menus & currmenu) && s->func == f->func && s->keystr[0]) { /* Make the first column 7 cells wide and the second 10. */ if (++tally == 1) { sprintf(ptr, "%s ", s->keystr); diff --git a/src/winio.c b/src/winio.c index c8fe28b2..21a5afb6 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1236,23 +1236,13 @@ int parse_kbinput(WINDOW *win) case KEY_SDC: return SHIFT_DELETE; #endif -#ifdef KEY_SIC /* Slang doesn't support KEY_SIC. */ - case KEY_SIC: - return the_code_for(do_insertfile_void, KEY_IC); -#endif -#ifdef KEY_CANCEL /* Slang doesn't support KEY_CANCEL. */ -#ifdef KEY_SCANCEL /* Slang doesn't support KEY_SCANCEL. */ +#if defined(KEY_CANCEL) && defined(KEY_SCANCEL) /* Slang doesn't support these. */ case KEY_SCANCEL: + return KEY_CANCEL; #endif - case KEY_CANCEL: - return the_code_for(do_cancel, 0x03); -#endif -#ifdef KEY_SUSPEND /* Slang doesn't support KEY_SUSPEND. */ -#ifdef KEY_SSUSPEND /* Slang doesn't support KEY_SSUSPEND. */ +#if defined(KEY_SUSPEND) && defined(KEY_SSUSPEND) /* Slang doesn't support these. */ case KEY_SSUSPEND: -#endif - case KEY_SUSPEND: - return the_code_for(do_suspend_void, KEY_SUSPEND); + return KEY_SUSPEND; #endif #ifdef KEY_BTAB /* Slang doesn't support KEY_BTAB. */ case KEY_BTAB: