diff options
author | Mattias Andrée <m@maandree.se> | 2025-02-19 23:06:02 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-02-19 23:06:02 +0100 |
commit | 24ebd3c309c5d6cad63bbf1b40de8c17aead0366 (patch) | |
tree | 7deab3ddadf241ccfaefc31e65916b6036689285 /libterminput_unmarshal_input.c | |
parent | Add tests for new escape sequences (diff) | |
download | libterminput-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 '')
-rw-r--r-- | libterminput_unmarshal_input.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libterminput_unmarshal_input.c b/libterminput_unmarshal_input.c new file mode 100644 index 0000000..ef8606c --- /dev/null +++ b/libterminput_unmarshal_input.c @@ -0,0 +1,30 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +int +libterminput_unmarshal_input(struct libterminput_unmarshaller *how, union libterminput_input *what) /* TODO test */ +{ + enum libterminput_type type; + int r; + if (how->load(how, &what->type, sizeof(what->type))) + return -1; + type = what->type; + if (what->type == LIBTERMINPUT_NONE) { + what->keypress.key = LIBTERMINPUT_SYMBOL; + if (how->load(how, &what->type, sizeof(what->type))) + return -1; + } + if (what->type == LIBTERMINPUT_KEYPRESS) + r = libterminput_unmarshal_keypress__(how, &what->keypress); + else if (what->type == LIBTERMINPUT_TEXT) + r = libterminput_unmarshal_text__(how, &what->text); + else if (what->type == LIBTERMINPUT_MOUSEEVENT) + r = libterminput_unmarshal_mouseevent__(how, &what->mouseevent); + else if (what->type == LIBTERMINPUT_CURSOR_POSITION) + r = libterminput_unmarshal_position__(how, &what->position); + else + r = 0; + what->type = type; + return r; +} |