mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
core: fix chat colors at certain positions not being applied
The new rendering of multiline lines had some issues with colors at certain positions not being applied. The color would not be applied if the color code was at either of these positions: - At the start of a line after a newline character - At the end of a line after a space and before a newline character - At a line by itself before a newline character The way I had done it by considering newline characters as a word in gui_chat_get_word_info with a variable specifying that it's newline characters became messy and didn't really make sense, so rather than doing this, I changed gui_chat_get_word_info to stop before the first newline character. That way, we can just check if we are at a newline character at the start of the loop, and don't need any more special handling. Fixes #1928
This commit is contained in:
committed by
Sébastien Helleu
parent
f1a826a116
commit
96f41ce4bf
@@ -34,23 +34,19 @@ extern "C"
|
||||
#define WEE_GET_WORD_INFO(__result_word_start_offset, \
|
||||
__result_word_end_offset, \
|
||||
__result_word_length_with_spaces, \
|
||||
__result_word_length, \
|
||||
__result_word_is_newlines, __string) \
|
||||
__result_word_length, __string) \
|
||||
word_start_offset = -2; \
|
||||
word_end_offset = -2; \
|
||||
word_length_with_spaces = -2; \
|
||||
word_length = -2; \
|
||||
word_is_newlines = -2; \
|
||||
gui_chat_get_word_info (gui_windows, __string, \
|
||||
&word_start_offset, &word_end_offset, \
|
||||
&word_length_with_spaces, &word_length, \
|
||||
&word_is_newlines); \
|
||||
&word_length_with_spaces, &word_length); \
|
||||
LONGS_EQUAL(__result_word_start_offset, word_start_offset); \
|
||||
LONGS_EQUAL(__result_word_end_offset, word_end_offset); \
|
||||
LONGS_EQUAL(__result_word_length_with_spaces, \
|
||||
word_length_with_spaces); \
|
||||
LONGS_EQUAL(__result_word_length, word_length); \
|
||||
LONGS_EQUAL(__result_word_is_newlines, word_is_newlines);
|
||||
LONGS_EQUAL(__result_word_length, word_length);
|
||||
|
||||
TEST_GROUP(GuiChat)
|
||||
{
|
||||
@@ -338,19 +334,36 @@ TEST(GuiChat, StringPos)
|
||||
TEST(GuiChat, GetWordInfo)
|
||||
{
|
||||
int word_start_offset, word_end_offset, word_length_with_spaces;
|
||||
int word_length, word_is_newlines;
|
||||
int word_length;
|
||||
char string[32];
|
||||
|
||||
WEE_GET_WORD_INFO (0, 0, 0, -1, 0, NULL);
|
||||
WEE_GET_WORD_INFO (0, 0, 0, -1, 0, "");
|
||||
WEE_GET_WORD_INFO (0, 0, 1, 1, 0, "a");
|
||||
WEE_GET_WORD_INFO (0, 2, 3, 3, 0, "abc");
|
||||
WEE_GET_WORD_INFO (2, 4, 5, 3, 0, " abc");
|
||||
WEE_GET_WORD_INFO (2, 4, 5, 3, 0, " abc ");
|
||||
WEE_GET_WORD_INFO (0, 4, 5, 5, 0, "first second");
|
||||
WEE_GET_WORD_INFO (1, 5, 6, 5, 0, " first second");
|
||||
WEE_GET_WORD_INFO (0, 0, 1, 1, 1, "\nabc");
|
||||
WEE_GET_WORD_INFO (2, 2, 3, 1, 1, " \nabc");
|
||||
WEE_GET_WORD_INFO (2, 3, 4, 2, 1, " \n\nabc");
|
||||
WEE_GET_WORD_INFO (0, 0, 0, -1, NULL);
|
||||
WEE_GET_WORD_INFO (0, 0, 0, -1, "");
|
||||
WEE_GET_WORD_INFO (0, 0, 1, 1, "a");
|
||||
WEE_GET_WORD_INFO (0, 2, 3, 3, "abc");
|
||||
WEE_GET_WORD_INFO (2, 4, 5, 3, " abc");
|
||||
WEE_GET_WORD_INFO (2, 4, 5, 3, " abc ");
|
||||
WEE_GET_WORD_INFO (0, 4, 5, 5, "first second");
|
||||
WEE_GET_WORD_INFO (1, 5, 6, 5, " first second");
|
||||
|
||||
WEE_GET_WORD_INFO (0, -1, 0, 0, "\nabc");
|
||||
WEE_GET_WORD_INFO (0, 0, 1, 0, " \nabc");
|
||||
WEE_GET_WORD_INFO (0, 1, 2, 0, " \nabc");
|
||||
WEE_GET_WORD_INFO (0, 4, 5, 5, "first\nsecond");
|
||||
|
||||
snprintf (string, sizeof (string), "%c%c01abc", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR);
|
||||
WEE_GET_WORD_INFO (4, 6, 3, 3, string);
|
||||
snprintf (string, sizeof (string), "abc%c%c01", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR);
|
||||
WEE_GET_WORD_INFO (0, 6, 3, 3, string);
|
||||
snprintf (string, sizeof (string), " %c%c01 abc", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR);
|
||||
WEE_GET_WORD_INFO (6, 8, 5, 3, string);
|
||||
|
||||
snprintf (string, sizeof (string), "\n%c%c01abc", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR);
|
||||
WEE_GET_WORD_INFO (0, -1, 0, 0, string);
|
||||
snprintf (string, sizeof (string), "%c%c01\nabc", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR);
|
||||
WEE_GET_WORD_INFO (0, 3, 0, 0, string);
|
||||
snprintf (string, sizeof (string), " %c%c01 \nabc", GUI_COLOR_COLOR_CHAR, GUI_COLOR_FG_CHAR);
|
||||
WEE_GET_WORD_INFO (0, 5, 2, 0, string);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user