Summary: fix highlighted position in string with full-width
Submitted by: ayanokouzi
Submitted on: 2013年12月11日 09時17分36秒
Priority: 5 - Normal
Assigned to: None
Discussion Lock: Any
When highlighting a word in string containing full-width chars ahead
of the search word, wrong position is highlighted.
This is a patch for this bug.
This bug is caused by position counting error in
"gui_chat_string_real_pos" function. According to the source of
"gui_color_emphasize" function, argument "pos" for function
"gui_chat_string_real_pos" is expected to be a number of UTF-8 chars,
but inside "gui_chat_string_real_pos" function, argument "pos" is
treated as the width of string on screen. So, if argument "string"
doesn't contain full-width chars, it's always fine. But if there is
full-width char ahead of search word, wrong position is highlighted.
I changed some things:
- use of only one function to not duplicate code, with new argument: "int
use_screen_size", to use size on screen instead of number of chars,
- use of "use_screen_size" == 0 only in text emphasis (I'm not sure it was
intentional in your patch to not use width any more in many calls to the
My tests were OK, but if you think something is wrong with these changes,
please let me know.