From 24ebd3c309c5d6cad63bbf1b40de8c17aead0366 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Feb 2025 23:06:02 +0100 Subject: Add state marshalling and unmarshalling functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'common.h') diff --git a/common.h b/common.h index ba96f50..a1c385f 100644 --- a/common.h +++ b/common.h @@ -16,6 +16,19 @@ #endif +/** + * Mark that there is no input available or pending + * + * @param INPUT_OUT:union libterminput_input *input The input output + */ +#define NOTHING(INPUT_OUT)\ + do {\ + union libterminput_input *input__ = (INPUT_OUT);\ + input__->type = LIBTERMINPUT_NONE;\ + input__->keypress.key = LIBTERMINPUT_SYMBOL;\ + } while (0); + + /** * Singlar read symbol */ @@ -130,5 +143,15 @@ HIDDEN void libterminput_parse_sequence__(union libterminput_input *input, struc */ HIDDEN int libterminput_read_symbol__(int fd, struct input *input, struct libterminput_state *ctx); +/* TODO doc, test */ +HIDDEN int libterminput_marshal_keypress__(struct libterminput_marshaller *how, const struct libterminput_keypress *what); +HIDDEN int libterminput_marshal_text__(struct libterminput_marshaller *how, const struct libterminput_text *what); +HIDDEN int libterminput_marshal_mouseevent__(struct libterminput_marshaller *how, const struct libterminput_mouseevent *what); +HIDDEN int libterminput_marshal_position__(struct libterminput_marshaller *how, const struct libterminput_position *what); +HIDDEN int libterminput_unmarshal_keypress__(struct libterminput_unmarshaller *how, struct libterminput_keypress *what); +HIDDEN int libterminput_unmarshal_text__(struct libterminput_unmarshaller *how, struct libterminput_text *what); +HIDDEN int libterminput_unmarshal_mouseevent__(struct libterminput_unmarshaller *how, struct libterminput_mouseevent *what); +HIDDEN int libterminput_unmarshal_position__(struct libterminput_unmarshaller *how, struct libterminput_position *what); + #undef HIDDEN -- cgit v1.2.3-70-g09d2