2014-10-14 00:24:47 +02:00
|
|
|
#include "../termo.h"
|
2011-03-31 13:47:09 +02:00
|
|
|
#include "taplib.h"
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2011-03-31 13:47:09 +02:00
|
|
|
{
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_t *tk;
|
|
|
|
termo_key_t key;
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
plan_tests (31);
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
tk = termo_new_abstract ("vt100", NULL, 0);
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_get_buffer_remaining (tk),
|
2014-09-28 05:56:13 +02:00
|
|
|
256, "buffer free initially 256");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_NONE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_NONE when empty");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_push_bytes (tk, "h", 1), 1, "push_bytes returns 1");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_get_buffer_remaining (tk), 255,
|
2014-09-28 05:56:13 +02:00
|
|
|
"buffer free 255 after push_bytes");
|
2012-01-18 11:04:15 +01: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 after h");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_KEY, "key.type after h");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.code.codepoint, 'h', "key.code.codepoint after h");
|
|
|
|
is_int (key.modifiers, 0, "key.modifiers after h");
|
|
|
|
is_str (key.multibyte, "h", "key.multibyte after h");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_get_buffer_remaining (tk), 256,
|
2014-09-28 05:56:13 +02:00
|
|
|
"buffer free 256 after getkey");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_NONE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_NONE a second time");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\x01", 1);
|
2011-03-31 13:47:09 +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 after C-a");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_KEY, "key.type after C-a");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.code.codepoint, 'a', "key.code.codepoint after C-a");
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.modifiers, TERMO_KEYMOD_CTRL, "key.modifiers after C-a");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\033OA", 3);
|
2011-03-31 13:47:09 +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 after Up");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_KEYSYM, "key.type after Up");
|
|
|
|
is_int (key.code.sym, TERMO_SYM_UP, "key.code.sym after Up");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "key.modifiers after Up");
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_push_bytes (tk, "\033O", 2), 2, "push_bytes returns 2");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_get_buffer_remaining (tk), 254,
|
2014-09-28 05:56:13 +02:00
|
|
|
"buffer free 254 after partial write");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_getkey (tk, &key), TERMO_RES_AGAIN,
|
2014-09-28 05:56:13 +02:00
|
|
|
"getkey yields RES_AGAIN after partial write");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "C", 1);
|
2012-01-18 11:04:15 +01: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 after Right completion");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_KEYSYM, "key.type after Right");
|
|
|
|
is_int (key.code.sym, TERMO_SYM_RIGHT, "key.code.sym after Right");
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (key.modifiers, 0, "key.modifiers after Right");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (termo_get_buffer_remaining (tk), 256,
|
2014-09-28 05:56:13 +02:00
|
|
|
"buffer free 256 after completion");
|
2012-01-18 11:04:15 +01:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_push_bytes (tk, "\033[27;5u", 7);
|
2012-04-24 16:58:37 +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 after Ctrl-Escape");
|
2012-04-24 16:58:37 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.type, TERMO_TYPE_KEYSYM,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.type after Ctrl-Escape");
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.code.sym, TERMO_SYM_ESCAPE,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.code.sym after Ctrl-Escape");
|
2014-10-14 00:24:47 +02:00
|
|
|
is_int (key.modifiers, TERMO_KEYMOD_CTRL,
|
2014-09-28 05:56:13 +02:00
|
|
|
"key.modifiers after Ctrl-Escape");
|
2012-04-24 16:58:37 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_destroy (tk);
|
2011-03-31 13:47:09 +02:00
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
return exit_status ();
|
2011-03-31 13:47:09 +02:00
|
|
|
}
|