diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2013-04-15 01:21:04 +0200 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2013-04-15 01:21:04 +0200 |
commit | 01b4d568b99fc48fdab0ec628a550dfbeaa7b021 (patch) | |
tree | 6629463cfe74fc9be48a9c631e419ca7b51308c2 /src/editor.h | |
parent | 5a6fe0574c77342f29370219fb9010b72d6d3a00 (diff) | |
download | ratpoison-01b4d568b99fc48fdab0ec628a550dfbeaa7b021.zip |
Support UTF-8 in the input bar
* introduce RP_IS_UTF8_{CHAR,CONT,START} macros. Those yield non-zero
only if the locale is UTF-8.
* use those macros in editor.c to properly handle UTF-8 multibyte
characters.
* use them also in input.c:update_input_window, to draw the cursor
Reviewing and comments are welcome.
Patches for generic support of multibyte encodings are welcome too.
UTF-8 was chosen because of its processing simplicity and its wide use,
not because of any political opinion or religious belief. ;)
Diffstat (limited to 'src/editor.h')
-rw-r--r-- | src/editor.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/editor.h b/src/editor.h index f3ffa31..b6e4b76 100644 --- a/src/editor.h +++ b/src/editor.h @@ -35,6 +35,11 @@ edit_status EDIT_NO_OP }; +/* UTF-8 handling macros */ +#define RP_IS_UTF8_CHAR(c) (defaults.utf8_locale && (c) & 0xC0) +#define RP_IS_UTF8_START(c) (defaults.utf8_locale && ((c) & 0xC0) == 0xC0) +#define RP_IS_UTF8_CONT(c) (defaults.utf8_locale && ((c) & 0xC0) == 0x80) + /* Input line functions */ rp_input_line *input_line_new (char *prompt, char *preinput, int history_id, completion_fn fn); void input_line_free (rp_input_line *line); |