diff options
author | wm4 <wm4@mplayer2.org> | 2012-01-13 07:38:40 +0100 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2012-03-25 22:30:37 +0300 |
commit | 166a7de4cf94a78c34040b47a929a72d12f2945f (patch) | |
tree | 3b326a949d7add071c3dc92a1ab1eb5d86e194da /bstr.h | |
parent | 3e6e80a32c04e38c7d2fa77e4bcf1401e792dc7a (diff) | |
download | mpv-166a7de4cf94a78c34040b47a929a72d12f2945f.tar.bz2 mpv-166a7de4cf94a78c34040b47a929a72d12f2945f.tar.xz |
input: allow unicode keys and reassign internal key codes
This moves all key codes above the highest valid unicode code point
(which is 0x10FFFF). All key codes below MP_KEY_BASE now directly map
to unicode (KEY_ENTER is 13, carriage return). Configuration files
(input.conf) can contain unicode characters in UTF-8 to map non-ASCII
characters/keys.
This shouldn't change anything user visible, except that "direct key
codes" (as used in input.conf) will change their meaning.
Parts of the bstr functions taken from libavutil's GET_UTF8 and
slightly modified.
Diffstat (limited to 'bstr.h')
-rw-r--r-- | bstr.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -69,6 +69,19 @@ double bstrtod(struct bstr str, struct bstr *rest); void bstr_lower(struct bstr str); int bstr_sscanf(struct bstr str, const char *format, ...); +// Decode the UTF-8 code point at the start of the string,, and return the +// character. +// After calling this function, *out_next will point to the next character. +// out_next can be NULL. +// On error, -1 is returned, and *out_next is not modified. +int bstr_decode_utf8(struct bstr str, struct bstr *out_next); + +// Return the length of the UTF-8 sequence that starts with the given byte. +// Given a string char *s, the next UTF-8 code point is to be expected at +// s + bstr_parse_utf8_code_length(s[0]) +// On error, -1 is returned. On success, it returns a value in the range [1, 4]. +int bstr_parse_utf8_code_length(unsigned char b); + static inline struct bstr bstr_cut(struct bstr str, int n) { if (n > str.len) |