2011-03-31 15:10:35 +02:00
|
|
|
#include "../termkey.h"
|
|
|
|
#include "taplib.h"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
TermKey *tk;
|
|
|
|
TermKeyKey key;
|
|
|
|
char buffer[16];
|
|
|
|
size_t len;
|
|
|
|
|
2011-04-01 11:48:15 +02:00
|
|
|
plan_tests(28);
|
2011-03-31 15:10:35 +02:00
|
|
|
|
2012-01-26 13:55:34 +01:00
|
|
|
tk = termkey_new_abstract("vt100", 0);
|
2011-03-31 15:10:35 +02:00
|
|
|
|
|
|
|
key.type = TERMKEY_TYPE_UNICODE;
|
2011-04-01 11:41:44 +02:00
|
|
|
key.code.codepoint = 'A';
|
2011-03-31 15:10:35 +02:00
|
|
|
key.modifiers = 0;
|
|
|
|
key.utf8[0] = 0;
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, 0);
|
|
|
|
is_int(len, 1, "length for unicode/A/0");
|
|
|
|
is_str(buffer, "A", "buffer for unicode/A/0");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_WRAPBRACKET);
|
|
|
|
is_int(len, 1, "length for unicode/A/0 wrapbracket");
|
|
|
|
is_str(buffer, "A", "buffer for unicode/A/0 wrapbracket");
|
|
|
|
|
|
|
|
key.type = TERMKEY_TYPE_UNICODE;
|
2011-04-01 11:41:44 +02:00
|
|
|
key.code.codepoint = 'b';
|
2011-03-31 15:10:35 +02:00
|
|
|
key.modifiers = TERMKEY_KEYMOD_CTRL;
|
|
|
|
key.utf8[0] = 0;
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, 0);
|
|
|
|
is_int(len, 3, "length for unicode/b/CTRL");
|
|
|
|
is_str(buffer, "C-b", "buffer for unicode/b/CTRL");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_LONGMOD);
|
|
|
|
is_int(len, 6, "length for unicode/b/CTRL longmod");
|
|
|
|
is_str(buffer, "Ctrl-b", "buffer for unicode/b/CTRL longmod");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_CARETCTRL);
|
|
|
|
is_int(len, 2, "length for unicode/b/CTRL caretctrl");
|
|
|
|
is_str(buffer, "^B", "buffer for unicode/b/CTRL caretctrl");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_WRAPBRACKET);
|
|
|
|
is_int(len, 5, "length for unicode/b/CTRL wrapbracket");
|
|
|
|
is_str(buffer, "<C-b>", "buffer for unicode/b/CTRL wrapbracket");
|
|
|
|
|
|
|
|
key.type = TERMKEY_TYPE_UNICODE;
|
2011-04-01 11:41:44 +02:00
|
|
|
key.code.codepoint = 'c';
|
2011-03-31 15:10:35 +02:00
|
|
|
key.modifiers = TERMKEY_KEYMOD_ALT;
|
|
|
|
key.utf8[0] = 0;
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, 0);
|
|
|
|
is_int(len, 3, "length for unicode/c/ALT");
|
|
|
|
is_str(buffer, "A-c", "buffer for unicode/c/ALT");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_LONGMOD);
|
|
|
|
is_int(len, 5, "length for unicode/c/ALT longmod");
|
|
|
|
is_str(buffer, "Alt-c", "buffer for unicode/c/ALT longmod");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_ALTISMETA);
|
|
|
|
is_int(len, 3, "length for unicode/c/ALT altismeta");
|
|
|
|
is_str(buffer, "M-c", "buffer for unicode/c/ALT altismeta");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_LONGMOD|TERMKEY_FORMAT_ALTISMETA);
|
|
|
|
is_int(len, 6, "length for unicode/c/ALT longmod|altismeta");
|
|
|
|
is_str(buffer, "Meta-c", "buffer for unicode/c/ALT longmod|altismeta");
|
|
|
|
|
|
|
|
key.type = TERMKEY_TYPE_KEYSYM;
|
|
|
|
key.code.sym = TERMKEY_SYM_UP;
|
|
|
|
key.modifiers = 0;
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, 0);
|
|
|
|
is_int(len, 2, "length for sym/Up/0");
|
|
|
|
is_str(buffer, "Up", "buffer for sym/Up/0");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_WRAPBRACKET);
|
|
|
|
is_int(len, 4, "length for sym/Up/0 wrapbracket");
|
|
|
|
is_str(buffer, "<Up>", "buffer for sym/Up/0 wrapbracket");
|
|
|
|
|
2011-04-01 11:48:15 +02:00
|
|
|
key.type = TERMKEY_TYPE_FUNCTION;
|
|
|
|
key.code.number = 5;
|
|
|
|
key.modifiers = 0;
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, 0);
|
|
|
|
is_int(len, 2, "length for func/5/0");
|
|
|
|
is_str(buffer, "F5", "buffer for func/5/0");
|
|
|
|
|
|
|
|
len = termkey_strfkey(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_WRAPBRACKET);
|
|
|
|
is_int(len, 4, "length for func/5/0 wrapbracket");
|
|
|
|
is_str(buffer, "<F5>", "buffer for func/5/0 wrapbracket");
|
|
|
|
|
2011-03-31 15:10:35 +02:00
|
|
|
termkey_destroy(tk);
|
|
|
|
|
|
|
|
return exit_status();
|
|
|
|
}
|