aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-04-10 19:20:30 +0200
committerMattias Andrée <maandree@kth.se>2021-04-10 19:20:30 +0200
commit0edd4e9312117009756ca6185c845a71bdd58fb9 (patch)
tree7746717657b05109cc7e1fa1b328903ee64ed6c2
parentAdd tests for mouse events (diff)
downloadlibterminput-0edd4e9312117009756ca6185c845a71bdd58fb9.tar.gz
libterminput-0edd4e9312117009756ca6185c845a71bdd58fb9.tar.bz2
libterminput-0edd4e9312117009756ca6185c845a71bdd58fb9.tar.xz
Fix mouse tracking support and add more tests for it
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--libterminput.c149
-rw-r--r--libterminput.h2
-rw-r--r--test.c344
3 files changed, 277 insertions, 218 deletions
diff --git a/libterminput.c b/libterminput.c
index 5758be0..10c85cf 100644
--- a/libterminput.c
+++ b/libterminput.c
@@ -6,7 +6,6 @@
#include <limits.h>
#include <string.h>
#include <unistd.h>
-#include <stdio.h>
struct input {
@@ -148,6 +147,7 @@ encode_utf8(unsigned long long int codepoint, char buffer[7])
static int
check_utf8_char(const char *s, size_t *lenp, size_t size)
{
+ size_t i;
*lenp = 0;
if (!size) {
return 0;
@@ -155,47 +155,25 @@ check_utf8_char(const char *s, size_t *lenp, size_t size)
*lenp = 1;
return 1;
} else if ((*s & 0xE0) == 0xC0) {
- goto need_2;
+ *lenp = 2;
} else if ((*s & 0xF0) == 0xE0) {
- goto need_3;
+ *lenp = 3;
} else if ((*s & 0xF8) == 0xF0) {
- goto need_4;
+ *lenp = 4;
} else if ((*s & 0xFC) == 0xF8) {
- goto need_5;
+ *lenp = 5;
} else if ((*s & 0xFE) == 0xFC) {
- goto need_6;
+ *lenp = 6;
} else {
*lenp = 0;
return -1;
}
-
-need_6:
- if (!size--) return 0;
- if ((s[5] & 0xC0) != 0x80) return -1;
- ++*lenp;
-
-need_5:
- if (!size--) return 0;
- if ((s[4] & 0xC0) != 0x80) return -1;
- ++*lenp;
-
-need_4:
- if (!size--) return 0;
- if ((s[3] & 0xC0) != 0x80) return -1;
- ++*lenp;
-
-need_3:
- if (!size--) return 0;
- if ((s[2] & 0xC0) != 0x80) return -1;
- ++*lenp;
-
-need_2:
- if (!size--) return 0;
- if ((s[1] & 0xC0) != 0x80) return -1;
- ++*lenp;
-
- if (!size--) return 0;
- ++*lenp;
+ for (i = 1; i < *lenp; i++) {
+ if (i == size)
+ return 0;
+ if ((s[i] & 0xC0) != 0x80)
+ return -1;
+ }
return 1;
}
@@ -210,23 +188,23 @@ utf8_decode(const char *s, size_t *ip)
return (unsigned long long int)s[(*ip)++];
} else if ((s[*ip] & 0xE0) == 0xC0) {
cp = (unsigned long long int)((unsigned char)s[(*ip)++] ^ 0xC0U);
- len = 1;
+ len = 2;
goto need_1;
} else if ((s[*ip] & 0xF0) == 0xE0) {
cp = (unsigned long long int)((unsigned char)s[(*ip)++] ^ 0xE0U);
- len = 2;
+ len = 3;
goto need_2;
} else if ((s[*ip] & 0xF8) == 0xF0) {
cp = (unsigned long long int)((unsigned char)s[(*ip)++] ^ 0xF0U);
- len = 3;
+ len = 4;
goto need_3;
} else if ((s[*ip] & 0xFC) == 0xF8) {
cp = (unsigned long long int)((unsigned char)s[(*ip)++] ^ 0xF8U);
- len = 4;
+ len = 5;
goto need_4;
} else if ((s[*ip] & 0xFE) == 0xFC) {
cp = (unsigned long long int)((unsigned char)s[(*ip)++] ^ 0xFCU);
- len = 5;
+ len = 6;
goto need_5;
}
@@ -258,17 +236,17 @@ need_1:
/* Let's ignore the 0x10FFFF upper bound. */
if (cp < 1ULL << (7 + 0 * 6))
- return len > 1 ? 0ULL : cp;
+ return 0;
if (cp < 1ULL << (5 + 1 * 6))
- return len > 1 ? 0ULL : cp;
+ return len > 2 ? 0ULL : cp;
if (cp < 1ULL << (4 + 2 * 6))
- return len > 1 ? 0ULL : cp;
+ return len > 3 ? 0ULL : cp;
if (cp < 1ULL << (3 + 3 * 6))
- return len > 1 ? 0ULL : cp;
+ return len > 4 ? 0ULL : cp;
if (cp < 1ULL << (2 + 4 * 6))
- return len > 1 ? 0ULL : cp;
+ return len > 5 ? 0ULL : cp;
if (cp < 1ULL << (1 + 5 * 6))
- return len > 1 ? 0ULL : cp;
+ return len > 6 ? 0ULL : cp;
return 0;
}
@@ -352,7 +330,7 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
}
}
input->mouseevent.button = (enum libterminput_button)nums[0];
- } else if (!nnums & !(ctx->flags & LIBTERMINPUT_DECSET_1005)) { /* TODO test */
+ } else if (!nnums & !(ctx->flags & LIBTERMINPUT_DECSET_1005)) {
/* Parsing output for legacy mouse tracking output. */
ctx->mouse_tracking = 0;
nums = numsbuf;
@@ -365,27 +343,17 @@ parse_sequence(union libterminput_input *input, struct libterminput_state *ctx)
if (ctx->stored_head == ctx->stored_tail)
ctx->stored_head = ctx->stored_tail = 0;
goto decimal_mouse_tracking_set_press;
- } else if (!nnums) { /* TODO test */
+ } else if (!nnums) {
/* Parsing for semi-legacy \e[?1000;1005h output. */
ctx->mouse_tracking = 0;
nums = numsbuf;
pos = ctx->stored_tail;
- nums[0] = utf8_decode(ctx->stored, &ctx->stored_tail);
- if (nums[0] <= 32) {
+ if ((nums[0] = utf8_decode(ctx->stored, &ctx->stored_tail)) < 32 ||
+ (nums[1] = utf8_decode(ctx->stored, &ctx->stored_tail)) < 32 ||
+ (nums[2] = utf8_decode(ctx->stored, &ctx->stored_tail)) < 32) {
ctx->stored_tail = pos;
- goto suppress;
- }
- pos = ctx->stored_tail;
- nums[1] = utf8_decode(ctx->stored, &ctx->stored_tail);
- if (nums[1] <= 32) {
- ctx->stored_tail = pos;
- goto suppress;
- }
- pos = ctx->stored_tail;
- nums[2] = utf8_decode(ctx->stored, &ctx->stored_tail);
- if (nums[2] <= 32) {
- ctx->stored_tail = pos;
- goto suppress;
+ input->keypress.key = LIBTERMINPUT_MACRO;
+ return;
}
nums[0] = nums[0] - 32ULL;
nums[1] = nums[1] - 32ULL;
@@ -838,49 +806,42 @@ again:
} else if (ctx->key[0] == '[' && ctx->key[1] == '<' && p == &ctx->key[2]) { /* TODO test */
input->type = LIBTERMINPUT_NONE;
return 1;
- } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && (ctx->flags & LIBTERMINPUT_MACRO_ON_CSI_M)) { /* TODO test */
+ } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && (ctx->flags & LIBTERMINPUT_MACRO_ON_CSI_M)) {
/* complete */
- } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && (ctx->flags & LIBTERMINPUT_DECSET_1005)) { /* TODO test */
+ } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && (ctx->flags & LIBTERMINPUT_DECSET_1005)) {
ctx->mouse_tracking = 1;
if (ctx->stored_head == ctx->stored_tail) {
input->type = LIBTERMINPUT_NONE;
return 1;
}
- n = 0;
- r = check_utf8_char(&ctx->stored[ctx->stored_tail + n], &m, ctx->stored_head - (ctx->stored_tail + n));
- n += m;
- if (!r) {
- input->type = LIBTERMINPUT_NONE;
- return 1;
- } else if (r < 0) {
- ctx->mouse_tracking = 0;
- input->type = LIBTERMINPUT_NONE;
- ctx->stored_tail += n;
- return 1;
- }
- r = check_utf8_char(&ctx->stored[ctx->stored_tail + n], &m, ctx->stored_head - (ctx->stored_tail + n));
+ n = ctx->stored_tail;
+ r = check_utf8_char(&ctx->stored[n], &m, ctx->stored_head - n);
+ if (r <= 0)
+ goto fallback_to_none_or_macro;
n += m;
- if (!r) {
- input->type = LIBTERMINPUT_NONE;
- return 1;
- } else if (r < 0) {
- ctx->mouse_tracking = 0;
- input->type = LIBTERMINPUT_NONE;
- ctx->stored_tail += n;
- return 1;
- }
- r = check_utf8_char(&ctx->stored[ctx->stored_tail + n], &m, ctx->stored_head - (ctx->stored_tail + n));
+ r = check_utf8_char(&ctx->stored[n], &m, ctx->stored_head - n);
+ if (r <= 0)
+ goto fallback_to_none_or_macro;
n += m;
- if (!r) {
- input->type = LIBTERMINPUT_NONE;
- return 1;
- } else if (r < 0) {
+ r = check_utf8_char(&ctx->stored[n], &m, ctx->stored_head - n);
+ if (r <= 0) {
+ fallback_to_none_or_macro:
+ if (!r) {
+ input->type = LIBTERMINPUT_NONE;
+ return 1;
+ }
ctx->mouse_tracking = 0;
- input->type = LIBTERMINPUT_NONE;
- ctx->stored_tail += n;
+ input->type = LIBTERMINPUT_KEYPRESS;
+ input->keypress.key = LIBTERMINPUT_MACRO;
+ input->keypress.mods = ret.mods;
+ input->keypress.times = 1;
+ if (ctx->meta > 1)
+ input->keypress.mods |= LIBTERMINPUT_META;
+ ctx->meta = 0;
+ ctx->key[0] = '\0';
return 1;
}
- } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && ctx->stored_head - ctx->stored_tail < 3) { /* TODO test */
+ } else if (ctx->key[0] == '[' && ctx->key[1] == 'M' && ctx->stored_head - ctx->stored_tail < 3) {
ctx->mouse_tracking = 3;
input->type = LIBTERMINPUT_NONE;
return 1;
diff --git a/libterminput.h b/libterminput.h
index 6029305..d5c5439 100644
--- a/libterminput.h
+++ b/libterminput.h
@@ -199,7 +199,7 @@ int libterminput_read(int fd, union libterminput_input *input, struct libterminp
inline int
libterminput_is_ready(union libterminput_input *input, struct libterminput_state *ctx)
{
- if (!ctx->inited || ctx->paused)
+ if (!ctx->inited || ctx->paused || ctx->mouse_tracking)
return 0;
if (input->type == LIBTERMINPUT_KEYPRESS && input->keypress.times > 1)
return 1;
diff --git a/test.c b/test.c
index 094dae2..7e03ab2 100644
--- a/test.c
+++ b/test.c
@@ -114,6 +114,128 @@ static const struct keynum {
{0, 0, 0, 0}
};
+static const struct mouse {
+ const char *str;
+ enum libterminput_event event;
+ enum libterminput_button button;
+ enum libterminput_mod mods;
+ int x;
+ int y;
+} mice[] = {
+ {"\033[32;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 2},
+ {"\033[33;61;19M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 61, 19},
+ {"\033[34;6115;1559M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 6115, 1559},
+ {"\033[35;0;0M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 1},
+ {"\033[36;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[37;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[38;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[39;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[40;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6},
+ {"\033[41;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META, 5, 6},
+ {"\033[42;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META, 5, 6},
+ {"\033[43;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6},
+ {"\033[44;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[45;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[46;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[47;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[48;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[49;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[50;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[51;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[52;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[53;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[54;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[55;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[56;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[57;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[58;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[59;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[64;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, 0, 5, 6},
+ {"\033[65;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, 0, 5, 6},
+ {"\033[66;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, 0, 5, 6},
+ {"\033[67;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, 0, 5, 6},
+ {"\033[68;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[69;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[70;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[71;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[96;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_UP, 0, 1, 2},
+ {"\033[97;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_DOWN, 0, 1, 2},
+ {"\033[98;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_LEFT, 0, 1, 2},
+ {"\033[99;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_RIGHT, 0, 1, 2},
+ {"\033[160;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 2},
+ {"\033[161;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, 0, 1, 2},
+ {"\033[162;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON3, 0, 1, 2},
+ {"\033[163;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON4, 0, 1, 2},
+
+ {"\033[<0;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 2},
+ {"\033[<1;61;19M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 61, 19},
+ {"\033[<2;6115;1559M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 6115, 1559},
+ {"\033[<4;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<5;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<6;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<8;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6},
+ {"\033[<9;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META, 5, 6},
+ {"\033[<10;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META, 5, 6},
+ {"\033[<12;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<13;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<14;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<16;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[<17;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[<18;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[<20;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<21;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<22;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<24;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[<25;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[<26;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[<32;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, 0, 5, 6},
+ {"\033[<33;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, 0, 5, 6},
+ {"\033[<34;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, 0, 5, 6},
+ {"\033[<35;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, 0, 5, 6},
+ {"\033[<36;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<37;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<38;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<39;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<64;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_UP, 0, 1, 2},
+ {"\033[<65;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_DOWN, 0, 1, 2},
+ {"\033[<66;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_LEFT, 0, 1, 2},
+ {"\033[<67;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_RIGHT, 0, 1, 2},
+ {"\033[<128;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 2},
+ {"\033[<129;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, 0, 1, 2},
+ {"\033[<130;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON3, 0, 1, 2},
+ {"\033[<131;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON4, 0, 1, 2},
+
+ {"\033[<0;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 2},
+ {"\033[<1;61;19m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, 0, 61, 19},
+ {"\033[<2;6115;1559m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, 0, 6115, 1559},
+ {"\033[<4;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<5;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<6;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<8;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6},
+ {"\033[<9;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META, 5, 6},
+ {"\033[<10;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META, 5, 6},
+ {"\033[<12;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<13;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<14;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<16;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[<17;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[<18;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL, 5, 6},
+ {"\033[<20;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<21;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<22;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6},
+ {"\033[<24;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[<25;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[<26;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6},
+ {"\033[<66;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_SCROLL_LEFT, 0, 1, 2},
+ {"\033[<67;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_SCROLL_RIGHT, 0, 1, 2},
+ {"\033[<128;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON1, 0, 1, 2},
+ {"\033[<129;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON2, 0, 1, 2},
+ {"\033[<130;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON3, 0, 1, 2},
+ {"\033[<131;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON4, 0, 1, 2},
+
+ {NULL, 0, 0, 0, 0, 0}
+};
+
int
main(void)
@@ -479,129 +601,105 @@ main(void)
TEST(input.keypress.times == 1);
TEST(!strcmp(input.keypress.symbol, " "));
- MOUSE("\033[32;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 2);
- MOUSE("\033[33;61;19M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 61, 19);
- MOUSE("\033[34;6115;1559M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 6115, 1559);
- MOUSE("\033[35;0;0M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 1);
- MOUSE("\033[36;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[37;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[38;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[39;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[40;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[41;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[42;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[43;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[44;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[45;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[46;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[47;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[48;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[49;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[50;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[51;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[52;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[53;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[54;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[55;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[56;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[57;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[58;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[59;5;6M", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[64;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, 0, 5, 6);
- MOUSE("\033[65;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, 0, 5, 6);
- MOUSE("\033[66;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, 0, 5, 6);
- MOUSE("\033[67;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, 0, 5, 6);
- MOUSE("\033[68;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[69;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[70;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[71;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[96;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_UP, 0, 1, 2);
- MOUSE("\033[97;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_DOWN, 0, 1, 2);
- MOUSE("\033[98;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_LEFT, 0, 1, 2);
- MOUSE("\033[99;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_RIGHT, 0, 1, 2);
- MOUSE("\033[160;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 2);
- MOUSE("\033[161;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, 0, 1, 2);
- MOUSE("\033[162;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON3, 0, 1, 2);
- MOUSE("\033[163;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON4, 0, 1, 2);
-
- MOUSE("\033[<0;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 2);
- MOUSE("\033[<1;61;19M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 61, 19);
- MOUSE("\033[<2;6115;1559M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 6115, 1559);
- MOUSE("\033[<4;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<5;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<6;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<8;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<9;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<10;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<12;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<13;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<14;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<16;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[<17;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[<18;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[<20;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<21;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<22;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<24;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<25;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<26;5;6M", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<32;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, 0, 5, 6);
- MOUSE("\033[<33;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, 0, 5, 6);
- MOUSE("\033[<34;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, 0, 5, 6);
- MOUSE("\033[<35;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, 0, 5, 6);
- MOUSE("\033[<36;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<37;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<38;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<39;5;6M", LIBTERMINPUT_MOTION, LIBTERMINPUT_NO_BUTTON, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<64;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_UP, 0, 1, 2);
- MOUSE("\033[<65;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_DOWN, 0, 1, 2);
- MOUSE("\033[<66;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_LEFT, 0, 1, 2);
- MOUSE("\033[<67;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_SCROLL_RIGHT, 0, 1, 2);
- MOUSE("\033[<128;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 2);
- MOUSE("\033[<129;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, 0, 1, 2);
- MOUSE("\033[<130;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON3, 0, 1, 2);
- MOUSE("\033[<131;1;2M", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON4, 0, 1, 2);
-
- MOUSE("\033[<0;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 2);
- MOUSE("\033[<1;61;19m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, 0, 61, 19);
- MOUSE("\033[<2;6115;1559m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, 0, 6115, 1559);
- MOUSE("\033[<4;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<5;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<6;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<8;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<9;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<10;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<12;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<13;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<14;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_META | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<16;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[<17;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[<18;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL, 5, 6);
- MOUSE("\033[<20;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<21;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<22;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_SHIFT, 5, 6);
- MOUSE("\033[<24;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<25;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON2, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<26;5;6m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON3, LIBTERMINPUT_CTRL | LIBTERMINPUT_META, 5, 6);
- MOUSE("\033[<66;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_SCROLL_LEFT, 0, 1, 2);
- MOUSE("\033[<67;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_SCROLL_RIGHT, 0, 1, 2);
- MOUSE("\033[<128;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON1, 0, 1, 2);
- MOUSE("\033[<129;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON2, 0, 1, 2);
- MOUSE("\033[<130;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON3, 0, 1, 2);
- MOUSE("\033[<131;1;2m", LIBTERMINPUT_RELEASE, LIBTERMINPUT_XBUTTON4, 0, 1, 2);
-
- MOUSE("\033[M !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 3);
- MOUSE("\033[M!#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 3, 1);
- MOUSE("\033[M\"#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 3, 1);
- MOUSE("\033[M#!#", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 3);
-#ifdef TODO
- MOUSE("\033[\x80 !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 3);
- MOUSE("\033[\x84 !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_SHIFT, 1, 3);
- MOUSE("\033[\x88 !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_META, 1, 3);
- MOUSE("\033[\x8C !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_SHIFT | LIBTERMINPUT_META, 1, 3);
- MOUSE("\033[\x90 !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_CTRL, 1, 3);
- MOUSE("\033[\x91 !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, LIBTERMINPUT_CTRL, 1, 3);
-#endif
+ for (i = 0; mice[i].str; i++)
+ MOUSE(mice[i].str, mice[i].event, mice[i].button, mice[i].mods, mice[i].x, mice[i].y);
+
+ MOUSE("\033[M !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 3);
+ MOUSE("\033[M!#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 3, 1);
+ MOUSE("\033[M\"#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 3, 1);
+ MOUSE("\033[M#!#", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 3);
+ MOUSE("\033[M\xa0!#" , LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 3);
+ MOUSE("\033[M\xa4!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_SHIFT, 1, 3);
+ MOUSE("\033[M\xa8!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_META, 1, 3);
+ MOUSE("\033[M\xac!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_SHIFT | LIBTERMINPUT_META, 1, 3);
+ MOUSE("\033[M\xb0!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_CTRL, 1, 3);
+ MOUSE("\033[M\xb1!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, LIBTERMINPUT_CTRL, 1, 3);
+ MOUSE("\033[M ", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 1);
+
+ MOUSE("\033[M\xdf\xff\xff", LIBTERMINPUT_MOTION, 11, 7, 255 - 32, 255 - 32);
+ MOUSE("\033[M\x1f\x1f\x1f", LIBTERMINPUT_MOTION, 15, 7, 255, 255);
+
+ TYPE("\033[M", LIBTERMINPUT_NONE);
+ MOUSE("!#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 3, 1);
+ TYPE("\033[M!", LIBTERMINPUT_NONE);
+ MOUSE("#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 3, 1);
+ TYPE("\033[M!#", LIBTERMINPUT_NONE);
+ MOUSE("!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 3, 1);
+
+ libterminput_set_flags(&ctx, LIBTERMINPUT_DECSET_1005);
+
+ MOUSE("\033[M !#", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 3);
+ MOUSE("\033[M!#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON2, 0, 3, 1);
+ MOUSE("\033[M\"#!", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON3, 0, 3, 1);
+ MOUSE("\033[M#!#", LIBTERMINPUT_RELEASE, LIBTERMINPUT_BUTTON1, 0, 1, 3);
+ MOUSE("\033[M\xc2\xa0!#" , LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, 0, 1, 3);
+ MOUSE("\033[M\xc2\xa4!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_SHIFT, 1, 3);
+ MOUSE("\033[M\xc2\xa8!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_META, 1, 3);
+ MOUSE("\033[M\xc2\xac!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_SHIFT | LIBTERMINPUT_META, 1, 3);
+ MOUSE("\033[M\xc2\xb0!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON1, LIBTERMINPUT_CTRL, 1, 3);
+ MOUSE("\033[M\xc2\xb1!#", LIBTERMINPUT_PRESS, LIBTERMINPUT_XBUTTON2, LIBTERMINPUT_CTRL, 1, 3);
+ MOUSE("\033[M ", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 1, 1);
+
+ TYPE("\033[M \x1f", LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_MACRO);
+ TEST(input.keypress.mods == 0);
+ TEST(input.keypress.times == 1);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_SYMBOL);
+ TEST(input.keypress.mods == 0);
+ TEST(input.keypress.times == 1);
+ TEST(!strcmp(input.keypress.symbol, " "));
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_SYMBOL);
+ TEST(input.keypress.mods == 0);
+ TEST(input.keypress.times == 1);
+ TEST(!strcmp(input.keypress.symbol, " "));
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_SYMBOL);
+ TEST(input.keypress.mods == LIBTERMINPUT_CTRL);
+ TEST(input.keypress.times == 1);
+ TEST(!strcmp(input.keypress.symbol, "_"));
+ TYPE("\033[M \x1f ", LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE("\033[M\x1f ", LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+
+ MOUSE("\033[M \xc6\x89#", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 361, 3);
+ MOUSE("\033[M #\xc6\x89", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 3, 361);
+ MOUSE("\033[M \xc6\x89\xe0\xb4\xa5", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 361, 3333);
+
+ TYPE("\033[M\xff", LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_MACRO);
+ TEST(input.keypress.mods == 0);
+ TEST(input.keypress.times == 1);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE("\033[M!\xff", LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_MACRO);
+ TEST(input.keypress.mods == 0);
+ TEST(input.keypress.times == 1);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE("\033[M!!\xff", LIBTERMINPUT_KEYPRESS);
+ TEST(input.keypress.key == LIBTERMINPUT_MACRO);
+ TEST(input.keypress.mods == 0);
+ TEST(input.keypress.times == 1);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+ TYPE(NULL, LIBTERMINPUT_KEYPRESS);
+
+ TYPE("\033[M", LIBTERMINPUT_NONE);
+ TYPE(" ", LIBTERMINPUT_NONE);
+ TYPE("\xc6", LIBTERMINPUT_NONE);
+ TYPE("\x89", LIBTERMINPUT_NONE);
+ TYPE("\xe0", LIBTERMINPUT_NONE);
+ TYPE("\xb4", LIBTERMINPUT_NONE);
+ MOUSE("\xa5", LIBTERMINPUT_PRESS, LIBTERMINPUT_BUTTON1, 0, 361, 3333);
+
+ libterminput_clear_flags(&ctx, LIBTERMINPUT_DECSET_1005);
close(fds[1]);
TEST(libterminput_read(fds[0], &input, &ctx) == 0);