From d46f72fc1af33a3f184bd1ffe4e3eb656ae5147d Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evans Date: Wed, 8 Oct 2008 00:12:41 +0100 Subject: Moved all of the C0 registration and 'do_codepoint' logic out of driver-csi back into termkey via another protected method 'emit_codepoint' --- termkey-internal.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'termkey-internal.h') diff --git a/termkey-internal.h b/termkey-internal.h index 271e628..9abc43d 100644 --- a/termkey-internal.h +++ b/termkey-internal.h @@ -13,6 +13,13 @@ struct termkey_driver termkey_result (*getkey)(termkey_t *tk, termkey_key *key); }; +struct keyinfo { + termkey_type type; + termkey_keysym sym; + int modifier_mask; + int modifier_set; +}; + struct termkey { int fd; int flags; @@ -31,6 +38,9 @@ struct termkey { int nkeynames; const char **keynames; + // There are 32 C0 codes + struct keyinfo c0[32]; + struct termkey_driver driver; void *driver_info; @@ -38,9 +48,21 @@ struct termkey { // want exported as real symbols in the library struct { void (*eat_bytes)(termkey_t *tk, size_t count); + void (*emit_codepoint)(termkey_t *tk, int codepoint, termkey_key *key); } method; }; extern struct termkey_driver termkey_driver_csi; +// Keep this here for now since it's tiny +static inline int utf8_seqlen(int codepoint) +{ + if(codepoint < 0x0000080) return 1; + if(codepoint < 0x0000800) return 2; + if(codepoint < 0x0010000) return 3; + if(codepoint < 0x0200000) return 4; + if(codepoint < 0x4000000) return 5; + return 6; +} + #endif -- cgit v1.2.3-70-g09d2