From: Benno Schulenberg Date: Sun, 29 Jun 2014 20:53:00 +0000 (+0000) Subject: Making Ctrl-Left and Ctrl-Right produce special codes, X-Git-Tag: v2.3.5~24 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=09dd0a4acb6c47806a143ed4b8079fe0559660f8;p=nano.git Making Ctrl-Left and Ctrl-Right produce special codes, and mapping these codes to Prevword and Nextword. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5036 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 6a4126ba..0040fbb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2014-06-29 Benno Schulenberg * src/rcfile.c: Fix compilation with --enable-tiny --enable-nanorc. + * src/winio.c (parse_kbinput, get_escape_seq_kbinput): Make Ctrl-Left + and Ctrl-Right produce special codes, and map these codes to Prevword + and Nextword instead of reducing them to a plain Left and Right. The + codes 539 and 554 were so chosen because some terminals produce these. 2014-06-29 Mark Majeres * src/text.c (do_undo): Update the pointer to the bottom of the file diff --git a/src/nano.h b/src/nano.h index bb04dc64..b8071dca 100644 --- a/src/nano.h +++ b/src/nano.h @@ -563,6 +563,10 @@ enum #define NANO_CONTROL_7 31 #define NANO_CONTROL_8 127 +/* Codes for "modified" Arrow keys. Chosen like this because some + * terminals produce them, and they are beyond KEY_MAX of ncurses. */ +#define CONTROL_LEFT 539 +#define CONTROL_RIGHT 554 #ifndef NANO_TINY /* Extra bits for the undo function. */ diff --git a/src/winio.c b/src/winio.c index 6c9ba526..58dfe8f8 100644 --- a/src/winio.c +++ b/src/winio.c @@ -634,6 +634,16 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key) retval = ERR; break; #endif + case CONTROL_LEFT: +#ifndef NANO_TINY + retval = sc_seq_or(do_prev_word_void, 0); +#endif + break; + case CONTROL_RIGHT: +#ifndef NANO_TINY + retval = sc_seq_or(do_next_word_void, 0); +#endif + break; } /* If our result is an extended keypad value (i.e. a value @@ -709,11 +719,15 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len) * Terminal. */ case 'B': /* Esc O 1 ; 5 B == Ctrl-Down on * Terminal. */ + retval = get_escape_seq_abcd(seq[4]); + break; case 'C': /* Esc O 1 ; 5 C == Ctrl-Right on * Terminal. */ + retval = CONTROL_RIGHT; + break; case 'D': /* Esc O 1 ; 5 D == Ctrl-Left on * Terminal. */ - retval = get_escape_seq_abcd(seq[4]); + retval = CONTROL_LEFT; break; } } @@ -806,9 +820,13 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len) break; case 'a': /* Esc O a == Ctrl-Up on rxvt. */ case 'b': /* Esc O b == Ctrl-Down on rxvt. */ + retval = get_escape_seq_abcd(seq[1]); + break; case 'c': /* Esc O c == Ctrl-Right on rxvt. */ + retval = CONTROL_RIGHT; + break; case 'd': /* Esc O d == Ctrl-Left on rxvt. */ - retval = get_escape_seq_abcd(seq[1]); + retval = CONTROL_LEFT; break; case 'j': /* Esc O j == '*' on numeric keypad with * NumLock off on VT100/VT220/VT320/xterm/ @@ -896,9 +914,13 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len) switch (seq[1]) { case 'a': /* Esc o a == Ctrl-Up on Eterm. */ case 'b': /* Esc o b == Ctrl-Down on Eterm. */ + retval = get_escape_seq_abcd(seq[1]); + break; case 'c': /* Esc o c == Ctrl-Right on Eterm. */ + retval = CONTROL_RIGHT; + break; case 'd': /* Esc o d == Ctrl-Left on Eterm. */ - retval = get_escape_seq_abcd(seq[1]); + retval = CONTROL_LEFT; break; } break; @@ -968,11 +990,15 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len) * xterm. */ case 'B': /* Esc [ 1 ; 5 B == Ctrl-Down on * xterm. */ + retval = get_escape_seq_abcd(seq[4]); + break; case 'C': /* Esc [ 1 ; 5 C == Ctrl-Right on * xterm. */ + retval = CONTROL_RIGHT; + break; case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on * xterm. */ - retval = get_escape_seq_abcd(seq[4]); + retval = CONTROL_LEFT; break; } }