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
master
Benno Schulenberg 2014-06-29 20:53:00 +00:00
parent 6f28d35eef
commit 09dd0a4acb
3 changed files with 40 additions and 6 deletions

View File

@ -1,5 +1,9 @@
2014-06-29 Benno Schulenberg <bensberg@justemail.net>
* 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 <mark@engine12.com>
* src/text.c (do_undo): Update the pointer to the bottom of the file

View File

@ -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. */

View File

@ -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,10 +820,14 @@ 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. */
case 'c': /* Esc O c == Ctrl-Right on rxvt. */
case 'd': /* Esc O d == Ctrl-Left 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 = CONTROL_LEFT;
break;
case 'j': /* Esc O j == '*' on numeric keypad with
* NumLock off on VT100/VT220/VT320/xterm/
* rxvt/Eterm/Terminal. */
@ -896,10 +914,14 @@ 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. */
case 'c': /* Esc o c == Ctrl-Right on Eterm. */
case 'd': /* Esc o d == Ctrl-Left 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 = CONTROL_LEFT;
break;
}
break;
case '[':
@ -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;
}
}