=== modified file 'demo.c' --- demo.c 2012-11-30 16:12:26 +0000 +++ demo.c 2012-04-25 17:32:18 +0000 @@ -61,12 +61,12 @@ if(key.type == TERMKEY_TYPE_MOUSE) { int line, col; termkey_interpret_mouse(tk, &key, NULL, NULL, &line, &col); - printf("%s at line=%d, col=%d\n", buffer, line, col); + printf("%s at line=%d, col=%d)\n", buffer, line, col); } else if(key.type == TERMKEY_TYPE_POSITION) { int line, col; termkey_interpret_position(tk, &key, &line, &col); - printf("Cursor position report at line=%d, col=%d\n", line, col); + printf("Cursor position report at line=%d, col=%d)\n", line, col); } else { printf("%s\n", buffer); @@ -80,7 +80,7 @@ if(key.type == TERMKEY_TYPE_UNICODE && key.modifiers == 0 && key.code.codepoint == '?') { - printf("\033[?6n"); + printf("\033[6n"); fflush(stdout); } } === modified file 'driver-csi.c' --- driver-csi.c 2012-11-30 16:12:26 +0000 +++ driver-csi.c 2012-11-30 15:36:06 +0000 @@ -257,23 +257,30 @@ } /* - * Handler for CSI ? R position reports + * Handler for CSI R position reports * A plain CSI R with no arguments is probably actually */ static TermKeyResult handle_csi_R(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args) { switch(cmd) { - case 'R'|'?'<<8: - 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; - + case 'R': + 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 handle_csi_ss3_full(tk, key, cmd, arg, args); + return TERMKEY_RES_NONE; } } === modified file 'man/termkey.7' --- man/termkey.7 2012-11-30 16:12:26 +0000 +++ man/termkey.7 2012-11-30 14:35:23 +0000 @@ -132,7 +132,7 @@ .SM SGR encoding (\f(CWCSI < ... M\fP, as requested by \f(CWCSI ? 1006 h\fP), and rxvt encoding (\f(CWCSI ... M\fP, as requested by \f(CWCSI ? 1015 h\fP). Which encoding is in use is inferred automatically by \fBtermkey\fP, and does not need to be specified explicitly. .SS Position Events -The \fBTERMKEY_TYPE_POSITION\fP event type indicates a cursor position report. This is typically sent by a terminal in response to the Report Cursor Position command (\f(CWCSI ? 6 n\fP). The event bytes are opaque, but can be obtained by calling \fBtermkey_interpret_position\fP(3) passing the event structure and pointers to integers to store the result in. Note that only a DEC CPR sequence (\f(CWCSI ? R\fP) is recognised, and not the non-DEC prefixed \f(CWCSI R\fP because the latter could be interpreted as the \f(CWF3\fP function key instead. +The \fBTERMKEY_TYPE_POSITION\fP event type indicates a cursor position report. This is typically sent by a terminal in response to the Report Cursor Position command (\f(CWCSI 6 n\fP). The event bytes are opaque, but can be obtained by calling \fBtermkey_interpret_position\fP(3) passing the event structure and pointers to integers to store the result in. .SS Unrecognised CSIs The \fBTERMKEY_TYPE_UNKNOWN_CSI\fP event type indicates a CSI sequence that the \fBtermkey\fP does not recognise. It will have been extracted from the stream, but is available to the application to inspect by calling \fBtermkey_interpret_csi\fP(3). It is important that if the application wishes to inspect this sequence it is done immediately, before any other IO operations on the \fBtermkey\fP instance (specifically, before calling \fBtermkey_waitkey\fP() or \fBtermkey_getkey\fP() again), otherwise the buffer space consumed by the sequence will be overwritten. .SH "SEE ALSO" === modified file 't/31position.c' --- t/31position.c 2012-11-30 16:12:26 +0000 +++ t/31position.c 2012-11-30 15:36:06 +0000 @@ -11,7 +11,7 @@ tk = termkey_new_abstract("vt100", 0); - termkey_push_bytes(tk, "\e[?15;7R", 8); + termkey_push_bytes(tk, "\e[15;7R", 7); is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY for position report");