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 --- libterminput_parse_csi_small_t_mouse_tracking__.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 libterminput_parse_csi_small_t_mouse_tracking__.c (limited to 'libterminput_parse_csi_small_t_mouse_tracking__.c') diff --git a/libterminput_parse_csi_small_t_mouse_tracking__.c b/libterminput_parse_csi_small_t_mouse_tracking__.c new file mode 100644 index 0000000..14a1cf7 --- /dev/null +++ b/libterminput_parse_csi_small_t_mouse_tracking__.c @@ -0,0 +1,24 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +void +libterminput_parse_csi_small_t_mouse_tracking__(union libterminput_input *input, struct libterminput_state *ctx) +{ + unsigned long long int nums[2]; + + /* Parsing output for legacy mouse highlight tracking output (\e[?1001h) */ + ctx->mouse_tracking = 0; + nums[0] = (unsigned long long int)(unsigned char)ctx->stored[ctx->stored_tail++]; + nums[1] = (unsigned long long int)(unsigned char)ctx->stored[ctx->stored_tail++]; + nums[0] = (nums[0] - 32ULL) & 255ULL; + nums[1] = (nums[1] - 32ULL) & 255ULL; + if (ctx->stored_head == ctx->stored_tail) + ctx->stored_head = ctx->stored_tail = 0; + input->mouseevent.type = LIBTERMINPUT_MOUSEEVENT; + input->mouseevent.event = LIBTERMINPUT_HIGHLIGHT_INSIDE; + input->mouseevent.mods = 0; + input->mouseevent.button = LIBTERMINPUT_BUTTON1; + input->mouseevent.x = (size_t)nums[0] + (size_t)!nums[0]; + input->mouseevent.y = (size_t)nums[1] + (size_t)!nums[1]; +} -- cgit v1.2.3-70-g09d2