summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-05-11 17:36:00 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-05-11 17:36:00 +0200
commitfb5eac4ae56a7b77475f426a0874498897ff45ec (patch)
tree3ac7ee1b4bfb47933a6bc5a7fbd38e11f95f43d5 /src
parent185e861b4975bf2e5505ac7237f6946ee4def608 (diff)
Handle some Esc-based keys from stdin (arrow keys and Alt+X for now)
Diffstat (limited to 'src')
-rw-r--r--src/keyevents.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/keyevents.c b/src/keyevents.c
index 933d887..12a8eb9 100644
--- a/src/keyevents.c
+++ b/src/keyevents.c
@@ -317,6 +317,7 @@ void feh_event_invoke_action(winwidget winwid, unsigned char action)
void feh_event_handle_stdin()
{
char stdin_buf[2];
+ static char is_esc = 0;
KeySym keysym = NoSymbol;
if (read(STDIN_FILENO, &stdin_buf, 1) == -1) {
control_via_stdin = 0;
@@ -328,17 +329,40 @@ void feh_event_handle_stdin()
}
stdin_buf[1] = '\0';
+ // escape?
+ if (stdin_buf[0] == 0x1b) {
+ is_esc = 1;
+ return;
+ }
+ if ((is_esc == 1) && (stdin_buf[0] == '[')) {
+ is_esc = 2;
+ return;
+ }
+
if (stdin_buf[0] == ' ')
keysym = XK_space;
else if (stdin_buf[0] == '\n')
keysym = XK_Return;
else if ((stdin_buf[0] == '\b') || (stdin_buf[0] == 127))
keysym = XK_BackSpace;
+ else if (is_esc == 2) {
+ if (stdin_buf[0] == 'A')
+ keysym = XK_Up;
+ else if (stdin_buf[0] == 'B')
+ keysym = XK_Down;
+ else if (stdin_buf[0] == 'C')
+ keysym = XK_Right;
+ else if (stdin_buf[0] == 'D')
+ keysym = XK_Left;
+ is_esc = 0;
+ }
else
keysym = XStringToKeysym(stdin_buf);
if (window_num)
- feh_event_handle_generic(windows[0], 0, keysym, 0);
+ feh_event_handle_generic(windows[0], is_esc * Mod1Mask, keysym, 0);
+
+ is_esc = 0;
}
void feh_event_handle_keypress(XEvent * ev)