From 578091f051541ffcd68fb755641fd7c45e28977c Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 30 Aug 2017 16:27:29 +0200 Subject: Add support for UTF-8 key bindings A new function keys_wgetch() reads full UTF-8 characters instead of single ASCII characters only. Key bindings for regular ASCII characters are stored in a hash map while the actions of keys with higher code points are stored in a linked list for space efficiency. The key serialization methods are updated to handle UTF-8 characters as well; extended UTF-8 characters (characters not in the ASCII range) are serialized by using the hexadecimal representation of the corresponding code points (e.g. "U+00E4"). Signed-off-by: Lukas Fleischer --- src/calcurse.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/calcurse.h') diff --git a/src/calcurse.h b/src/calcurse.h index ac1baba..f9439b7 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -230,6 +230,7 @@ ((unsigned char)ch >= 0xF0 ? 4 : \ ((unsigned char)ch >= 0xE0 ? 3 : \ ((unsigned char)ch >= 0xC0 ? 2 : 1))))) +#define UTF8_ISMULTI(ch) ((unsigned char)ch >= 0x80) #define UTF8_ISCONT(ch) ((unsigned char)ch >= 0x80 && \ (unsigned char)ch <= 0xBF) @@ -871,11 +872,12 @@ void keys_free(void); void keys_dump_defaults(char *); const char *keys_get_label(enum key); enum key keys_get_action(int); +int keys_wgetch(WINDOW *); enum key keys_get(WINDOW *, int *, int *); int keys_assign_binding(int, enum key); void keys_remove_binding(int, enum key); int keys_str2int(const char *); -const char *keys_int2str(int); +char *keys_int2str(int); int keys_action_count_keys(enum key); const char *keys_action_firstkey(enum key); const char *keys_action_nkey(enum key, int); -- cgit v1.2.3-54-g00ecf