1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 21:36:37 +02:00

core: add buffer property "modes"

This commit is contained in:
Sébastien Helleu
2024-05-12 09:26:10 +02:00
parent e57777acb1
commit e7b2d98b6e
11 changed files with 114 additions and 8 deletions
+3
View File
@@ -523,6 +523,9 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
ptr_buffer->title = (str) ? strdup (str) : NULL;
}
/* modes */
gui_buffer_set_modes (ptr_buffer, infolist_string (infolist, "modes"));
/* first line not read */
ptr_buffer->lines->first_line_not_read =
infolist_integer (infolist, "first_line_not_read");
+5 -3
View File
@@ -1301,10 +1301,12 @@ gui_bar_item_buffer_modes_cb (const void *pointer, void *data,
(void) data;
(void) item;
(void) window;
(void) buffer;
(void) extra_info;
return NULL;
if (!buffer)
return NULL;
return (buffer->modes) ? strdup (buffer->modes) : NULL;
}
/*
@@ -2387,7 +2389,7 @@ gui_bar_item_init ()
gui_bar_item_new (NULL,
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES],
&gui_bar_item_buffer_modes_cb, NULL, NULL);
gui_bar_item_hook_signal ("window_switch;buffer_switch",
gui_bar_item_hook_signal ("window_switch;buffer_switch;buffer_modes_changed",
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES]);
/* buffer filter */
+37 -4
View File
@@ -110,9 +110,10 @@ char *gui_buffer_properties_get_integer[] =
};
char *gui_buffer_properties_get_string[] =
{ "id", "plugin", "name", "full_name", "old_full_name", "short_name", "title",
"nicklist_last_id_assigned", "input_prompt", "input", "text_search_input",
"highlight_words", "highlight_disable_regex", "highlight_regex",
"highlight_tags_restrict", "highlight_tags", "hotlist_max_level_nicks",
"modes", "nicklist_last_id_assigned", "input_prompt", "input",
"text_search_input", "highlight_words", "highlight_disable_regex",
"highlight_regex", "highlight_tags_restrict", "highlight_tags",
"hotlist_max_level_nicks",
NULL
};
char *gui_buffer_properties_get_pointer[] =
@@ -123,7 +124,7 @@ char *gui_buffer_properties_get_pointer[] =
char *gui_buffer_properties_set[] =
{ "hotlist", "unread", "display", "hidden", "print_hooks_enabled", "day_change",
"clear", "filter", "number", "name", "short_name", "type", "notify", "title",
"time_for_each_line", "nicklist", "nicklist_case_sensitive",
"modes", "time_for_each_line", "nicklist", "nicklist_case_sensitive",
"nicklist_display_groups", "highlight_words", "highlight_words_add",
"highlight_words_del", "highlight_disable_regex", "highlight_regex",
"highlight_tags_restrict", "highlight_tags", "hotlist_max_level_nicks",
@@ -867,6 +868,9 @@ gui_buffer_new_props_with_id (long long id,
/* title */
new_buffer->title = NULL;
/* modes */
new_buffer->modes = NULL;
/* chat content */
new_buffer->own_lines = gui_line_lines_alloc ();
new_buffer->mixed_lines = NULL;
@@ -1538,6 +1542,8 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
return gui_buffer_type_string[buffer->type];
else if (strcmp (property, "title") == 0)
return buffer->title;
else if (strcmp (property, "modes") == 0)
return buffer->modes;
else if (strcmp (property, "nicklist_last_id_assigned") == 0)
{
snprintf (str_value, sizeof (str_value),
@@ -1793,6 +1799,24 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title)
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
* Sets modes for a buffer.
*/
void
gui_buffer_set_modes (struct t_gui_buffer *buffer, const char *modes)
{
if (!buffer || (string_strcmp (buffer->modes, modes) == 0))
return;
free (buffer->modes);
buffer->modes = (modes && modes[0]) ? strdup (modes) : NULL;
(void) gui_buffer_send_signal (buffer,
"buffer_modes_changed",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
* Sets flag "time for each line" for a buffer.
*/
@@ -2650,6 +2674,10 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
{
gui_buffer_set_title (buffer, value);
}
else if (strcmp (property, "modes") == 0)
{
gui_buffer_set_modes (buffer, value);
}
else if (strcmp (property, "time_for_each_line") == 0)
{
error = NULL;
@@ -3777,6 +3805,7 @@ gui_buffer_close (struct t_gui_buffer *buffer)
free (buffer->old_full_name);
free (buffer->short_name);
free (buffer->title);
free (buffer->modes);
free (buffer->input_prompt);
free (buffer->input_buffer);
free (buffer->input_undo_snap);
@@ -5202,6 +5231,7 @@ gui_buffer_hdata_buffer_cb (const void *pointer, void *data,
HDATA_VAR(struct t_gui_buffer, close_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, closing, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, title, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, modes, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, own_lines, POINTER, 0, NULL, "lines");
HDATA_VAR(struct t_gui_buffer, mixed_lines, POINTER, 0, NULL, "lines");
HDATA_VAR(struct t_gui_buffer, lines, POINTER, 0, NULL, "lines");
@@ -5445,6 +5475,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_string (ptr_item, "title", buffer->title))
return 0;
if (!infolist_new_var_string (ptr_item, "modes", buffer->modes))
return 0;
if (!infolist_new_var_integer (ptr_item, "input", buffer->input))
return 0;
if (!infolist_new_var_integer (ptr_item, "input_get_any_user_data", buffer->input_get_any_user_data))
@@ -5659,6 +5691,7 @@ gui_buffer_print_log ()
log_printf (" close_callback_data . . : %p", ptr_buffer->close_callback_data);
log_printf (" closing . . . . . . . . : %d", ptr_buffer->closing);
log_printf (" title . . . . . . . . . : '%s'", ptr_buffer->title);
log_printf (" modes . . . . . . . . . : '%s'", ptr_buffer->modes);
log_printf (" own_lines . . . . . . . : %p", ptr_buffer->own_lines);
gui_lines_print_log (ptr_buffer->own_lines);
log_printf (" mixed_lines . . . . . . : %p", ptr_buffer->mixed_lines);
+5
View File
@@ -146,6 +146,9 @@ struct t_gui_buffer
/* buffer title */
char *title; /* buffer title */
/* buffer modes */
char *modes; /* buffer modes */
/* chat content */
struct t_gui_lines *own_lines; /* lines (for this buffer only) */
struct t_gui_lines *mixed_lines; /* mixed lines (if buffers merged) */
@@ -373,6 +376,8 @@ extern void gui_buffer_ask_chat_refresh (struct t_gui_buffer *buffer,
int refresh);
extern void gui_buffer_set_title (struct t_gui_buffer *buffer,
const char *new_title);
extern void gui_buffer_set_modes (struct t_gui_buffer *buffer,
const char *new_modes);
extern void gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
const char *new_highlight_words);
extern void gui_buffer_set_highlight_disable_regex (struct t_gui_buffer *buffer,