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).
master
Benno Schulenberg 2020-06-27 10:03:07 +02:00
parent 7fa6e95ce1
commit 009fb2fae6
3 changed files with 10 additions and 15 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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: