aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/input_common.h
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2015-07-26 10:20:13 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2015-07-26 10:20:13 +0800
commit3929e9de0e69666b37df87347d5ce15663e81347 (patch)
treeb2701c439c0260840ce1c68beaebf7de1178cc53 /src/input_common.h
parent793e1afa084982dac92c4fe19e50c25e326a79c2 (diff)
parentf4d1657c22c81a7720a91026f915b80d2d6aa6e8 (diff)
Merge branch 'master' into iwyu
Diffstat (limited to 'src/input_common.h')
-rw-r--r--src/input_common.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/input_common.h b/src/input_common.h
new file mode 100644
index 00000000..5ec34b39
--- /dev/null
+++ b/src/input_common.h
@@ -0,0 +1,66 @@
+/** \file input_common.h
+
+Header file for the low level input library
+
+*/
+#ifndef INPUT_COMMON_H
+#define INPUT_COMMON_H
+
+#include <stddef.h>
+
+/**
+ Use unencoded private-use keycodes for internal characters
+*/
+#define INPUT_COMMON_RESERVED 0xe000
+
+enum
+{
+ /**
+ R_NULL is sometimes returned by the input when a character was
+ requested but none could be delivered, or when an exception
+ happened.
+ */
+ R_NULL = INPUT_COMMON_RESERVED,
+ R_EOF
+}
+;
+
+/**
+ Init the library
+*/
+void input_common_init(int (*ih)());
+
+/**
+ Free memory used by the library
+*/
+void input_common_destroy();
+
+/**
+ Function used by input_readch to read bytes from stdin until enough
+ bytes have been read to convert them to a wchar_t. Conversion is
+ done using mbrtowc. If a character has previously been read and
+ then 'unread' using \c input_common_unreadch, that character is
+ returned. If timed is true, readch2 will wait at most
+ WAIT_ON_ESCAPE milliseconds for a character to be available for
+ reading before returning with the value WEOF.
+*/
+wchar_t input_common_readch(int timed);
+
+/**
+ Enqueue a character or a readline function to the queue of unread
+ characters that input_readch will return before actually reading from fd
+ 0.
+*/
+void input_common_queue_ch(wint_t ch);
+
+/**
+ Add a character or a readline function to the front of the queue of unread
+ characters. This will be the first character returned by input_readch
+ (unless this function is called more than once).
+*/
+void input_common_next_ch(wint_t ch);
+
+/** Adds a callback to be invoked at the next turn of the "event loop." The callback function will be invoked and passed arg. */
+void input_common_add_callback(void (*callback)(void *), void *arg);
+
+#endif