mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
core: render newline characters in chat line messages
If a chat line message contains a newline character (\n) it was previously rendered as J with reverse video. This commit makes it render as an actual newline instead, so messages with multiple lines become supported. The rendering is fixed in normal mode as well as bare mode both when scrolled to the bottom and when scrolled up (which is different code paths). Focus events has also been updated to support this (except for _chat_line_y which returns -1 for all lines, but the docs says this variable is only for buffers with free content). Currently, the only way to include a \n in a chat line message is with hdata_update because printf splits on \n and creates multiple separate lines, but hopefully either printf can be changed to not split on \n, or a new command which doesn't split can be added.
This commit is contained in:
committed by
Sébastien Helleu
parent
2b7f745369
commit
031bd45e36
@@ -34,19 +34,23 @@ extern "C"
|
||||
#define WEE_GET_WORD_INFO(__result_word_start_offset, \
|
||||
__result_word_end_offset, \
|
||||
__result_word_length_with_spaces, \
|
||||
__result_word_length, __string) \
|
||||
__result_word_length, \
|
||||
__result_word_is_newlines, __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_length_with_spaces, &word_length, \
|
||||
&word_is_newlines); \
|
||||
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_length, word_length); \
|
||||
LONGS_EQUAL(__result_word_is_newlines, word_is_newlines);
|
||||
|
||||
TEST_GROUP(GuiChat)
|
||||
{
|
||||
@@ -334,16 +338,19 @@ TEST(GuiChat, StringPos)
|
||||
TEST(GuiChat, GetWordInfo)
|
||||
{
|
||||
int word_start_offset, word_end_offset, word_length_with_spaces;
|
||||
int word_length;
|
||||
int word_length, word_is_newlines;
|
||||
|
||||
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, 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");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user