aboutsummaryrefslogtreecommitdiffstats
path: root/libterminput.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-09 20:02:37 +0200
committerMattias Andrée <maandree@kth.se>2021-04-09 20:02:37 +0200
commitf86c044e3e42669154e3aad79a3b0a1295128328 (patch)
tree25b3238f94186a442e55e3913a6fac4631d72cef /libterminput.c
parentAdd flags for some incompatible input (diff)
downloadlibterminput-f86c044e3e42669154e3aad79a3b0a1295128328.tar.gz
libterminput-f86c044e3e42669154e3aad79a3b0a1295128328.tar.bz2
libterminput-f86c044e3e42669154e3aad79a3b0a1295128328.tar.xz
Add LIBTERMINPUT_SEPARATE_BACKTAB and LIBTERMINPUT_ESC_ON_BLOCK
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libterminput.c')
-rw-r--r--libterminput.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/libterminput.c b/libterminput.c
index 95a4e03..7ca36de 100644
--- a/libterminput.c
+++ b/libterminput.c
@@ -63,7 +63,14 @@ again:
}
}
} else if (c == 033 && !*ctx->key) {
- /* ESC at the beginning, save as a Meta/ESC */
+ /* ESC at the beginning, save as a Meta/ESC (for default behaviour) */
+ if ((ctx->flags & LIBTERMINPUT_ESC_ON_BLOCK) && ctx->stored_tail == ctx->stored_head) {
+ input->symbol[0] = (char)c;
+ input->symbol[1] = '\0';
+ input->mods = ctx->mods;
+ ctx->mods = 0;
+ return 1;
+ }
ctx->meta += 1;
} else if (c == 0) {
/* CTRL on Space */
@@ -430,8 +437,12 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
case 'U': input->keypress.key = LIBTERMINPUT_NEXT; break;
case 'V': input->keypress.key = LIBTERMINPUT_PRIOR; break;
case 'Z':
- input->keypress.key = LIBTERMINPUT_TAB;
- input->keypress.mods |= LIBTERMINPUT_SHIFT;
+ if (!(ctx->flags & LIBTERMINPUT_SEPARATE_BACKTAB)) {
+ input->keypress.key = LIBTERMINPUT_TAB;
+ input->keypress.mods |= LIBTERMINPUT_SHIFT;
+ } else {
+ input->keypress.key = LIBTERMINPUT_BACKTAB;
+ }
break;
case 'a':
input->keypress.key = LIBTERMINPUT_UP;
@@ -847,6 +858,10 @@ again:
input->keypress.key = LIBTERMINPUT_ENTER;
input->keypress.symbol[0] = '\0';
break;
+ case 033:
+ input->keypress.key = LIBTERMINPUT_ESC;
+ input->keypress.symbol[0] = '\0';
+ break;
default:
input->keypress.key = LIBTERMINPUT_SYMBOL;
strcpy(input->keypress.symbol, ret.symbol);