aboutsummaryrefslogtreecommitdiffstats
path: root/libterminput.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-10 12:56:41 +0200
committerMattias Andrée <maandree@kth.se>2021-04-10 12:56:41 +0200
commita71b4d629bf723dcb6d9e61463f50a2fe9c66601 (patch)
treefa4c23ac252ef36455885ff096bab9f4e2e3d6c4 /libterminput.c
parentFix bracketed paste support (diff)
downloadlibterminput-a71b4d629bf723dcb6d9e61463f50a2fe9c66601.tar.gz
libterminput-a71b4d629bf723dcb6d9e61463f50a2fe9c66601.tar.bz2
libterminput-a71b4d629bf723dcb6d9e61463f50a2fe9c66601.tar.xz
Add more tests and fixes
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libterminput.c')
-rw-r--r--libterminput.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libterminput.c b/libterminput.c
index 0b2b22d..960967d 100644
--- a/libterminput.c
+++ b/libterminput.c
@@ -86,7 +86,7 @@ again:
input->mods = ctx->mods | LIBTERMINPUT_CTRL;
ctx->mods = 0;
return 1;
- } else if ((c & 0xC0) == 0xC0) {
+ } else if ((c & 0xC0) == 0xC0 && c != 0xFF) {
/* Beginning of multibyte-character */
ctx->n = 0;
for (tc = c; tc & 0x80; tc <<= 1)
@@ -105,11 +105,8 @@ again:
/* 8th bit set to signify META */
c ^= 0x80;
ctx->mods |= LIBTERMINPUT_META;
- if (c == 033)
- goto single_byte;
goto again;
} else {
- single_byte:
/* Single-byte-character */
input->symbol[0] = (char)c;
input->symbol[1] = '\0';
@@ -800,7 +797,7 @@ libterminput_read(int fd, union libterminput_input *input, struct libterminput_s
}
again:
- if (!*ret.symbol) { /* TODO test */
+ if (!*ret.symbol) {
/* Incomplete input */
if (ctx->meta < 3) {
/* Up to two Meta/ESC, wait until a third or something else is read */
@@ -811,7 +808,7 @@ again:
input->type = LIBTERMINPUT_KEYPRESS;
input->keypress.key = LIBTERMINPUT_ESC;
input->keypress.times = 3;
- input->keypress.mods = ret.mods;
+ input->keypress.mods = 0;
input->keypress.symbol[0] = '\0';
ctx->meta -= 3;
} else if (*ctx->key) {
@@ -902,7 +899,7 @@ again:
/* ESC [ or ESC 0 is used as the beginning of most special keys */
strcpy(ctx->key, ret.symbol);
input->type = LIBTERMINPUT_NONE;
- } else { /* TODO test */
+ } else {
/* Character input and single-byte special keys */
input->type = LIBTERMINPUT_KEYPRESS;
input->keypress.mods = ret.mods;