diff --git a/src/global.c b/src/global.c index 69c6647..bcb13dc 100644 --- a/src/global.c +++ b/src/global.c @@ -398,6 +398,24 @@ functionptrtype func_from_key(int *kbinput) return NULL; } +/* Assigns keycode provided by ncurses to modifier key's combinations. */ +void reassign_keycode_to_modifier_keys() +{ + sc *s; + + for (s = sclist; s != NULL; s = s->next) + if (s->menus == MMAIN && s->toggle == 0 && s->meta == FALSE) { + if (!strcasecmp(s->keystr, "^Left")) + s->keycode = controlleft; + if (!strcasecmp(s->keystr, "^Right")) + s->keycode = controlright; + if (!strcasecmp(s->keystr, "^Up")) + s->keycode = controlup; + if (!strcasecmp(s->keystr, "^Down")) + s->keycode = controldown; + } +} + /* Set the string and its corresponding keycode for the given shortcut s. */ void assign_keyinfo(sc *s, const char *keystring) { @@ -1118,6 +1136,8 @@ void shortcut_init(void) #ifndef NANO_TINY add_to_sclist(MMOST, "M-Space", do_prev_word_void, 0); add_to_sclist(MMOST, "^Space", do_next_word_void, 0); + add_to_sclist(MMAIN, "^Left", do_prev_word_void, 0); + add_to_sclist(MMAIN, "^Right", do_next_word_void, 0); #endif add_to_sclist((MMOST & ~MBROWSER), "^A", do_home, 0); add_to_sclist((MMOST & ~MBROWSER), "Home", do_home, 0); @@ -1130,6 +1150,8 @@ void shortcut_init(void) #ifndef NANO_TINY add_to_sclist(MMAIN, "M-7", do_prev_block, 0); add_to_sclist(MMAIN, "M-8", do_next_block, 0); + add_to_sclist(MMAIN, "^Up", do_prev_block, 0); + add_to_sclist(MMAIN, "^Down", do_next_block, 0); #endif #ifndef DISABLE_JUSTIFY add_to_sclist(MMAIN, "M-(", do_para_begin_void, 0); diff --git a/src/nano.c b/src/nano.c index 6e55f49..43ee5c4 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2525,6 +2525,10 @@ int main(int argc, char **argv) keyvalue = tigetstr("kDN5"); if (keyvalue != 0 && keyvalue != (char *)-1) controldown = key_defined(keyvalue); + + /* Supposed to be used only once - right after initializing keypad, + * after getting values of the modifier and arrow key combinations. */ + reassign_keycode_to_modifier_keys(); #endif #ifndef USE_SLANG diff --git a/src/proto.h b/src/proto.h index 6396f37..b95ffc5 100644 --- a/src/proto.h +++ b/src/proto.h @@ -359,6 +359,7 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column); #endif /* Some functions in global.c. */ +void reassign_keycode_to_modifier_keys(); size_t length_of_list(int menu); const sc *first_sc_for(int menu, void (*func)(void)); int sc_seq_or(void (*func)(void), int defaultval); diff --git a/src/winio.c b/src/winio.c index bcfb8a2..73c1b25 100644 --- a/src/winio.c +++ b/src/winio.c @@ -493,17 +493,6 @@ int parse_kbinput(WINDOW *win) if (retval == ERR) return ERR; -#ifndef NANO_TINY - if (retval == controlleft) - return sc_seq_or(do_prev_word_void, 0); - else if (retval == controlright) - return sc_seq_or(do_next_word_void, 0); - else if (retval == controlup) - return sc_seq_or(do_prev_block, 0); - else if (retval == controldown) - return sc_seq_or(do_next_block, 0); -#endif - /* When not running under X, check for the bare arrow keys whether * the Ctrl key is being held together with them. */ if (console && (retval == KEY_UP || retval == KEY_DOWN ||