diff options
author | Jesse Luehrs <doy@tozt.net> | 2017-01-25 22:27:17 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2017-01-25 22:27:17 -0500 |
commit | da065599801b35070a83217ab79d7c22a2b5024b (patch) | |
tree | d6abf65cb810fbf4f29414d9bb82ec3273c929c0 /src/unicode-extra.c | |
parent | 32f97d8385d591ec4026f3fb5a1ab8e34e12a06d (diff) | |
download | libvt100-da065599801b35070a83217ab79d7c22a2b5024b.tar.gz libvt100-da065599801b35070a83217ab79d7c22a2b5024b.zip |
allow specifying whether or not emoji are wide
vim says yes, weechat says no ¯\_(ツ)_/¯
Diffstat (limited to 'src/unicode-extra.c')
-rw-r--r-- | src/unicode-extra.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/unicode-extra.c b/src/unicode-extra.c index 69e5c76..b661aef 100644 --- a/src/unicode-extra.c +++ b/src/unicode-extra.c @@ -66,15 +66,15 @@ static struct vt100_char_range vt100_wide_emoji[] = { }; static int vt100_is_zero_width(uint32_t codepoint); -static int vt100_is_wide_char(uint32_t codepoint); +static int vt100_is_wide_char(uint32_t codepoint, int wide_emoji); static int vt100_is_wide_emoji(uint32_t codepoint); -int vt100_char_width(uint32_t codepoint) +int vt100_char_width(uint32_t codepoint, int wide_emoji) { if (vt100_is_zero_width(codepoint)) { return 0; } - else if (vt100_is_wide_char(codepoint)) { + else if (vt100_is_wide_char(codepoint, wide_emoji)) { return 2; } else { @@ -89,9 +89,10 @@ static int vt100_is_zero_width(uint32_t codepoint) return g_unichar_iszerowidth(codepoint) || codepoint == 0xAD; } -static int vt100_is_wide_char(uint32_t codepoint) +static int vt100_is_wide_char(uint32_t codepoint, int wide_emoji) { - return g_unichar_iswide(codepoint) || vt100_is_wide_emoji(codepoint); + return g_unichar_iswide(codepoint) + || (wide_emoji && vt100_is_wide_emoji(codepoint)); } static int vt100_is_wide_emoji(uint32_t codepoint) |