aboutsummaryrefslogtreecommitdiffstats
path: root/fbcon.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-01-30 19:17:33 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-01-30 19:17:33 +0100
commit718d175591dc4f135dc0bbbb79d5c4ae242a14be (patch)
treeb4d191375d1d975b13bdab9b9c7064f98051dcfb /fbcon.c
parent5a77b52b4d862cd366cba06145e34349fdbdf6ce (diff)
downloadfbida-718d175591dc4f135dc0bbbb79d5c4ae242a14be.tar.gz
cursor key support
Diffstat (limited to 'fbcon.c')
-rw-r--r--fbcon.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/fbcon.c b/fbcon.c
index c2a7496..25bd2f2 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -180,6 +180,15 @@ struct color *tmt_background(struct TMTATTRS *a)
/* ---------------------------------------------------------------------- */
+const char *ansiseq[KEY_MAX] = {
+ [ KEY_UP ] = "\x1b[A",
+ [ KEY_DOWN ] = "\x1b[B",
+ [ KEY_RIGHT ] = "\x1b[C",
+ [ KEY_LEFT ] = "\x1b[D",
+};
+
+/* ---------------------------------------------------------------------- */
+
static void render(void)
{
static bool second;
@@ -373,10 +382,15 @@ int main(int argc, char *argv[])
down = libinput_event_keyboard_get_key_state(kevt);
xkb_state_update_key(state, key, down);
if (down) {
- rc = xkb_state_key_get_utf8(state, key,
- buf, sizeof(buf));
- if (rc > 0)
- write(pty, buf, rc);
+ if (ansiseq[key - 8]) {
+ write(pty, ansiseq[key - 8],
+ strlen(ansiseq[key - 8]));
+ } else {
+ rc = xkb_state_key_get_utf8(state, key,
+ buf, sizeof(buf));
+ if (rc > 0)
+ write(pty, buf, rc);
+ }
}
break;
default: