aboutsummaryrefslogtreecommitdiffstats
path: root/libterminput.h
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-02-19 23:06:02 +0100
committerMattias Andrée <m@maandree.se>2025-02-19 23:06:02 +0100
commit24ebd3c309c5d6cad63bbf1b40de8c17aead0366 (patch)
tree7deab3ddadf241ccfaefc31e65916b6036689285 /libterminput.h
parentAdd tests for new escape sequences (diff)
downloadlibterminput-24ebd3c309c5d6cad63bbf1b40de8c17aead0366.tar.gz
libterminput-24ebd3c309c5d6cad63bbf1b40de8c17aead0366.tar.bz2
libterminput-24ebd3c309c5d6cad63bbf1b40de8c17aead0366.tar.xz
Add state marshalling and unmarshalling functions
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libterminput.h')
-rw-r--r--libterminput.h46
1 files changed, 45 insertions, 1 deletions
diff --git a/libterminput.h b/libterminput.h
index 46d47e2..d69cb0d 100644
--- a/libterminput.h
+++ b/libterminput.h
@@ -85,6 +85,7 @@ enum libterminput_flags {
LIBTERMINPUT_MACRO_ON_BLOCK = 0x0080
};
+
/**
* Modifier keys
*
@@ -108,6 +109,7 @@ enum libterminput_mod {
LIBTERMINPUT_CTRL = 0x04
};
+
/**
* Keyboard buttons
*
@@ -178,6 +180,7 @@ enum libterminput_key {
LIBTERMINPUT_KEYPAD_ENTER
};
+
/**
* Mouse buttons
*
@@ -264,6 +267,7 @@ enum libterminput_button {
LIBTERMINPUT_XBUTTON4
};
+
/**
* Input event type
*/
@@ -316,6 +320,7 @@ enum libterminput_type {
LIBTERMINPUT_CURSOR_POSITION /* response to CSI 6 n */
};
+
/**
* Mouse event subtype
*/
@@ -346,6 +351,7 @@ enum libterminput_event {
LIBTERMINPUT_HIGHLIGHT_OUTSIDE
};
+
/**
* Keypress event
*
@@ -395,6 +401,7 @@ struct libterminput_keypress {
char symbol[7];
};
+
/**
* Text from a bracketed paste
*/
@@ -424,6 +431,7 @@ struct libterminput_text {
char bytes[512];
};
+
/**
* Mouse event
*/
@@ -498,6 +506,7 @@ struct libterminput_mouseevent {
size_t end_y;
};
+
/**
* Cursor position response
*/
@@ -522,6 +531,7 @@ struct libterminput_position {
size_t y;
};
+
/**
* Input event
*/
@@ -529,7 +539,7 @@ union libterminput_input {
/**
* Input event type, used to determine which
* other member to read
- *
+ *
* The following values have no corresponding
* member to read data from:
* `LIBTERMINPUT_NONE`,
@@ -537,6 +547,12 @@ union libterminput_input {
* `LIBTERMINPUT_BRACKETED_PASTE_END`,
* `LIBTERMINPUT_TERMINAL_IS_OK`,
* `LIBTERMINPUT_TERMINAL_IS_NOT_OK`
+ *
+ * Internal comment:
+ * When `.type == LIBTERMINPUT_NONE`, `.keypress.key`
+ * is normally set to `LIBTERMINPUT_SYMBOL`, however
+ * if it is set to anything else, there is a queued
+ * keypress
*/
enum libterminput_type type;
@@ -590,6 +606,28 @@ struct libterminput_state {
};
+/* TODO doc */
+struct libterminput_marshaller {
+ int (*store)(struct libterminput_marshaller *this, const void *data, size_t size);
+ union {
+ void *ptr;
+ int i;
+ size_t zu;
+ } user;
+};
+
+
+/* TODO doc */
+struct libterminput_unmarshaller {
+ int (*load)(struct libterminput_unmarshaller *this, void *data, size_t size);
+ union {
+ void *ptr;
+ int i;
+ size_t zu;
+ } user;
+};
+
+
/**
* Get input from the terminal
*
@@ -652,5 +690,11 @@ int libterminput_set_flags(struct libterminput_state *ctx, enum libterminput_fla
*/
int libterminput_clear_flags(struct libterminput_state *ctx, enum libterminput_flags flags);
+/* TODO doc, man */
+int libterminput_marshal_input(struct libterminput_marshaller *how, const union libterminput_input *what);
+int libterminput_marshal_state(struct libterminput_marshaller *how, const struct libterminput_state *what);
+int libterminput_unmarshal_input(struct libterminput_unmarshaller *how, union libterminput_input *what);
+int libterminput_unmarshal_state(struct libterminput_unmarshaller *how, struct libterminput_state *what);
+
#endif