aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/termkey.c b/termkey.c
index e1969c2..bb1c5f8 100644
--- a/termkey.c
+++ b/termkey.c
@@ -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;
}