diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-11-03 14:46:42 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-11-03 14:46:42 +0000 |
commit | 86933f18364a249ca67b4b916e83edbb429e091f (patch) | |
tree | 824c7d8d245be94fcf5cf7c716b4a3352e14dd66 /driver-csi.c | |
parent | ca485ca6709f99bee0cc0f696ebbab442c2bbe0a (diff) | |
download | termo-86933f18364a249ca67b4b916e83edbb429e091f.tar.gz termo-86933f18364a249ca67b4b916e83edbb429e091f.tar.xz termo-86933f18364a249ca67b4b916e83edbb429e091f.zip |
Reuse common Esc-prefix code in getkey_simple() from CSI driver; avoids code duplication
Diffstat (limited to 'driver-csi.c')
-rw-r--r-- | driver-csi.c | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/driver-csi.c b/driver-csi.c index 6b3f9b0..29da086 100644 --- a/driver-csi.c +++ b/driver-csi.c @@ -298,50 +298,11 @@ static termkey_result getkey(termkey_t *tk, termkey_key *key, int force) // Now we're sure at least 1 byte is valid unsigned char b0 = CHARAT(0); - if(b0 == 0x1b) { - if(tk->buffcount == 1) { - // This might be an <Esc> press, or it may want to be part of a longer - // sequence - if(!force) - return TERMKEY_RES_AGAIN; - - (*tk->method.emit_codepoint)(tk, b0, key); - (*tk->method.eat_bytes)(tk, 1); - return TERMKEY_RES_KEY; - } - - unsigned char b1 = CHARAT(1); - - if(b1 == '[') - return getkey_csi(tk, 2, key, force); - - if(b1 == 'O') - return getkey_ss3(tk, 2, key, force); - - if(b1 == 0x1b) { - (*tk->method.emit_codepoint)(tk, b0, key); - (*tk->method.eat_bytes)(tk, 1); - return TERMKEY_RES_KEY; - } - - tk->buffstart++; - - termkey_result metakey_result = termkey_getkey(tk, key); - - switch(metakey_result) { - case TERMKEY_RES_KEY: - key->modifiers |= TERMKEY_KEYMOD_ALT; - tk->buffstart--; - (*tk->method.eat_bytes)(tk, 1); - break; - - case TERMKEY_RES_NONE: - case TERMKEY_RES_EOF: - case TERMKEY_RES_AGAIN: - break; - } - - return metakey_result; + if(b0 == 0x1b && tk->buffcount > 1 && CHARAT(1) == '[') { + return getkey_csi(tk, 2, key, force); + } + else if(b0 == 0x1b && tk->buffcount > 1 && CHARAT(1) == 'O') { + return getkey_ss3(tk, 2, key, force); } else if(b0 == 0x8f) { return getkey_ss3(tk, 1, key, force); |