diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-04-24 17:27:48 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-04-24 17:27:48 +0100 |
commit | f5cbf9eb57b0dd38ed8054eff02defec1602f57a (patch) | |
tree | 8f5d412e6ce36cd3639600d1b6aa92b819bf07f4 /termkey.c | |
parent | 6645ee971807c5257ca50b073d1dee4af0630fc7 (diff) | |
download | termo-f5cbf9eb57b0dd38ed8054eff02defec1602f57a.tar.gz termo-f5cbf9eb57b0dd38ed8054eff02defec1602f57a.tar.xz termo-f5cbf9eb57b0dd38ed8054eff02defec1602f57a.zip |
Also handle CSI R; position report replies to CSI 6n
Diffstat (limited to 'termkey.c')
-rw-r--r-- | termkey.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -956,6 +956,16 @@ TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key, TermKe return TERMKEY_RES_KEY; } +TermKeyResult termkey_interpret_position(TermKey *tk, const TermKeyKey *key, int *line, int *col) +{ + if(key->type != TERMKEY_TYPE_POSITION) + return TERMKEY_RES_NONE; + + termkey_key_get_linecol(key, line, col); + + return TERMKEY_RES_KEY; +} + TermKeyResult termkey_getkey(TermKey *tk, TermKeyKey *key) { size_t nbytes = 0; @@ -1297,6 +1307,9 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T } } break; + case TERMKEY_TYPE_POSITION: + l = snprintf(buffer + pos, len - pos, "Position"); + break; } if(l <= 0) return pos; @@ -1394,18 +1407,32 @@ int termkey_keycmp(TermKey *tk, const TermKeyKey *key1p, const TermKeyKey *key2p case TERMKEY_TYPE_UNICODE: if(key1.code.codepoint != key2.code.codepoint) return key1.code.codepoint - key2.code.codepoint; + break; case TERMKEY_TYPE_KEYSYM: if(key1.code.sym != key2.code.sym) return key1.code.sym - key2.code.sym; + break; case TERMKEY_TYPE_FUNCTION: if(key1.code.number != key2.code.number) return key1.code.number - key2.code.number; + break; case TERMKEY_TYPE_MOUSE: { int cmp = strncmp(key1.code.mouse, key2.code.mouse, 4); if(cmp != 0) return cmp; } + break; + case TERMKEY_TYPE_POSITION: + { + int line1, col1, line2, col2; + termkey_interpret_position(tk, &key1, &line1, &col1); + termkey_interpret_position(tk, &key2, &line2, &col2); + if(line1 != line2) + return line1 - line2; + return col1 - col2; + } + break; } return key1.modifiers - key2.modifiers; |