aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2011-08-28 17:50:18 +0100
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2011-08-28 17:50:18 +0100
commit26384996486963bc2f097f44a82a5c07e0dfe69e (patch)
tree58c7da5748c3a635ff4cb49e419f3153552e6ca6 /termkey.c
parent713351788373e764fc1c66ae1960b36ea6096b02 (diff)
downloadtermo-26384996486963bc2f097f44a82a5c07e0dfe69e.tar.gz
termo-26384996486963bc2f097f44a82a5c07e0dfe69e.tar.xz
termo-26384996486963bc2f097f44a82a5c07e0dfe69e.zip
Move canonicalisation flags into their own bitfield with their own accessor and named constants
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/termkey.c b/termkey.c
index bb1c5f8..37c2690 100644
--- a/termkey.c
+++ b/termkey.c
@@ -198,6 +198,10 @@ static TermKey *termkey_new_full(int fd, int flags, size_t buffsize, int waittim
tk->fd = fd;
tk->flags = flags;
+ tk->canonflags = 0;
+
+ if(flags & TERMKEY_FLAG_SPACESYMBOL)
+ tk->canonflags |= TERMKEY_CANON_SPACESYMBOL;
tk->buffer = malloc(buffsize);
if(!tk->buffer)
@@ -373,6 +377,11 @@ int termkey_get_flags(TermKey *tk)
void termkey_set_flags(TermKey *tk, int newflags)
{
tk->flags = newflags;
+
+ if(tk->flags & TERMKEY_FLAG_SPACESYMBOL)
+ tk->canonflags |= TERMKEY_CANON_SPACESYMBOL;
+ else
+ tk->canonflags &= ~TERMKEY_CANON_SPACESYMBOL;
}
void termkey_set_waittime(TermKey *tk, int msec)
@@ -385,6 +394,21 @@ int termkey_get_waittime(TermKey *tk)
return tk->waittime;
}
+int termkey_get_canonflags(TermKey *tk)
+{
+ return tk->canonflags;
+}
+
+void termkey_set_canonflags(TermKey *tk, int flags)
+{
+ tk->canonflags = flags;
+
+ if(tk->canonflags & TERMKEY_CANON_SPACESYMBOL)
+ tk->flags |= TERMKEY_FLAG_SPACESYMBOL;
+ else
+ tk->flags &= ~TERMKEY_FLAG_SPACESYMBOL;
+}
+
static void eat_bytes(TermKey *tk, size_t count)
{
if(count >= tk->buffcount) {
@@ -571,9 +595,9 @@ static void emit_codepoint(TermKey *tk, long codepoint, TermKeyKey *key)
void termkey_canonicalise(TermKey *tk, TermKeyKey *key)
{
- int flags = tk->flags;
+ int flags = tk->canonflags;
- if(flags & TERMKEY_FLAG_SPACESYMBOL) {
+ if(flags & TERMKEY_CANON_SPACESYMBOL) {
if(key->type == TERMKEY_TYPE_UNICODE && key->code.number == 0x20) {
key->type = TERMKEY_TYPE_KEYSYM;
key->code.sym = TERMKEY_SYM_SPACE;