2014-10-14 00:24:47 +02:00
|
|
|
#include "../termo.h"
|
2012-04-05 18:57:13 +02:00
|
|
|
#include "taplib.h"
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2012-04-05 18:57:13 +02:00
|
|
|
{
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_t *tk;
|
|
|
|
termo_key_t key;
|
|
|
|
termo_mouse_event_t ev;
|
2014-09-28 05:56:13 +02:00
|
|
|
int button, line, col;
|
|
|
|
char buffer[32];
|
|
|
|
size_t len;
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
plan_tests (60);
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
tk = termo_new_abstract ("vt100", NULL, 0);
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[M !!", 6);
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_KEY for mouse press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_MOUSE, "key.type for mouse press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_PRESS, "mouse event for press");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (button, 1, "mouse button for press");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 0, "mouse line for press");
|
|
|
|
is_int (col, 0, "mouse column for press");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "modifiers for press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2016-10-04 13:22:52 +02:00
|
|
|
len = termo_strfkey_utf8 (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 13, "string length for press");
|
|
|
|
is_str (buffer, "MousePress(1)", "string buffer for press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2016-10-04 13:22:52 +02:00
|
|
|
len = termo_strfkey_utf8 (tk, buffer, sizeof buffer,
|
2014-10-14 00:24:47 +02:00
|
|
|
&key, TERMO_FORMAT_MOUSE_POS);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 21, "string length for press");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_str (buffer, "MousePress(1) @ (0,0)", "string buffer for press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[M@\"!", 6);
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_getkey (tk, &key);
|
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_DRAG, "mouse event for drag");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (button, 1, "mouse button for drag");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 0, "mouse line for drag");
|
|
|
|
is_int (col, 1, "mouse column for drag");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "modifiers for press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[M##!", 6);
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_getkey (tk, &key);
|
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_RELEASE, "mouse event for release");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 0, "mouse line for release");
|
|
|
|
is_int (col, 2, "mouse column for release");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "modifiers for press");
|
2012-04-05 19:54:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[M0++", 6);
|
2012-04-05 19:54:30 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_getkey (tk, &key);
|
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-05 19:54:30 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_PRESS, "mouse event for Ctrl-press");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (button, 1, "mouse button for Ctrl-press");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 10, "mouse line for Ctrl-press");
|
|
|
|
is_int (col, 10, "mouse column for Ctrl-press");
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.modifiers, TERMO_KEYMOD_CTRL, "modifiers for Ctrl-press");
|
2012-04-05 19:54:30 +02:00
|
|
|
|
2016-10-04 13:22:52 +02:00
|
|
|
len = termo_strfkey_utf8 (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 15, "string length for Ctrl-press");
|
|
|
|
is_str (buffer, "C-MousePress(1)", "string buffer for Ctrl-press");
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
// rxvt protocol
|
2015-05-27 21:31:04 +02:00
|
|
|
termo_push_bytes (tk, "\e[32;20;20M", 11);
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_KEY for mouse press rxvt protocol");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_MOUSE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.type for mouse press rxvt protocol");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_PRESS, "mouse event for press rxvt protocol");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (button, 1, "mouse button for press rxvt protocol");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 19, "mouse line for press rxvt protocol");
|
|
|
|
is_int (col, 19, "mouse column for press rxvt protocol");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "modifiers for press rxvt protocol");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2015-05-27 21:31:04 +02:00
|
|
|
termo_push_bytes (tk, "\e[35;20;20M", 11);
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_KEY for mouse release rxvt protocol");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_MOUSE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.type for mouse release rxvt protocol");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_RELEASE, "mouse event for release rxvt protocol");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 19, "mouse line for release rxvt protocol");
|
|
|
|
is_int (col, 19, "mouse column for release rxvt protocol");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "modifiers for release rxvt protocol");
|
2012-04-12 01:12:19 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
// SGR protocol
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[<0;30;30M", 11);
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_KEY for mouse press SGR encoding");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_MOUSE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.type for mouse press SGR encoding");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_PRESS, "mouse event for press SGR");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (button, 1, "mouse button for press SGR");
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 29, "mouse line for press SGR");
|
|
|
|
is_int (col, 29, "mouse column for press SGR");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "modifiers for press SGR");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[<0;30;30m", 11);
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_KEY,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_KEY for mouse release SGR encoding");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_MOUSE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.type for mouse release SGR encoding");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_interpret_mouse (tk, &key, &ev, &button, &line, &col),
|
|
|
|
TERMO_RES_KEY, "interpret_mouse yields RES_KEY");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (ev, TERMO_MOUSE_RELEASE, "mouse event for release SGR");
|
2012-04-12 01:19:10 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\e[<0;500;300M", 13);
|
2012-04-12 18:02:45 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
key.type = -1;
|
|
|
|
ev = -1; button = -1; line = -1; col = -1;
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_getkey (tk, &key);
|
|
|
|
termo_interpret_mouse (tk, &key, &ev, &button, &line, &col);
|
2012-04-12 18:02:45 +02:00
|
|
|
|
2015-05-27 21:31:04 +02:00
|
|
|
is_int (line, 299, "mouse line for press SGR wide");
|
|
|
|
is_int (col, 499, "mouse column for press SGR wide");
|
2012-04-12 18:02:45 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_destroy (tk);
|
2012-04-05 18:57:13 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
return exit_status ();
|
2012-04-05 18:57:13 +02:00
|
|
|
}
|