aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver-csi.c22
-rw-r--r--t/31position.c12
2 files changed, 26 insertions, 8 deletions
diff --git a/driver-csi.c b/driver-csi.c
index f4de6a8..ae0b50d 100644
--- a/driver-csi.c
+++ b/driver-csi.c
@@ -258,19 +258,27 @@ TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key, TermKe
/*
* Handler for CSI R position reports
+ * A plain CSI R with no arguments is probably actually <F3>
*/
static TermKeyResult handle_csi_R(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
switch(cmd) {
case 'R':
- if(args < 2)
- return TERMKEY_RES_NONE;
-
- key->type = TERMKEY_TYPE_POSITION;
- termkey_key_set_linecol(key, arg[1], arg[0]);
-
- return TERMKEY_RES_KEY;
+ switch(args) {
+ case 0:
+ key->type = TERMKEY_TYPE_FUNCTION;
+ key->code.number = 3;
+ return TERMKEY_RES_KEY;
+
+ case 2:
+ key->type = TERMKEY_TYPE_POSITION;
+ termkey_key_set_linecol(key, arg[1], arg[0]);
+ return TERMKEY_RES_KEY;
+
+ default:
+ return TERMKEY_RES_NONE;
+ }
default:
return TERMKEY_RES_NONE;
}
diff --git a/t/31position.c b/t/31position.c
index bb798c6..3304643 100644
--- a/t/31position.c
+++ b/t/31position.c
@@ -7,7 +7,7 @@ int main(int argc, char *argv[])
TermKeyKey key;
int line, col;
- plan_tests(5);
+ plan_tests(8);
tk = termkey_new_abstract("vt100", 0);
@@ -22,6 +22,16 @@ int main(int argc, char *argv[])
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();