From a40d93ab5a064f8f2f9696acd1b57ef3603cd2fe Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 19 Feb 2025 19:53:53 +0100 Subject: misc cleanup, fixes, and clarifications, and escape sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'common.h') diff --git a/common.h b/common.h index 05b5269..ba96f50 100644 --- a/common.h +++ b/common.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -15,8 +16,18 @@ #endif +/** + * Singlar read symbol + */ struct input { + /** + * Applied modifier keys + */ enum libterminput_mod mods; + + /** + * The read symbol; NUL-byte terminated + */ char symbol[7]; }; @@ -64,5 +75,60 @@ HIDDEN unsigned long long int libterminput_utf8_decode__(const char *s, size_t * */ HIDDEN int libterminput_read_bracketed_paste__(int fd, union libterminput_input *input, struct libterminput_state *ctx); +/** + * Parse mouse tracking event data + * + * @param input Output parameter for the parsed event + * @param nums The numbers assoicated with the event + */ +HIDDEN void libterminput_parse_decimal_mouse_tracking__(union libterminput_input *input, unsigned long long int nums[3]); + +/** + * Parse a CSI M mouse tracking event + * + * @param input Output parameter for the parsed event + * @param ctx State for the terminal, parts of the state may be stored in `input` + * @param nums Numbers insert reported for the event (between CSI and M) + * @param nnums Number of elements in `nums` + */ +HIDDEN void libterminput_parse_csi_m_mouse_tracking__(union libterminput_input *input, struct libterminput_state *ctx, + unsigned long long int *nums, size_t nnums); + +/** + * Parse a CSI T mouse tracking event + * + * @param input Output parameter for the parsed event + * @param ctx State for the terminal, parts of the state may be stored in `input` + */ +HIDDEN void libterminput_parse_csi_t_mouse_tracking__(union libterminput_input *input, struct libterminput_state *ctx); + +/** + * Parse a CSI t mouse tracking event + * + * @param input Output parameter for the parsed event + * @param ctx State for the terminal, parts of the state may be stored in `input` + */ +HIDDEN void libterminput_parse_csi_small_t_mouse_tracking__(union libterminput_input *input, struct libterminput_state *ctx); + +/** + * Parse a complete, atomic input sequence out side of a bracketed paste + * + * @param input Output parameter for the parsed event + * @param ctx State for the terminal, parts of the state may be stored in `input` + */ +HIDDEN void libterminput_parse_sequence__(union libterminput_input *input, struct libterminput_state *ctx); + +/** + * Read a singular symbol from the terminal + * + * @param fd The file descriptor to the terminal + * @param input Output parameter for input + * @param ctx State for the terminal, parts of the state may be stored in `input` + * @return 1 normally, 0 on end of input, -1 on error + * + * @throws Any reason specified for read(3) + */ +HIDDEN int libterminput_read_symbol__(int fd, struct input *input, struct libterminput_state *ctx); + #undef HIDDEN -- cgit v1.2.3-70-g09d2