diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-04-24 15:25:17 +0100 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-04-24 15:25:17 +0100 |
commit | f33513282a2fb5e55101ef1e0c8d4387d351e42d (patch) | |
tree | 8a944b520e4d6d0ee816cc69e883c590e9d96676 /termkey-internal.h | |
parent | 3b3a7c2f45ad99e66487c503668865711d368210 (diff) | |
download | termo-f33513282a2fb5e55101ef1e0c8d4387d351e42d.tar.gz termo-f33513282a2fb5e55101ef1e0c8d4387d351e42d.tar.xz termo-f33513282a2fb5e55101ef1e0c8d4387d351e42d.zip |
Created abstract accessors for getting/setting key event line/col counts
Diffstat (limited to 'termkey-internal.h')
-rw-r--r-- | termkey-internal.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/termkey-internal.h b/termkey-internal.h index d23f68c..1ebdecb 100644 --- a/termkey-internal.h +++ b/termkey-internal.h @@ -64,6 +64,28 @@ struct TermKey { } method; }; +static inline void termkey_key_get_linecol(const TermKeyKey *key, int *line, int *col) +{ + if(col) + *col = (unsigned char)key->code.mouse[1] | ((unsigned char)key->code.mouse[3] & 0x0f) << 8; + + if(line) + *line = (unsigned char)key->code.mouse[2] | ((unsigned char)key->code.mouse[3] & 0x70) << 4; +} + +static inline void termkey_key_set_linecol(TermKeyKey *key, int line, int col) +{ + if(line > 0xfff) + line = 0xfff; + + if(col > 0x7ff) + col = 0x7ff; + + key->code.mouse[1] = (line & 0x0ff); + key->code.mouse[2] = (col & 0x0ff); + key->code.mouse[3] = (line & 0xf00) >> 8 | (col & 0x300) >> 4; +} + extern struct TermKeyDriver termkey_driver_csi; extern struct TermKeyDriver termkey_driver_ti; |