mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 05:16:38 +02:00
core: fix text emphasis with wide chars on screen like japanese (patch #8253) (patch from Ryuunosuke Ayanokouzi)
This commit is contained in:
@@ -11,6 +11,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
|
||||
== Version 0.4.3 (under dev)
|
||||
|
||||
* core: fix text emphasis with wide chars on screen like japanese (patch #8253)
|
||||
* core: add signal "buffer_cleared"
|
||||
* core: remove option on /unset of plugin description option (plugins.desc.xxx)
|
||||
(bug #40768)
|
||||
|
||||
@@ -582,7 +582,9 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
|
||||
}
|
||||
|
||||
/* compute new start for displaying input */
|
||||
new_start_input = pos_after_start_input + gui_chat_string_real_pos (pos_after_start_input, diff);
|
||||
new_start_input = pos_after_start_input +
|
||||
gui_chat_string_real_pos (pos_after_start_input,
|
||||
diff, 1);
|
||||
if (new_start_input > pos_cursor)
|
||||
new_start_input = pos_cursor;
|
||||
|
||||
|
||||
@@ -527,7 +527,8 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
if (window->win_chat_cursor_x + chars_to_display > gui_chat_get_real_width (window))
|
||||
{
|
||||
num_displayed = gui_chat_get_real_width (window) - window->win_chat_cursor_x;
|
||||
pos_saved_char = gui_chat_string_real_pos (ptr_data, num_displayed);
|
||||
pos_saved_char = gui_chat_string_real_pos (ptr_data, num_displayed,
|
||||
1);
|
||||
saved_char = ptr_data[pos_saved_char];
|
||||
ptr_data[pos_saved_char] = '\0';
|
||||
if ((count == 0) || (*lines_displayed >= num_lines - count))
|
||||
@@ -790,7 +791,8 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
short_name,
|
||||
short_name +
|
||||
gui_chat_string_real_pos (short_name,
|
||||
chars_to_display),
|
||||
chars_to_display,
|
||||
1),
|
||||
1, num_lines, count,
|
||||
pre_lines_displayed, lines_displayed,
|
||||
simulate,
|
||||
@@ -1043,9 +1045,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
|
||||
(prefix_highlighted) ? prefix_highlighted : ptr_prefix,
|
||||
(prefix_highlighted) ?
|
||||
prefix_highlighted + gui_chat_string_real_pos (prefix_highlighted,
|
||||
chars_to_display) :
|
||||
chars_to_display, 1) :
|
||||
ptr_prefix + gui_chat_string_real_pos (ptr_prefix,
|
||||
chars_to_display),
|
||||
chars_to_display, 1),
|
||||
1, num_lines, count,
|
||||
pre_lines_displayed,
|
||||
lines_displayed,
|
||||
|
||||
+7
-2
@@ -243,11 +243,16 @@ gui_chat_string_add_offset_screen (const char *string, int offset_screen)
|
||||
* Gets real position in string (ignoring formatting chars like
|
||||
* colors/attributes).
|
||||
*
|
||||
* If argument "use_screen_size" is 0, the "pos" argument is a number of UTF-8
|
||||
* chars.
|
||||
* If argument "use_screen_size" is 1, the "pos" argument is the width of UTF-8
|
||||
* chars on screen.
|
||||
*
|
||||
* Returns real position, in bytes.
|
||||
*/
|
||||
|
||||
int
|
||||
gui_chat_string_real_pos (const char *string, int pos)
|
||||
gui_chat_string_real_pos (const char *string, int pos, int use_screen_size)
|
||||
{
|
||||
const char *real_pos, *real_pos_prev, *ptr_string;
|
||||
int size_on_screen;
|
||||
@@ -267,7 +272,7 @@ gui_chat_string_real_pos (const char *string, int pos)
|
||||
{
|
||||
size_on_screen = gui_chat_char_size_screen (ptr_string);
|
||||
if (size_on_screen > 0)
|
||||
pos -= size_on_screen;
|
||||
pos -= (use_screen_size) ? size_on_screen : 1;
|
||||
ptr_string = utf8_next_char (ptr_string);
|
||||
real_pos_prev = real_pos;
|
||||
real_pos = ptr_string;
|
||||
|
||||
+2
-1
@@ -70,7 +70,8 @@ extern int gui_chat_strlen_screen (const char *string);
|
||||
extern char *gui_chat_string_add_offset (const char *string, int offset);
|
||||
extern char *gui_chat_string_add_offset_screen (const char *string,
|
||||
int offset_screen);
|
||||
extern int gui_chat_string_real_pos (const char *string, int pos);
|
||||
extern int gui_chat_string_real_pos (const char *string, int pos,
|
||||
int use_screen_size);
|
||||
extern int gui_chat_string_pos (const char *string, int real_pos);
|
||||
extern void gui_chat_get_word_info (struct t_gui_window *window,
|
||||
const char *data, int *word_start_offset,
|
||||
|
||||
+4
-2
@@ -700,9 +700,11 @@ gui_color_emphasize (const char *string,
|
||||
* color codes)
|
||||
*/
|
||||
real_pos1 = gui_chat_string_real_pos (ptr_string,
|
||||
gui_chat_string_pos (ptr_no_color, pos1));
|
||||
gui_chat_string_pos (ptr_no_color, pos1),
|
||||
0);
|
||||
real_pos2 = gui_chat_string_real_pos (ptr_string,
|
||||
gui_chat_string_pos (ptr_no_color, pos2));
|
||||
gui_chat_string_pos (ptr_no_color, pos2),
|
||||
0);
|
||||
|
||||
/*
|
||||
* concatenate following strings to the result:
|
||||
|
||||
Reference in New Issue
Block a user