1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 08:43:13 +02:00

core: move functions from gui-chat.c to gui-line.c

Functions moved and renamed:

- gui_chat_build_string_prefix_message -> gui_line_build_string_prefix_message
- gui_chat_build_string_message_tags -> gui_line_build_string_message_tags
This commit is contained in:
Sébastien Helleu
2022-01-28 07:26:11 +01:00
parent 3110740777
commit 05a9457504
5 changed files with 70 additions and 70 deletions
+1 -1
View File
@@ -1421,7 +1421,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (line->data->message && line->data->message[0])
{
message_with_tags = (gui_chat_display_tags) ?
gui_chat_build_string_message_tags (line) : NULL;
gui_line_build_string_message_tags (line) : NULL;
ptr_data = (message_with_tags) ?
message_with_tags : line->data->message;
message_with_search = NULL;
-65
View File
@@ -579,71 +579,6 @@ gui_chat_change_time_format ()
}
}
/*
* Builds a string with prefix and message.
*
* Note: result must be freed after use.
*/
char *
gui_chat_build_string_prefix_message (struct t_gui_line *line)
{
char **string, *string_without_colors;
string = string_dyn_alloc (256);
if (!string)
return NULL;
if (line->data->prefix)
string_dyn_concat (string, line->data->prefix, -1);
string_dyn_concat (string, "\t", -1);
if (line->data->message)
string_dyn_concat (string, line->data->message, -1);
string_without_colors = gui_color_decode (*string, NULL);
string_dyn_free (string, 1);
return string_without_colors;
}
/*
* Builds a string with message and tags.
*
* Note: result must be freed after use.
*/
char *
gui_chat_build_string_message_tags (struct t_gui_line *line)
{
int i;
char **string, *result;
string = string_dyn_alloc (256);
if (!string)
return NULL;
if (line->data->message)
string_dyn_concat (string, line->data->message, -1);
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), -1);
string_dyn_concat (string, " [", -1);
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_TAGS), -1);
for (i = 0; i < line->data->tags_count; i++)
{
string_dyn_concat (string, line->data->tags_array[i], -1);
if (i < line->data->tags_count - 1)
string_dyn_concat (string, ",", -1);
}
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), -1);
string_dyn_concat (string, "]", -1);
result = strdup (*string);
string_dyn_free (string, 1);
return result;
}
/*
* Checks if the buffer pointer is valid for printing a chat message,
* according to buffer type.
-2
View File
@@ -85,8 +85,6 @@ extern void gui_chat_get_word_info (struct t_gui_window *window,
extern char *gui_chat_get_time_string (time_t date);
extern int gui_chat_get_time_length ();
extern void gui_chat_change_time_format ();
extern char *gui_chat_build_string_prefix_message (struct t_gui_line *line);
extern char *gui_chat_build_string_message_tags (struct t_gui_line *line);
extern int gui_chat_buffer_valid (struct t_gui_buffer *buffer,
int buffer_type);
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
+67 -2
View File
@@ -372,6 +372,71 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
+ length_suffix;
}
/*
* Builds a string with prefix and message.
*
* Note: result must be freed after use.
*/
char *
gui_line_build_string_prefix_message (struct t_gui_line *line)
{
char **string, *string_without_colors;
string = string_dyn_alloc (256);
if (!string)
return NULL;
if (line->data->prefix)
string_dyn_concat (string, line->data->prefix, -1);
string_dyn_concat (string, "\t", -1);
if (line->data->message)
string_dyn_concat (string, line->data->message, -1);
string_without_colors = gui_color_decode (*string, NULL);
string_dyn_free (string, 1);
return string_without_colors;
}
/*
* Builds a string with message and tags.
*
* Note: result must be freed after use.
*/
char *
gui_line_build_string_message_tags (struct t_gui_line *line)
{
int i;
char **string, *result;
string = string_dyn_alloc (256);
if (!string)
return NULL;
if (line->data->message)
string_dyn_concat (string, line->data->message, -1);
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), -1);
string_dyn_concat (string, " [", -1);
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_TAGS), -1);
for (i = 0; i < line->data->tags_count; i++)
{
string_dyn_concat (string, line->data->tags_array[i], -1);
if (i < line->data->tags_count - 1)
string_dyn_concat (string, ",", -1);
}
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), -1);
string_dyn_concat (string, "]", -1);
result = strdup (*string);
string_dyn_free (string, 1);
return result;
}
/*
* Checks if a line is displayed (no filter on line or filters disabled).
*
@@ -1623,7 +1688,7 @@ gui_line_add (struct t_gui_line *line)
GUI_HOTLIST_HIGHLIGHT, NULL);
if (!weechat_upgrading)
{
message_for_signal = gui_chat_build_string_prefix_message (line);
message_for_signal = gui_line_build_string_prefix_message (line);
if (message_for_signal)
{
(void) hook_signal_send ("weechat_highlight",
@@ -1638,7 +1703,7 @@ gui_line_add (struct t_gui_line *line)
if (!weechat_upgrading
&& (line->data->notify_level == GUI_HOTLIST_PRIVATE))
{
message_for_signal = gui_chat_build_string_prefix_message (line);
message_for_signal = gui_line_build_string_prefix_message (line);
if (message_for_signal)
{
(void) hook_signal_send ("weechat_pv",
+2
View File
@@ -80,6 +80,8 @@ extern void gui_line_get_prefix_for_display (struct t_gui_line *line,
extern int gui_line_get_align (struct t_gui_buffer *buffer,
struct t_gui_line *line,
int with_suffix, int first_line);
extern char *gui_line_build_string_prefix_message (struct t_gui_line *line);
extern char *gui_line_build_string_message_tags (struct t_gui_line *line);
extern int gui_line_is_displayed (struct t_gui_line *line);
extern struct t_gui_line *gui_line_get_first_displayed (struct t_gui_buffer *buffer);
extern struct t_gui_line *gui_line_get_last_displayed (struct t_gui_buffer *buffer);