diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2011-08-27 19:59:02 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2011-08-27 19:59:02 +0100 |
commit | 46eefda07367e63b7ceffeecb2778409f1d4b387 (patch) | |
tree | 811bf778119fa1fc67c803ea8cc22a2e6252dd21 /termkey.c | |
parent | 83ca948d7818b88fa604a39a73465ba6932d4ce5 (diff) | |
download | termo-46eefda07367e63b7ceffeecb2778409f1d4b387.tar.gz termo-46eefda07367e63b7ceffeecb2778409f1d4b387.tar.xz termo-46eefda07367e63b7ceffeecb2778409f1d4b387.zip |
Provide an explicit termkey_canonicalise() function; canonicalise Space/SP in both directions
Diffstat (limited to 'termkey.c')
-rw-r--r-- | termkey.c | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -538,12 +538,6 @@ static void emit_codepoint(TermKey *tk, long codepoint, TermKeyKey *key) key->type = TERMKEY_TYPE_KEYSYM; } } - else if(codepoint == 0x20 && (tk->flags & TERMKEY_FLAG_SPACESYMBOL)) { - // ASCII space - key->type = TERMKEY_TYPE_KEYSYM; - key->code.sym = TERMKEY_SYM_SPACE; - key->modifiers = 0; - } else if(codepoint == 0x7f && !(tk->flags & TERMKEY_FLAG_NOINTERPRET)) { // ASCII DEL key->type = TERMKEY_TYPE_KEYSYM; @@ -569,10 +563,31 @@ static void emit_codepoint(TermKey *tk, long codepoint, TermKeyKey *key) key->modifiers = 0; } + termkey_canonicalise(tk, key); + if(key->type == TERMKEY_TYPE_UNICODE) fill_utf8(key); } +void termkey_canonicalise(TermKey *tk, TermKeyKey *key) +{ + int flags = tk->flags; + + if(flags & TERMKEY_FLAG_SPACESYMBOL) { + if(key->type == TERMKEY_TYPE_UNICODE && key->code.number == 0x20) { + key->type = TERMKEY_TYPE_KEYSYM; + key->code.sym = TERMKEY_SYM_SPACE; + } + } + else { + if(key->type == TERMKEY_TYPE_KEYSYM && key->code.sym == TERMKEY_SYM_SPACE) { + key->type = TERMKEY_TYPE_UNICODE; + key->code.number = 0x20; + fill_utf8(key); + } + } +} + static TermKeyResult peekkey(TermKey *tk, TermKeyKey *key, int force, size_t *nbytep) { int again = 0; @@ -1178,6 +1193,8 @@ char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyForm else return NULL; + termkey_canonicalise(tk, key); + return (char *)str; } |