aboutsummaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test.c')
-rw-r--r--test.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/test.c b/test.c
index 223353f..094dae2 100644
--- a/test.c
+++ b/test.c
@@ -244,6 +244,16 @@ main(void)
TEST(input.keypress.key == (KEY));\
} while (0)
+#define MOUSE(STR, EV, BTN, MODS, X, Y)\
+ do {\
+ TYPE(STR, LIBTERMINPUT_MOUSEEVENT);\
+ TEST(input.mouseevent.button == (BTN));\
+ TEST(input.mouseevent.mods == (MODS));\
+ TEST(input.mouseevent.event == (EV));\
+ TEST(input.mouseevent.x == (X));\
+ TEST(input.mouseevent.y == (Y));\
+ } while (0)
+
char buffer[512], numbuf[3 * sizeof(int) + 2];
struct libterminput_state ctx;
union libterminput_input input;
@@ -469,6 +479,130 @@ 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
+
close(fds[1]);
TEST(libterminput_read(fds[0], &input, &ctx) == 0);
close(fds[0]);