Making Ctrl+Left and Ctrl+Right work on more terminals by asking
ncurses for the keycodes. This addresses Debian bug #800681. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5434 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
72caa54020
commit
f08d79d204
|
@ -1,3 +1,8 @@
|
|||
2015-11-23 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.c (main), src/winio.c (parse_kbinput): Make Ctrl+Left and
|
||||
Ctrl+Right work on more terminals by asking ncurses for the keycodes.
|
||||
This addresses Debian bug #800681 reported by Arturo Borrero González.
|
||||
|
||||
2015-11-22 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (add_undo): Delete a condition that will never occur --
|
||||
this function is only ever called with PASTE when cutbuffer != NULL.
|
||||
|
|
|
@ -41,6 +41,11 @@ bool func_key;
|
|||
bool focusing = FALSE;
|
||||
/* Whether an update of the edit window should center the cursor. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
int controlleft = CONTROL_LEFT;
|
||||
int controlright = CONTROL_RIGHT;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
ssize_t fill = 0;
|
||||
/* The column where we will wrap lines. */
|
||||
|
|
|
@ -2712,6 +2712,14 @@ int main(int argc, char **argv)
|
|||
interface_color_pair[FUNCTION_TAG].bright = FALSE;
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(USE_SLANG)
|
||||
/* Ask ncurses for the key codes for Control+Left and Control+Right. */
|
||||
if ((int)tigetstr("kLFT5") > 0)
|
||||
controlleft = key_defined(tigetstr("kLFT5"));
|
||||
if ((int)tigetstr("kRIT5") > 0)
|
||||
controlright = key_defined(tigetstr("kRIT5"));
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Main: open file\n");
|
||||
#endif
|
||||
|
|
|
@ -548,10 +548,9 @@ 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
|
||||
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
|
||||
#define CONTROL_LEFT 0x401
|
||||
#define CONTROL_RIGHT 0x402
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* An imaginary key for when we get a SIGWINCH (window resize). */
|
||||
|
|
|
@ -35,6 +35,11 @@ extern bool meta_key;
|
|||
extern bool func_key;
|
||||
extern bool focusing;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
extern int controlleft;
|
||||
extern int controlright;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
extern ssize_t fill;
|
||||
extern ssize_t wrap_at;
|
||||
|
|
17
src/winio.c
17
src/winio.c
|
@ -634,16 +634,6 @@ int parse_kbinput(WINDOW *win)
|
|||
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;
|
||||
#ifndef NANO_TINY
|
||||
case KEY_WINCH:
|
||||
retval = KEY_WINCH;
|
||||
|
@ -651,6 +641,13 @@ int parse_kbinput(WINDOW *win)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (retval == controlleft)
|
||||
retval = sc_seq_or(do_prev_word_void, 0);
|
||||
else if (retval == controlright)
|
||||
retval = sc_seq_or(do_next_word_void, 0);
|
||||
#endif
|
||||
|
||||
/* If our result is an extended keypad value (i.e. a value
|
||||
* outside of byte range), set func_key to TRUE. */
|
||||
if (retval != ERR)
|
||||
|
|
Loading…
Reference in New Issue