2014-10-14 00:24:47 +02:00
|
|
|
#include "../termo.h"
|
2011-03-31 15:10:35 +02:00
|
|
|
#include "taplib.h"
|
|
|
|
|
2014-09-28 05:56:13 +02:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2011-03-31 15:10:35 +02:00
|
|
|
{
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_t *tk;
|
|
|
|
termo_key_t key;
|
2014-09-28 05:56:13 +02:00
|
|
|
char buffer[16];
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
plan_tests (44);
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
tk = termo_new_abstract ("vt100", NULL, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key.type = TERMO_TYPE_KEY;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.code.codepoint = 'A';
|
|
|
|
key.modifiers = 0;
|
|
|
|
key.multibyte[0] = 0;
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 1, "length for unicode/A/0");
|
|
|
|
is_str (buffer, "A", "buffer for unicode/A/0");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_WRAPBRACKET);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 1, "length for unicode/A/0 wrapbracket");
|
|
|
|
is_str (buffer, "A", "buffer for unicode/A/0 wrapbracket");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key.type = TERMO_TYPE_KEY;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.code.codepoint = 'b';
|
2014-10-14 00:24:47 +02:00
|
|
|
key.modifiers = TERMO_KEYMOD_CTRL;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.multibyte[0] = 0;
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 3, "length for unicode/b/CTRL");
|
|
|
|
is_str (buffer, "C-b", "buffer for unicode/b/CTRL");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LONGMOD);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for unicode/b/CTRL longmod");
|
|
|
|
is_str (buffer, "Ctrl-b", "buffer for unicode/b/CTRL longmod");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LONGMOD | TERMO_FORMAT_SPACEMOD);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for unicode/b/CTRL longmod|spacemod");
|
|
|
|
is_str (buffer, "Ctrl b", "buffer for unicode/b/CTRL longmod|spacemod");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LONGMOD | TERMO_FORMAT_LOWERMOD);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for unicode/b/CTRL longmod|lowermod");
|
|
|
|
is_str (buffer, "ctrl-b", "buffer for unicode/b/CTRL longmod|lowermod");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LONGMOD | TERMO_FORMAT_SPACEMOD
|
|
|
|
| TERMO_FORMAT_LOWERMOD);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for unicode/b/CTRL longmod|spacemod|lowermode");
|
|
|
|
is_str (buffer, "ctrl b",
|
|
|
|
"buffer for unicode/b/CTRL longmod|spacemod|lowermode");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_CARETCTRL);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 2, "length for unicode/b/CTRL caretctrl");
|
|
|
|
is_str (buffer, "^B", "buffer for unicode/b/CTRL caretctrl");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_WRAPBRACKET);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 5, "length for unicode/b/CTRL wrapbracket");
|
|
|
|
is_str (buffer, "<C-b>", "buffer for unicode/b/CTRL wrapbracket");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key.type = TERMO_TYPE_KEY;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.code.codepoint = 'c';
|
2014-10-14 00:24:47 +02:00
|
|
|
key.modifiers = TERMO_KEYMOD_ALT;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.multibyte[0] = 0;
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 3, "length for unicode/c/ALT");
|
|
|
|
is_str (buffer, "A-c", "buffer for unicode/c/ALT");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LONGMOD);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 5, "length for unicode/c/ALT longmod");
|
|
|
|
is_str (buffer, "Alt-c", "buffer for unicode/c/ALT longmod");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_ALTISMETA);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 3, "length for unicode/c/ALT altismeta");
|
|
|
|
is_str (buffer, "M-c", "buffer for unicode/c/ALT altismeta");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LONGMOD|TERMO_FORMAT_ALTISMETA);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for unicode/c/ALT longmod|altismeta");
|
|
|
|
is_str (buffer, "Meta-c", "buffer for unicode/c/ALT longmod|altismeta");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key.type = TERMO_TYPE_KEYSYM;
|
|
|
|
key.code.sym = TERMO_SYM_UP;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.modifiers = 0;
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 2, "length for sym/Up/0");
|
|
|
|
is_str (buffer, "Up", "buffer for sym/Up/0");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_WRAPBRACKET);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 4, "length for sym/Up/0 wrapbracket");
|
|
|
|
is_str (buffer, "<Up>", "buffer for sym/Up/0 wrapbracket");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key.type = TERMO_TYPE_KEYSYM;
|
|
|
|
key.code.sym = TERMO_SYM_PAGEUP;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.modifiers = 0;
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for sym/PageUp/0");
|
|
|
|
is_str (buffer, "PageUp", "buffer for sym/PageUp/0");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LOWERSPACE);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 7, "length for sym/PageUp/0 lowerspace");
|
|
|
|
is_str (buffer, "page up", "buffer for sym/PageUp/0 lowerspace");
|
|
|
|
|
|
|
|
/* If size of buffer is too small,
|
|
|
|
* strfkey should return something consistent */
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, 4, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 6, "length for sym/PageUp/0");
|
|
|
|
is_str (buffer, "Pag", "buffer of len 4 for sym/PageUp/0");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, 4, &key, TERMO_FORMAT_LOWERSPACE);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 7, "length for sym/PageUp/0 lowerspace");
|
|
|
|
is_str (buffer, "pag", "buffer of len 4 for sym/PageUp/0 lowerspace");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
key.type = TERMO_TYPE_FUNCTION;
|
2014-09-28 05:56:13 +02:00
|
|
|
key.code.number = 5;
|
|
|
|
key.modifiers = 0;
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key, 0);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 2, "length for func/5/0");
|
|
|
|
is_str (buffer, "F5", "buffer for func/5/0");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_WRAPBRACKET);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 4, "length for func/5/0 wrapbracket");
|
|
|
|
is_str (buffer, "<F5>", "buffer for func/5/0 wrapbracket");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
len = termo_strfkey (tk, buffer, sizeof buffer, &key,
|
|
|
|
TERMO_FORMAT_LOWERSPACE);
|
2014-09-28 05:56:13 +02:00
|
|
|
is_int (len, 2, "length for func/5/0 lowerspace");
|
|
|
|
is_str (buffer, "f5", "buffer for func/5/0 lowerspace");
|
|
|
|
|
2014-10-14 00:24:47 +02:00
|
|
|
termo_destroy (tk);
|
2014-09-28 05:56:13 +02:00
|
|
|
return exit_status ();
|
2011-03-31 15:10:35 +02:00
|
|
|
}
|