aboutsummaryrefslogtreecommitdiffstats
path: root/libterminput.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-09 22:47:17 +0200
committerMattias Andrée <maandree@kth.se>2021-04-09 22:47:17 +0200
commita9bc337202ac7614821958063c5cec51e16dd48c (patch)
tree6c42a4c344a853691e85df67feab575482818d39 /libterminput.h
parentAdd libterminput.7 (diff)
downloadlibterminput-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.h10
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);