aboutsummaryrefslogtreecommitdiffstats
path: root/libterminput.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-10 00:22:45 +0200
committerMattias Andrée <maandree@kth.se>2021-04-10 00:22:45 +0200
commita7be1b1dc5648999167321df657d5490caef6883 (patch)
treebbdca1f9205dc735350cbda9d16318d9b0171dd8 /libterminput.c
parentAdd libterminput_is_ready (diff)
downloadlibterminput-a7be1b1dc5648999167321df657d5490caef6883.tar.gz
libterminput-a7be1b1dc5648999167321df657d5490caef6883.tar.bz2
libterminput-a7be1b1dc5648999167321df657d5490caef6883.tar.xz
Add support for cursor position and device status reports
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libterminput.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/libterminput.c b/libterminput.c
index 147e756..5d6f401 100644
--- a/libterminput.c
+++ b/libterminput.c
@@ -398,9 +398,15 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
}
break;
case 'P':
- input->keypress.key = LIBTERMINPUT_F1;
- if (ctx->flags & LIBTERMINPUT_PAUSE_ON_CSI_P)
- input->keypress.key = LIBTERMINPUT_PAUSE;
+ if ((ctx->flags & LIBTERMINPUT_AWAITING_CURSOR_POSITION) && nnums == 2) {
+ input->position.type = LIBTERMINPUT_CURSOR_POSITION;
+ input->position.y = (size_t)nums[0] + (size_t)!nums[0];
+ input->position.x = (size_t)nums[1] + (size_t)!nums[1];
+ } else {
+ input->keypress.key = LIBTERMINPUT_F1;
+ if (ctx->flags & LIBTERMINPUT_PAUSE_ON_CSI_P)
+ input->keypress.key = LIBTERMINPUT_PAUSE;
+ }
break;
case 'Q': input->keypress.key = LIBTERMINPUT_F2; break;
case 'R': input->keypress.key = LIBTERMINPUT_F3; break;
@@ -460,6 +466,15 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
input->keypress.key = LIBTERMINPUT_LEFT;
input->keypress.mods |= LIBTERMINPUT_SHIFT;
break;
+ case 'n':
+ if (nnums == 1 && nums[0] == '0') {
+ input->type = LIBTERMINPUT_TERMINAL_IS_OK;
+ } else if (nnums == 1 && nums[0] == '3') {
+ input->type = LIBTERMINPUT_TERMINAL_IS_NOT_OK;
+ } else {
+ goto suppress;
+ }
+ break;
case 't':
/* Parsing output for legacy mouse highlight tracking output (\e[?1001h). */
ctx->mouse_tracking = 0;