diff --git a/src/global.c b/src/global.c index 69c6647..a99ba09 100644 --- a/src/global.c +++ b/src/global.c @@ -446,6 +446,19 @@ void assign_keyinfo(sc *s, const char *keystring) s->keycode = KEY_HOME; else if (!strcasecmp(keystring, "End")) s->keycode = KEY_END; + +#ifndef NANO_TINY + /* Handle some special combinations, where combination is more than + * a pair of characters. */ + if (!strcasecmp(keystring, "^Left")) + s->keycode = controlleft; + if (!strcasecmp(keystring, "^Right")) + s->keycode = controlright; + if (!strcasecmp(keystring, "^Up")) + s->keycode = controlup; + if (!strcasecmp(keystring, "^Down")) + s->keycode = controldown; +#endif } #ifdef DEBUG diff --git a/src/nano.c b/src/nano.c index 6e55f49..40ea409 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2251,6 +2251,37 @@ int main(int argc, char **argv) #endif } + /* Initialize curses mode. If this fails, get out. */ + if (initscr() == NULL) + exit(1); + + /* Initialize all the windows based on the current screen + * dimensions. */ + window_init(); + + +#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED) + const char *keyvalue; + /* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */ + keyvalue = tigetstr("kLFT5"); + if (keyvalue != 0 && keyvalue != (char *)-1) + controlleft = key_defined(keyvalue); + keyvalue = tigetstr("kRIT5"); + if (keyvalue != 0 && keyvalue != (char *)-1) + controlright = key_defined(keyvalue); + keyvalue = tigetstr("kUP5"); + if (keyvalue != 0 && keyvalue != (char *)-1) + controlup = key_defined(keyvalue); + keyvalue = tigetstr("kDN5"); + if (keyvalue != 0 && keyvalue != (char *)-1) + controldown = key_defined(keyvalue); +#endif + +#ifndef USE_SLANG + /* Tell ncurses to pass the Esc key quickly. */ + set_escdelay(50); +#endif + /* Set up the function and shortcut lists. This needs to be done * before reading the rcfile, to be able to rebind/unbind keys. */ shortcut_init(); @@ -2475,10 +2506,6 @@ int main(int argc, char **argv) if (tabsize == -1) tabsize = WIDTH_OF_TAB; - /* Initialize curses mode. If this fails, get out. */ - if (initscr() == NULL) - exit(1); - /* Set up the terminal state. */ terminal_init(); @@ -2488,11 +2515,6 @@ int main(int argc, char **argv) #ifdef DEBUG fprintf(stderr, "Main: set up windows\n"); #endif - - /* Initialize all the windows based on the current screen - * dimensions. */ - window_init(); - /* Set up the signal handlers. */ signal_init(); @@ -2510,28 +2532,6 @@ int main(int argc, char **argv) interface_color_pair[FUNCTION_TAG] = A_NORMAL; #endif -#if !defined(NANO_TINY) && defined(HAVE_KEY_DEFINED) - const char *keyvalue; - /* Ask ncurses for the key codes for Control+Left/Right/Up/Down. */ - keyvalue = tigetstr("kLFT5"); - if (keyvalue != 0 && keyvalue != (char *)-1) - controlleft = key_defined(keyvalue); - keyvalue = tigetstr("kRIT5"); - if (keyvalue != 0 && keyvalue != (char *)-1) - controlright = key_defined(keyvalue); - keyvalue = tigetstr("kUP5"); - if (keyvalue != 0 && keyvalue != (char *)-1) - controlup = key_defined(keyvalue); - keyvalue = tigetstr("kDN5"); - if (keyvalue != 0 && keyvalue != (char *)-1) - controldown = key_defined(keyvalue); -#endif - -#ifndef USE_SLANG - /* Tell ncurses to pass the Esc key quickly. */ - set_escdelay(50); -#endif - #ifdef DEBUG fprintf(stderr, "Main: open file\n"); #endif diff --git a/src/winio.c b/src/winio.c index bcfb8a2..607b885 100644 --- a/src/winio.c +++ b/src/winio.c @@ -396,14 +396,6 @@ int parse_kbinput(WINDOW *win) case 'B': retval = KEY_END; break; -#ifndef NANO_TINY - case 'C': - retval = controlright; - break; - case 'D': - retval = controlleft; - break; -#endif } double_esc = FALSE; escapes = 0; @@ -493,17 +485,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 ||