diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 4 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 36 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 2 |
3 files changed, 31 insertions, 11 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 3877f676e..dbbf97a2f 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -598,7 +598,7 @@ COMMAND_CALLBACK(buffer) ptr_buffer2 = ptr_buffer2->next_buffer) { if ((ptr_buffer2->number == ptr_buffer->number) - && (ptr_buffer2->type == GUI_BUFFER_TYPE_FORMATTED)) + && ptr_buffer2->clear) { gui_buffer_clear (ptr_buffer2); } @@ -609,7 +609,7 @@ COMMAND_CALLBACK(buffer) } else { - if (buffer->type == GUI_BUFFER_TYPE_FORMATTED) + if (buffer->clear) gui_buffer_clear (buffer); } diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 65ab5cd3c..b0570b71c 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -76,7 +76,7 @@ char *gui_buffer_notify_string[GUI_BUFFER_NUM_NOTIFY] = char *gui_buffer_properties_get_integer[] = { "number", "layout_number", "layout_number_merge_order", "type", "notify", - "num_displayed", "active", "print_hooks_enabled", "day_change", + "num_displayed", "active", "print_hooks_enabled", "day_change", "clear", "lines_hidden", "prefix_max_length", "time_for_each_line", "nicklist", "nicklist_case_sensitive", "nicklist_max_length", "nicklist_display_groups", "nicklist_count", "nicklist_groups_count", "nicklist_nicks_count", @@ -97,13 +97,14 @@ char *gui_buffer_properties_get_pointer[] = NULL }; char *gui_buffer_properties_set[] = -{ "unread", "display", "print_hooks_enabled", "day_change", "number", "name", - "short_name", "type", "notify", "title", "time_for_each_line", "nicklist", - "nicklist_case_sensitive", "nicklist_display_groups", "highlight_words", - "highlight_words_add", "highlight_words_del", "highlight_regex", - "highlight_tags_restrict", "highlight_tags", "hotlist_max_level_nicks", - "hotlist_max_level_nicks_add", "hotlist_max_level_nicks_del", - "input", "input_pos", "input_get_unknown_commands", +{ "unread", "display", "print_hooks_enabled", "day_change", "clear", "number", + "name", "short_name", "type", "notify", "title", "time_for_each_line", + "nicklist", "nicklist_case_sensitive", "nicklist_display_groups", + "highlight_words", "highlight_words_add", "highlight_words_del", + "highlight_regex", "highlight_tags_restrict", "highlight_tags", + "hotlist_max_level_nicks", "hotlist_max_level_nicks_add", + "hotlist_max_level_nicks_del", "input", "input_pos", + "input_get_unknown_commands", NULL }; @@ -592,6 +593,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, new_buffer->active = 1; new_buffer->print_hooks_enabled = 1; new_buffer->day_change = 1; + new_buffer->clear = 1; /* close callback */ new_buffer->close_callback = close_callback; @@ -980,6 +982,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property) return buffer->print_hooks_enabled; else if (string_strcasecmp (property, "day_change") == 0) return buffer->day_change; + else if (string_strcasecmp (property, "clear") == 0) + return buffer->clear; else if (string_strcasecmp (property, "lines_hidden") == 0) return buffer->lines->lines_hidden; else if (string_strcasecmp (property, "prefix_max_length") == 0) @@ -1166,6 +1170,9 @@ gui_buffer_set_type (struct t_gui_buffer *buffer, enum t_gui_buffer_type type) gui_line_free_all (buffer); buffer->type = type; + if (type == GUI_BUFFER_TYPE_FREE) + buffer->clear = 0; + gui_buffer_ask_chat_refresh (buffer, 2); (void) hook_signal_send ("buffer_type_changed", @@ -1751,6 +1758,13 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property, gui_buffer_ask_chat_refresh (buffer, 2); } } + else if (string_strcasecmp (property, "clear") == 0) + { + error = NULL; + number = strtol (value, &error, 10); + if (error && !error[0]) + buffer->clear = (number) ? 1 : 0; + } else if (string_strcasecmp (property, "number") == 0) { error = NULL; @@ -2442,7 +2456,7 @@ gui_buffer_clear_all () for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { - if (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATTED) + if (ptr_buffer->clear) gui_buffer_clear (ptr_buffer); } } @@ -3809,6 +3823,7 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_buffer, active, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, print_hooks_enabled, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, day_change, INTEGER, 0, NULL, NULL); + HDATA_VAR(struct t_gui_buffer, clear, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, close_callback, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, close_callback_data, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, title, STRING, 0, NULL, NULL); @@ -3985,6 +4000,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist, return 0; if (!infolist_new_var_integer (ptr_item, "day_change", buffer->day_change)) return 0; + if (!infolist_new_var_integer (ptr_item, "clear", buffer->clear)) + return 0; if (!infolist_new_var_integer (ptr_item, "first_line_not_read", buffer->lines->first_line_not_read)) return 0; if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines->lines_hidden)) @@ -4191,6 +4208,7 @@ gui_buffer_print_log () log_printf (" active. . . . . . . . . : %d", ptr_buffer->active); log_printf (" print_hooks_enabled . . : %d", ptr_buffer->print_hooks_enabled); log_printf (" day_change. . . . . . . : %d", ptr_buffer->day_change); + log_printf (" clear . . . . . . . . . : %d", ptr_buffer->clear); log_printf (" close_callback. . . . . : 0x%lx", ptr_buffer->close_callback); log_printf (" close_callback_data . . : 0x%lx", ptr_buffer->close_callback_data); log_printf (" title . . . . . . . . . : '%s'", ptr_buffer->title); diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index c9d8e2674..25298bba7 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -98,6 +98,8 @@ struct t_gui_buffer /* 2 = the only active (merged) */ int print_hooks_enabled; /* 1 if print hooks are enabled */ int day_change; /* 1 if "day change" displayed */ + int clear; /* 1 if clear of buffer is allowed */ + /* with command /buffer clear */ /* close callback */ int (*close_callback)(void *data, /* called when buffer is closed */ |