blob: f943c04dcc72f8c0c9176bef58fa48d0fadcc27f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
void
libterminput_parse_csi_m_mouse_tracking__(union libterminput_input *input, struct libterminput_state *ctx,
unsigned long long int *nums, size_t nnums)
{
unsigned long long int numsbuf[3];
size_t pos;
if (nnums >= 3U) {
/* Parsing for \e[?1000;1015h output */
nums[0] -= 32ULL;
} else if (!nnums && (ctx->flags & LIBTERMINPUT_DECSET_1005)) {
/* Parsing for semi-legacy \e[?1000;1005h output */
ctx->mouse_tracking = 0;
nums = numsbuf;
pos = ctx->stored_tail;
if ((nums[0] = libterminput_utf8_decode__(ctx->stored, &ctx->stored_tail)) < 32 ||
(nums[1] = libterminput_utf8_decode__(ctx->stored, &ctx->stored_tail)) < 32 ||
(nums[2] = libterminput_utf8_decode__(ctx->stored, &ctx->stored_tail)) < 32) {
ctx->stored_tail = pos;
input->keypress.key = LIBTERMINPUT_MACRO;
return;
}
nums[0] = nums[0] - 32ULL;
nums[1] = nums[1] - 32ULL;
nums[2] = nums[2] - 32ULL;
if (ctx->stored_head == ctx->stored_tail)
ctx->stored_head = ctx->stored_tail = 0;
} else if (!nnums) {
/* Parsing output for legacy mouse tracking output */
ctx->mouse_tracking = 0;
nums = numsbuf;
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[2] = (unsigned long long int)(unsigned char)ctx->stored[ctx->stored_tail++];
nums[0] = (nums[0] - 32ULL) & 255ULL;
nums[1] = (nums[1] - 32ULL) & 255ULL;
nums[2] = (nums[2] - 32ULL) & 255ULL;
if (ctx->stored_head == ctx->stored_tail)
ctx->stored_head = ctx->stored_tail = 0;
} else {
input->type = LIBTERMINPUT_NONE;
return;
}
input->mouseevent.event = LIBTERMINPUT_PRESS;
libterminput_parse_decimal_mouse_tracking__(input, nums);
}
|