diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-04-12 00:19:10 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-04-12 00:19:10 +0100 |
commit | 60b4bfaf72cab1af28c12031b2ffefc0ec7b1fb6 (patch) | |
tree | 17ad0a061b8c2e3a01040a806d010058f926157d /driver-csi.c | |
parent | ff99b29b967579d5ce82e752d0f8407233e67df2 (diff) | |
download | termo-60b4bfaf72cab1af28c12031b2ffefc0ec7b1fb6.tar.gz termo-60b4bfaf72cab1af28c12031b2ffefc0ec7b1fb6.tar.xz termo-60b4bfaf72cab1af28c12031b2ffefc0ec7b1fb6.zip |
Recognise SGR-style mouse encoding
Diffstat (limited to 'driver-csi.c')
-rw-r--r-- | driver-csi.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/driver-csi.c b/driver-csi.c index 0b19c52..a8ae0c0 100644 --- a/driver-csi.c +++ b/driver-csi.c @@ -203,9 +203,16 @@ static TermKeyResult peekkey_csi(TermKey *tk, TermKeyCsi *csi, size_t introlen, long arg[16]; char present = 0; int args = 0; + int initial = 0; size_t p = introlen; + // See if there is an initial byte + if(CHARAT(p) >= '<' && CHARAT(p) <= '?') { + initial = CHARAT(p); + p++; + } + // Now attempt to parse out up number;number;... separated values while(p < csi_end) { unsigned char c = CHARAT(p); @@ -272,10 +279,10 @@ static TermKeyResult peekkey_csi(TermKey *tk, TermKeyCsi *csi, size_t introlen, (*tk->method.emit_codepoint)(tk, arg[0], key); key->modifiers |= mod; } - else if(cmd == 'M') { + else if(cmd == 'M' || (initial == '<' && cmd == 'm')) { size_t csi_len = csi_end + 1; - if(args >= 3) { + if(!initial && args >= 3) { // rxvt protocol key->code.mouse[0] = arg[0]; key->modifiers = (key->code.mouse[0] & 0x1c) >> 2; @@ -295,6 +302,28 @@ static TermKeyResult peekkey_csi(TermKey *tk, TermKeyCsi *csi, size_t introlen, return TERMKEY_RES_KEY; } + if(initial == '<' && args >= 3) { // SGR protocol + key->code.mouse[0] = arg[0]; + + key->modifiers = (key->code.mouse[0] & 0x1c) >> 2; + key->code.mouse[0] &= ~0x1c; + + if(arg[1] > 0xff) + key->code.mouse[1] = 0xff; + else + key->code.mouse[1] = arg[1]; + + if(arg[2] > 0xff) + key->code.mouse[2] = 0xff; + else + key->code.mouse[2] = arg[2]; + + key->code.mouse[3] = (cmd == 'm'); + + *nbytep = csi_len; + return TERMKEY_RES_KEY; + } + tk->buffstart += csi_len; tk->buffcount -= csi_len; |