Commit 55878efe authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

binding: supply the keycode for most special keys directly

Instead of figuring them out from the string.  This is possible
because those dedicated editing keys cannot be rebound anyway.
parent 43f35fc7
Showing with 176 additions and 210 deletions
+176 -210
...@@ -318,7 +318,8 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h ...@@ -318,7 +318,8 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
} }
/* Add a key combo to the shortcut list. */ /* Add a key combo to the shortcut list. */
void add_to_sclist(int menus, const char *scstring, void (*func)(void), int toggle) void add_to_sclist(int menus, const char *scstring, const int keycode,
void (*func)(void), int toggle)
{ {
static sc *tailsc; static sc *tailsc;
#ifndef NANO_TINY #ifndef NANO_TINY
...@@ -342,7 +343,7 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg ...@@ -342,7 +343,7 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg
if (toggle) if (toggle)
s->ordinal = ++counter; s->ordinal = ++counter;
#endif #endif
assign_keyinfo(s, scstring); assign_keyinfo(s, scstring, keycode);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus); fprintf(stderr, "Setting keycode to %d for shortcut \"%s\" in menus %x\n", s->keycode, scstring, s->menus);
...@@ -402,66 +403,31 @@ functionptrtype func_from_key(int *kbinput) ...@@ -402,66 +403,31 @@ functionptrtype func_from_key(int *kbinput)
} }
/* Set the string and its corresponding keycode for the given shortcut s. */ /* Set the string and its corresponding keycode for the given shortcut s. */
void assign_keyinfo(sc *s, const char *keystring) void assign_keyinfo(sc *s, const char *keystring, const int keycode)
{ {
s->keystr = keystring; s->keystr = keystring;
s->meta = (keystring[0] == 'M'); s->meta = (keystring[0] == 'M');
assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2)); assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2));
if (keystring[0] == '^') { if (keycode)
s->keycode = keycode;
else if (keystring[0] == '^') {
if (strcasecmp(keystring, "^Space") == 0) if (strcasecmp(keystring, "^Space") == 0)
s->keycode = 0; s->keycode = 0;
else if (strcasecmp(keystring, "^Left") == 0 ||
strcasecmp(keystring, "^\xE2\x86\x90") == 0)
s->keycode = CONTROL_LEFT;
else if (strcasecmp(keystring, "^Right") == 0 ||
strcasecmp(keystring, "^\xE2\x86\x92") == 0)
s->keycode = CONTROL_RIGHT;
else if (strcasecmp(keystring, "^Up") == 0 ||
strcasecmp(keystring, "^\xE2\x86\x91") == 0)
s->keycode = CONTROL_UP;
else if (strcasecmp(keystring, "^Down") == 0 ||
strcasecmp(keystring, "^\xE2\x86\x93") == 0)
s->keycode = CONTROL_DOWN;
else else
s->keycode = keystring[1] - 64; s->keycode = keystring[1] - 64;
} else if (s->meta) { } else if (s->meta) {
s->keycode = tolower((int)keystring[2]);
if (strcasecmp(keystring, "M-Space") == 0) if (strcasecmp(keystring, "M-Space") == 0)
s->keycode = (int)' '; s->keycode = (int)' ';
else
s->keycode = tolower((int)keystring[2]);
} else if (keystring[0] == 'F') } else if (keystring[0] == 'F')
s->keycode = KEY_F0 + atoi(&keystring[1]); s->keycode = KEY_F0 + atoi(&keystring[1]);
/* Catch the strings that don't bind as easily as we'd like. */
else if (!strcasecmp(keystring, "Up"))
s->keycode = KEY_UP;
else if (!strcasecmp(keystring, "Down"))
s->keycode = KEY_DOWN;
else if (!strcasecmp(keystring, "Left"))
s->keycode = KEY_LEFT;
else if (!strcasecmp(keystring, "Right"))
s->keycode = KEY_RIGHT;
else if (!strcasecmp(keystring, "Ins")) else if (!strcasecmp(keystring, "Ins"))
s->keycode = KEY_IC; s->keycode = KEY_IC;
else if (!strcasecmp(keystring, "Del")) else if (!strcasecmp(keystring, "Del"))
s->keycode = KEY_DC; s->keycode = KEY_DC;
else if (!strcasecmp(keystring, "Bsp"))
s->keycode = KEY_BACKSPACE;
/* The Tab and Enter keys don't actually produce special codes
* but the exact integer values of ^I and ^M. Rebinding the
* latter therefore also rebinds Tab and Enter. */
else if (!strcasecmp(keystring, "Tab"))
s->keycode = TAB_CODE;
else if (!strcasecmp(keystring, "Enter"))
s->keycode = KEY_ENTER;
else if (!strcasecmp(keystring, "PgUp"))
s->keycode = KEY_PPAGE;
else if (!strcasecmp(keystring, "PgDn"))
s->keycode = KEY_NPAGE;
else if (!strcasecmp(keystring, "Home"))
s->keycode = KEY_HOME;
else if (!strcasecmp(keystring, "End"))
s->keycode = KEY_END;
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -1059,232 +1025,232 @@ void shortcut_init(void) ...@@ -1059,232 +1025,232 @@ void shortcut_init(void)
/* Start associating key combos with functions in specific menus. */ /* Start associating key combos with functions in specific menus. */
add_to_sclist(MMOST, "^G", do_help_void, 0); add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST, "F1", do_help_void, 0); add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", do_exit, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", do_exit, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "^O", do_writeout_void, 0); add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "F3", do_writeout_void, 0); add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
add_to_sclist(MMAIN, "^R", do_insertfile_void, 0); add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", do_insertfile_void, 0); add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", do_insertfile_void, 0); add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^W", do_search, 0); add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MBROWSER, "F6", do_search, 0); add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN, "^\\", do_replace, 0); add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
add_to_sclist(MMAIN, "M-R", do_replace, 0); add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMAIN, "F14", do_replace, 0); add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
add_to_sclist(MMOST, "^K", do_cut_text_void, 0); add_to_sclist(MMOST, "^K", 0, do_cut_text_void, 0);
add_to_sclist(MMOST, "F9", do_cut_text_void, 0); add_to_sclist(MMOST, "F9", 0, do_cut_text_void, 0);
add_to_sclist(MMAIN, "^U", do_uncut_text, 0); add_to_sclist(MMAIN, "^U", 0, do_uncut_text, 0);
add_to_sclist(MMAIN, "F10", do_uncut_text, 0); add_to_sclist(MMAIN, "F10", 0, do_uncut_text, 0);
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", do_justify_void, 0); add_to_sclist(MMAIN, "^J", 0, do_justify_void, 0);
add_to_sclist(MMAIN, "F4", do_justify_void, 0); add_to_sclist(MMAIN, "F4", 0, do_justify_void, 0);
#endif #endif
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
add_to_sclist(MMAIN, "^T", do_spell, 0); add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
add_to_sclist(MMAIN, "F12", do_spell, 0); add_to_sclist(MMAIN, "F12", 0, do_spell, 0);
#else #else
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
add_to_sclist(MMAIN, "^T", do_linter, 0); add_to_sclist(MMAIN, "^T", 0, do_linter, 0);
add_to_sclist(MMAIN, "F12", do_linter, 0); add_to_sclist(MMAIN, "F12", 0, do_linter, 0);
#endif #endif
#endif #endif
add_to_sclist(MMAIN, "^C", do_cursorpos_void, 0); add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0);
add_to_sclist(MMAIN, "F11", do_cursorpos_void, 0); add_to_sclist(MMAIN, "F11", 0, do_cursorpos_void, 0);
add_to_sclist(MMAIN, "^_", do_gotolinecolumn_void, 0); add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "M-G", do_gotolinecolumn_void, 0); add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "F13", do_gotolinecolumn_void, 0); add_to_sclist(MMAIN, "F13", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", do_page_up, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", do_page_up, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", do_page_up, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", do_page_down, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", do_page_down, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", do_page_down, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
add_to_sclist(MMAIN|MHELP, "M-\\", do_first_line, 0); add_to_sclist(MMAIN|MHELP, "M-\\", 0, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-|", do_first_line, 0); add_to_sclist(MMAIN|MHELP, "M-|", 0, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-/", do_last_line, 0); add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "M-?", do_last_line, 0); add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
add_to_sclist(MMAIN|MBROWSER, "M-W", do_research, 0); add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MBROWSER, "F16", do_research, 0); add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_sclist(MMAIN, "M-]", do_find_bracket, 0); add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
add_to_sclist(MMAIN, "^^", do_mark, 0); add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-A", do_mark, 0); add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
add_to_sclist(MMAIN, "F15", do_mark, 0); add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-^", do_copy_text, 0); add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-6", do_copy_text, 0); add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-}", do_indent_void, 0); add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 0);
add_to_sclist(MMAIN, "M-{", do_unindent, 0); add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
add_to_sclist(MMAIN, "M-U", do_undo, 0); add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", do_redo, 0); add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
#endif #endif
#ifdef ENABLE_COMMENT #ifdef ENABLE_COMMENT
add_to_sclist(MMAIN, "M-3", do_comment, 0); add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
#endif #endif
add_to_sclist(MMOST, "^B", do_left, 0); add_to_sclist(MMOST, "^B", 0, do_left, 0);
add_to_sclist(MMOST, "Left", do_left, 0); add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "^F", do_right, 0); add_to_sclist(MMOST, "^F", 0, do_right, 0);
add_to_sclist(MMOST, "Right", do_right, 0); add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
if (using_utf8()) { if (using_utf8()) {
add_to_sclist(MMOST, "^\xE2\x86\x90", do_prev_word_void, 0); add_to_sclist(MMOST, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MMOST, "^\xE2\x86\x92", do_next_word_void, 0); add_to_sclist(MMOST, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
} else { } else {
add_to_sclist(MMOST, "^Left", do_prev_word_void, 0); add_to_sclist(MMOST, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Right", do_next_word_void, 0); add_to_sclist(MMOST, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
} }
add_to_sclist(MMOST, "M-Space", do_prev_word_void, 0); add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Space", do_next_word_void, 0); add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "^A", do_home, 0); add_to_sclist((MMOST & ~MBROWSER), "^A", 0, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "Home", do_home, 0); add_to_sclist((MMOST & ~MBROWSER), "Home", KEY_HOME, do_home, 0);
add_to_sclist((MMOST & ~MBROWSER), "^E", do_end, 0); add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", do_end, 0); add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", do_up_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", do_up_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", do_down_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", do_down_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
if (using_utf8()) { if (using_utf8()) {
add_to_sclist(MMAIN, "^\xE2\x86\x91", do_prev_block, 0); add_to_sclist(MMAIN, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN, "^\xE2\x86\x93", do_next_block, 0); add_to_sclist(MMAIN, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
} else { } else {
add_to_sclist(MMAIN, "^Up", do_prev_block, 0); add_to_sclist(MMAIN, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN, "^Down", do_next_block, 0); add_to_sclist(MMAIN, "^Down", CONTROL_DOWN, do_next_block, 0);
} }
add_to_sclist(MMAIN, "M-7", do_prev_block, 0); add_to_sclist(MMAIN, "M-7", 0, do_prev_block, 0);
add_to_sclist(MMAIN, "M-8", do_next_block, 0); add_to_sclist(MMAIN, "M-8", 0, do_next_block, 0);
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
add_to_sclist(MMAIN, "M-(", do_para_begin_void, 0); add_to_sclist(MMAIN, "M-(", 0, do_para_begin_void, 0);
add_to_sclist(MMAIN, "M-9", do_para_begin_void, 0); add_to_sclist(MMAIN, "M-9", 0, do_para_begin_void, 0);
add_to_sclist(MMAIN, "M-)", do_para_end_void, 0); add_to_sclist(MMAIN, "M-)", 0, do_para_end_void, 0);
add_to_sclist(MMAIN, "M-0", do_para_end_void, 0); add_to_sclist(MMAIN, "M-0", 0, do_para_end_void, 0);
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_sclist(MMAIN, "M--", do_scroll_up, 0); add_to_sclist(MMAIN, "M--", 0, do_scroll_up, 0);
add_to_sclist(MMAIN, "M-_", do_scroll_up, 0); add_to_sclist(MMAIN, "M-_", 0, do_scroll_up, 0);
add_to_sclist(MMAIN, "M-+", do_scroll_down, 0); add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
add_to_sclist(MMAIN, "M-=", do_scroll_down, 0); add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
#endif #endif
#ifndef DISABLE_MULTIBUFFER #ifndef DISABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-<", switch_to_prev_buffer_void, 0); add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M-,", switch_to_prev_buffer_void, 0); add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M->", switch_to_next_buffer_void, 0); add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
add_to_sclist(MMAIN, "M-.", switch_to_next_buffer_void, 0); add_to_sclist(MMAIN, "M-.", 0, switch_to_next_buffer_void, 0);
#endif #endif
add_to_sclist(MMOST, "M-V", do_verbatim_input, 0); add_to_sclist(MMOST, "M-V", 0, do_verbatim_input, 0);
#ifndef NANO_TINY #ifndef NANO_TINY
add_to_sclist(MMAIN, "M-T", do_cut_till_eof, 0); add_to_sclist(MMAIN, "M-T", 0, do_cut_till_eof, 0);
add_to_sclist(MMAIN, "M-D", do_wordlinechar_count, 0); add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
add_to_sclist(MMAIN|MWHEREIS, "M-J", do_full_justify, 0); add_to_sclist(MMAIN|MWHEREIS, "M-J", 0, do_full_justify, 0);
#endif #endif
add_to_sclist(MMAIN|MHELP, "^L", total_refresh, 0); add_to_sclist(MMAIN|MHELP, "^L", 0, total_refresh, 0);
add_to_sclist(MMAIN, "^Z", do_suspend_void, 0); add_to_sclist(MMAIN, "^Z", 0, do_suspend_void, 0);
#ifndef NANO_TINY #ifndef NANO_TINY
/* Group of "Appearance" toggles. */ /* Group of "Appearance" toggles. */
add_to_sclist(MMAIN, "M-X", do_toggle_void, NO_HELP); add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist(MMAIN, "M-C", do_toggle_void, CONST_UPDATE); add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONST_UPDATE);
add_to_sclist(MMAIN, "M-O", do_toggle_void, MORE_SPACE); add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
add_to_sclist(MMAIN, "M-S", do_toggle_void, SMOOTH_SCROLL); add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
add_to_sclist(MMAIN, "M-$", do_toggle_void, SOFTWRAP); add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
add_to_sclist(MMAIN, "M-P", do_toggle_void, WHITESPACE_DISPLAY); add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
add_to_sclist(MMAIN, "M-Y", do_toggle_void, NO_COLOR_SYNTAX); add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_COLOR_SYNTAX);
#endif #endif
/* Group of "Editing-behavior" toggles. */ /* Group of "Editing-behavior" toggles. */
add_to_sclist(MMAIN, "M-H", do_toggle_void, SMART_HOME); add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
add_to_sclist(MMAIN, "M-I", do_toggle_void, AUTOINDENT); add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
add_to_sclist(MMAIN, "M-K", do_toggle_void, CUT_TO_END); add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_TO_END);
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
add_to_sclist(MMAIN, "M-L", do_toggle_void, NO_WRAP); add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
#endif #endif
add_to_sclist(MMAIN, "M-Q", do_toggle_void, TABS_TO_SPACES); add_to_sclist(MMAIN, "M-Q", 0, do_toggle_void, TABS_TO_SPACES);
/* Group of "Peripheral-feature" toggles. */ /* Group of "Peripheral-feature" toggles. */
add_to_sclist(MMAIN, "M-B", do_toggle_void, BACKUP_FILE); add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
#ifndef DISABLE_MULTIBUFFER #ifndef DISABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-F", do_toggle_void, MULTIBUFFER); add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
#endif #endif
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
add_to_sclist(MMAIN, "M-M", do_toggle_void, USE_MOUSE); add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
#endif #endif
add_to_sclist(MMAIN, "M-N", do_toggle_void, NO_CONVERT); add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
add_to_sclist(MMAIN, "M-Z", do_toggle_void, SUSPEND); add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
add_to_sclist(MMAIN, "^Q", xon_complaint, 0); add_to_sclist(MMAIN, "^Q", 0, xon_complaint, 0);
add_to_sclist(MMAIN, "^S", xoff_complaint, 0); add_to_sclist(MMAIN, "^S", 0, xoff_complaint, 0);
add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", do_cancel, 0); add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", 0, do_cancel, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-C", case_sens_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-R", regexp_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-B", backwards_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "^R", flip_replace_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", do_first_line, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", 0, do_first_line, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", do_last_line, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", 0, do_last_line, 0);
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", do_para_begin_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^W", 0, do_para_begin_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", do_para_end_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH, "^O", 0, do_para_end_void, 0);
#endif #endif
add_to_sclist(MWHEREIS, "^T", do_gotolinecolumn_void, 0); add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", gototext_void, 0); add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", get_history_older_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", get_history_older_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", get_history_newer_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", get_history_newer_void, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
#endif #endif
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", do_first_file, 0); add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", do_last_file, 0); add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", do_first_file, 0); add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", do_first_file, 0); add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", do_last_file, 0); add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", do_last_file, 0); add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "Home", do_first_file, 0); add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "End", do_last_file, 0); add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
add_to_sclist(MBROWSER, "^_", goto_dir_void, 0); add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "M-G", goto_dir_void, 0); add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "F13", goto_dir_void, 0); add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "^L", total_refresh, 0); add_to_sclist(MBROWSER, "^L", 0, total_refresh, 0);
#endif #endif
if (ISSET(TEMP_FILE)) if (ISSET(TEMP_FILE))
add_to_sclist(MWRITEFILE, "^Q", discard_buffer, 0); add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
add_to_sclist(MWRITEFILE, "M-D", dos_format_void, 0); add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", mac_format_void, 0); add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
if (!ISSET(RESTRICTED)) { if (!ISSET(RESTRICTED)) {
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */ /* Don't allow Appending, Prepending, nor Backups in restricted mode. */
add_to_sclist(MWRITEFILE, "M-A", append_void, 0); add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", prepend_void, 0); add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", backup_file_void, 0); add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", to_files_void, 0); add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
#endif #endif
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", flip_execute_void, 0); add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", new_buffer_void, 0); add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
} }
add_to_sclist(MHELP|MBROWSER, "^C", do_exit, 0); add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
/* Allow exiting from the file browser and the help viewer with /* Allow exiting from the file browser and the help viewer with
* the same key as they were entered. */ * the same key as they were entered. */
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER
add_to_sclist(MBROWSER, "^T", do_exit, 0); add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
#endif #endif
#ifndef DISABLE_HELP #ifndef DISABLE_HELP
add_to_sclist(MHELP, "^G", do_exit, 0); add_to_sclist(MHELP, "^G", 0, do_exit, 0);
add_to_sclist(MHELP, "Home", do_first_line, 0); add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
add_to_sclist(MHELP, "End", do_last_line, 0); add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
#endif #endif
add_to_sclist(MMOST, "^I", do_tab, 0); add_to_sclist(MMOST, "^I", 0, do_tab, 0);
add_to_sclist(MMOST, "Tab", do_tab, 0); add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
add_to_sclist(MMOST, "^M", do_enter, 0); add_to_sclist(MMOST, "^M", 0, do_enter, 0);
add_to_sclist(MMOST, "Enter", do_enter, 0); add_to_sclist(MMOST, "Enter", KEY_ENTER, do_enter, 0);
add_to_sclist(MMOST, "^D", do_delete, 0); add_to_sclist(MMOST, "^D", 0, do_delete, 0);
add_to_sclist(MMOST, "Del", do_delete, 0); add_to_sclist(MMOST, "Del", 0, do_delete, 0);
add_to_sclist(MMOST, "^H", do_backspace, 0); add_to_sclist(MMOST, "^H", 0, do_backspace, 0);
add_to_sclist(MMOST, "Bsp", do_backspace, 0); add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
#ifdef DEBUG #ifdef DEBUG
print_sclist(); print_sclist();
......
...@@ -368,7 +368,7 @@ size_t length_of_list(int menu); ...@@ -368,7 +368,7 @@ size_t length_of_list(int menu);
const sc *first_sc_for(int menu, void (*func)(void)); const sc *first_sc_for(int menu, void (*func)(void));
int sc_seq_or(void (*func)(void), int defaultval); int sc_seq_or(void (*func)(void), int defaultval);
functionptrtype func_from_key(int *kbinput); functionptrtype func_from_key(int *kbinput);
void assign_keyinfo(sc *s, const char *keystring); void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void print_sclist(void); void print_sclist(void);
void shortcut_init(void); void shortcut_init(void);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
......
...@@ -478,7 +478,7 @@ void parse_binding(char *ptr, bool dobind) ...@@ -478,7 +478,7 @@ void parse_binding(char *ptr, bool dobind)
} }
newsc->menus = menu; newsc->menus = menu;
assign_keyinfo(newsc, keycopy); assign_keyinfo(newsc, keycopy, 0);
/* Do not allow rebinding a frequent escape-sequence starter: Esc [. */ /* Do not allow rebinding a frequent escape-sequence starter: Esc [. */
if (newsc->meta && newsc->keycode == 91) { if (newsc->meta && newsc->keycode == 91) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment