input: make the Ctrl+Arrow keys work on a Linux console
If this breaks your build, please send report or instructions or patch.master
parent
8edb096821
commit
290d278f68
|
@ -33,6 +33,8 @@ volatile sig_atomic_t sigwinch_counter = 0;
|
||||||
/* Is incremented by the handler whenever a SIGWINCH occurs. */
|
/* Is incremented by the handler whenever a SIGWINCH occurs. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool console;
|
||||||
|
/* Whether we're running on a Linux VC (TRUE) or under X (FALSE). */
|
||||||
bool meta_key;
|
bool meta_key;
|
||||||
/* Whether the current keystroke is a Meta key. */
|
/* Whether the current keystroke is a Meta key. */
|
||||||
bool focusing = TRUE;
|
bool focusing = TRUE;
|
||||||
|
|
|
@ -2482,6 +2482,9 @@ int main(int argc, char **argv)
|
||||||
/* Set up the terminal state. */
|
/* Set up the terminal state. */
|
||||||
terminal_init();
|
terminal_init();
|
||||||
|
|
||||||
|
/* Check whether we're running on a Linux console. */
|
||||||
|
console = (getenv("DISPLAY") == NULL);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Main: set up windows\n");
|
fprintf(stderr, "Main: set up windows\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
extern volatile sig_atomic_t sigwinch_counter;
|
extern volatile sig_atomic_t sigwinch_counter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern bool console;
|
||||||
extern bool meta_key;
|
extern bool meta_key;
|
||||||
extern bool focusing;
|
extern bool focusing;
|
||||||
|
|
||||||
|
|
20
src/winio.c
20
src/winio.c
|
@ -23,6 +23,8 @@
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -502,6 +504,24 @@ int parse_kbinput(WINDOW *win)
|
||||||
return sc_seq_or(do_next_block, 0);
|
return sc_seq_or(do_next_block, 0);
|
||||||
#endif
|
#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 ||
|
||||||
|
retval == KEY_LEFT || retval == KEY_RIGHT)) {
|
||||||
|
unsigned char modifiers = 6;
|
||||||
|
|
||||||
|
if (ioctl(0, TIOCLINUX, &modifiers) >= 0 && (modifiers & 0x04)) {
|
||||||
|
if (retval == KEY_UP)
|
||||||
|
return sc_seq_or(do_prev_block, 0);
|
||||||
|
else if (retval == KEY_DOWN)
|
||||||
|
return sc_seq_or(do_next_block, 0);
|
||||||
|
else if (retval == KEY_LEFT)
|
||||||
|
return sc_seq_or(do_prev_word_void, 0);
|
||||||
|
else
|
||||||
|
return sc_seq_or(do_next_word_void, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (retval) {
|
switch (retval) {
|
||||||
#ifdef KEY_SLEFT
|
#ifdef KEY_SLEFT
|
||||||
/* Slang doesn't support KEY_SLEFT. */
|
/* Slang doesn't support KEY_SLEFT. */
|
||||||
|
|
Loading…
Reference in New Issue