aboutsummaryrefslogtreecommitdiff
path: root/tests/31position.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-10-09 23:47:24 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-10-09 23:47:24 +0200
commit5692f32bcfa049fc2b5555b5a883045b217349b9 (patch)
tree512eaa1bece48291ffdf7cf4865a085e6ee0b2cc /tests/31position.c
parent3465d5553fbe88a75320d1da3f7228619492b036 (diff)
downloadtermo-5692f32bcfa049fc2b5555b5a883045b217349b9.tar.gz
termo-5692f32bcfa049fc2b5555b5a883045b217349b9.tar.xz
termo-5692f32bcfa049fc2b5555b5a883045b217349b9.zip
CMake-ify, rename to termkey2 for the time being
Diffstat (limited to 'tests/31position.c')
-rw-r--r--tests/31position.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/31position.c b/tests/31position.c
new file mode 100644
index 0000000..a62be7a
--- /dev/null
+++ b/tests/31position.c
@@ -0,0 +1,38 @@
+#include "../termkey.h"
+#include "taplib.h"
+
+int main (int argc, char *argv[])
+{
+ termkey_t *tk;
+ termkey_key_t key;
+ int line, col;
+
+ plan_tests (8);
+
+ tk = termkey_new_abstract ("vt100", NULL, 0);
+
+ termkey_push_bytes (tk, "\e[?15;7R", 8);
+
+ is_int (termkey_getkey (tk, &key), TERMKEY_RES_KEY,
+ "getkey yields RES_KEY for position report");
+
+ is_int (key.type, TERMKEY_TYPE_POSITION, "key.type for position report");
+
+ is_int (termkey_interpret_position (tk, &key, &line, &col), TERMKEY_RES_KEY,
+ "interpret_position yields RES_KEY");
+
+ is_int (line, 15, "line for position report");
+ is_int (col, 7, "column for position report");
+
+ /* A plain CSI R is likely to be <F3> though. This is tricky :/ */
+ termkey_push_bytes (tk, "\e[R", 3);
+
+ is_int (termkey_getkey (tk, &key), TERMKEY_RES_KEY,
+ "getkey yields RES_KEY for <F3>");
+
+ is_int (key.type, TERMKEY_TYPE_FUNCTION, "key.type for <F3>");
+ is_int (key.code.number, 3, "key.code.number for <F3>");
+
+ termkey_destroy (tk);
+ return exit_status ();
+}