diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-11-02 14:54:33 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2008-11-02 14:54:33 +0000 |
commit | 1d4d908cb8668a1c043a4630d114dcfa219711d7 (patch) | |
tree | 82f73649c99972e91f1fe456cb0add0d33a7e8fa | |
parent | 62d4e7eccbf8eca4e395688f2e4fc4948919a59d (diff) | |
download | termo-1d4d908cb8668a1c043a4630d114dcfa219711d7.tar.gz termo-1d4d908cb8668a1c043a4630d114dcfa219711d7.tar.xz termo-1d4d908cb8668a1c043a4630d114dcfa219711d7.zip |
Remeber to handle Esc-prefixed keypresses in base getkey_simple() function - involves some code duplication with CSI driver currently
-rw-r--r-- | termkey.c | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -351,7 +351,42 @@ static termkey_result getkey_simple(termkey_t *tk, termkey_key *key, int force) { unsigned char b0 = CHARAT(0); - if(b0 < 0xa0) { + if(b0 == 0x1b) { + // Escape-prefixed value? Might therefore be Alt+key + 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; + } + + // Try another key there + tk->buffstart++; + + // Run the full driver + termkey_result metakey_result = (*tk->driver.getkey)(tk, key, force); + + 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: + tk->buffstart--; + break; + } + + return metakey_result; + } + else if(b0 < 0xa0) { // Single byte C0, G0 or C1 - C1 is never UTF-8 initial byte (*tk->method.emit_codepoint)(tk, b0, key); (*tk->method.eat_bytes)(tk, 1); |