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_marshal_mouseevent__.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_marshal_mouseevent__.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libterminput_marshal_mouseevent__.c b/libterminput_marshal_mouseevent__.c new file mode 100644 index 0000000..8fe64c7 --- /dev/null +++ b/libterminput_marshal_mouseevent__.c @@ -0,0 +1,20 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +int +libterminput_marshal_mouseevent__(struct libterminput_marshaller *how, const struct libterminput_mouseevent *what) +{ + if (how->store(how, &what->event, sizeof(what->event)) || + how->store(how, &what->x, sizeof(size_t) * 2U)) + return -1; + if (what->event == LIBTERMINPUT_HIGHLIGHT_OUTSIDE) { + if (how->store(how, &what->start_x, sizeof(size_t) * 4U)) + return -1; + } else if (what->event != LIBTERMINPUT_HIGHLIGHT_INSIDE) { + if (how->store(how, &what->mods, sizeof(what->mods)) || + how->store(how, &what->button, sizeof(what->button))) + return -1; + } + return 0; +} |