diff options
author | Mattias Andrée <maandree@kth.se> | 2021-04-09 22:47:17 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-04-09 22:47:17 +0200 |
commit | a9bc337202ac7614821958063c5cec51e16dd48c (patch) | |
tree | 6c42a4c344a853691e85df67feab575482818d39 /libterminput.h | |
parent | Add libterminput.7 (diff) | |
download | libterminput-a9bc337202ac7614821958063c5cec51e16dd48c.tar.gz libterminput-a9bc337202ac7614821958063c5cec51e16dd48c.tar.bz2 libterminput-a9bc337202ac7614821958063c5cec51e16dd48c.tar.xz |
Add libterminput_is_ready
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libterminput.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libterminput.h b/libterminput.h index 45ac2a4..0182a54 100644 --- a/libterminput.h +++ b/libterminput.h @@ -183,6 +183,16 @@ struct libterminput_state { */ int libterminput_read(int fd, union libterminput_input *input, struct libterminput_state *ctx); +inline int +libterminput_is_ready(union libterminput_input *input, struct libterminput_state *ctx) +{ + if (!ctx->inited) + return 0; + if (input->type == LIBTERMINPUT_KEYPRESS && input->keypress.times > 1) + return 1; + return ctx->stored_head > ctx->stored_tail; +} + int libterminput_set_flags(struct libterminput_state *ctx, enum libterminput_flags flags); int libterminput_clear_flags(struct libterminput_state *ctx, enum libterminput_flags flags); |