summaryrefslogtreecommitdiff
path: root/tests/unit/gui
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-05-28 14:34:38 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-29 17:10:25 +0200
commit96f41ce4bfdbd57aee7103479faff54d7093e087 (patch)
treeb81e39aecfd0a6c727cfcd99257f9035f68c3d38 /tests/unit/gui
parentf1a826a1169a1b6a4d3d33aa280aaf117dd182a3 (diff)
downloadweechat-96f41ce4bfdbd57aee7103479faff54d7093e087.zip
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
Diffstat (limited to 'tests/unit/gui')
-rw-r--r--tests/unit/gui/test-gui-chat.cpp53
1 files changed, 33 insertions, 20 deletions
diff --git a/tests/unit/gui/test-gui-chat.cpp b/tests/unit/gui/test-gui-chat.cpp
index 99152886b..a9a46569c 100644
--- a/tests/unit/gui/test-gui-chat.cpp
+++ b/tests/unit/gui/test-gui-chat.cpp
@@ -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;
-
- 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");
+ int word_length;
+ char string[32];
+
+ 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);
}
/*