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

core: allow empty short name on buffers (name is used if not set)

This commit is contained in:
Sebastien Helleu
2011-08-14 13:20:03 +02:00
parent 1cb7c6a6c5
commit cc3a4834d0
9 changed files with 81 additions and 60 deletions
+1 -2
View File
@@ -439,8 +439,7 @@ upgrade_weechat_read_cb (void *data,
strdup (infolist_string (infolist, "plugin_name"));
upgrade_current_buffer->short_name =
(infolist_string (infolist, "short_name")) ?
strdup (infolist_string (infolist, "short_name")) :
strdup (infolist_string (infolist, "name"));
strdup (infolist_string (infolist, "short_name")) : NULL;
upgrade_current_buffer->type =
infolist_integer (infolist, "type");
upgrade_current_buffer->notify =
File diff suppressed because it is too large Load Diff
+2
View File
@@ -1147,6 +1147,8 @@ gui_color_buffer_open ()
&gui_color_buffer_close_cb, NULL);
if (gui_color_buffer)
{
if (!gui_color_buffer->short_name)
gui_color_buffer->short_name = strdup ("color");
gui_buffer_set (gui_color_buffer, "type", "free");
gui_buffer_set (gui_color_buffer, "localvar_set_no_log", "1");
gui_buffer_set (gui_color_buffer, "key_bind_meta-c", "/color switch");
+4
View File
@@ -134,6 +134,10 @@ gui_main_init ()
ptr_buffer->num_displayed = 1;
/* set short name */
if (!ptr_buffer->short_name)
ptr_buffer->short_name = strdup (GUI_BUFFER_MAIN);
/* set title for core buffer */
gui_buffer_set_title (ptr_buffer,
"WeeChat " PACKAGE_VERSION " "
+1 -1
View File
@@ -1115,7 +1115,7 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
CONFIG_INTEGER(config_look_hotlist_names_length));
sprintf (buf + strlen (buf), format,
(CONFIG_BOOLEAN(config_look_hotlist_short_names)) ?
ptr_hotlist->buffer->short_name : ptr_hotlist->buffer->name);
gui_buffer_get_short_name (ptr_hotlist->buffer) : ptr_hotlist->buffer->name);
}
else
{
+26 -12
View File
@@ -122,6 +122,18 @@ gui_buffer_get_plugin_name (struct t_gui_buffer *buffer)
return plugin_get_name (buffer->plugin);
}
/*
* gui_buffer_get_short_name: get short name of buffer (of name if short_name
* is NULL)
* Note: this function never returns NULL
*/
const char *
gui_buffer_get_short_name (struct t_gui_buffer *buffer)
{
return (buffer->short_name) ? buffer->short_name : buffer->name;
}
/*
* gui_buffer_local_var_add: add a new local variable to a buffer
*/
@@ -404,7 +416,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
struct t_gui_completion *new_completion;
int first_buffer_creation;
if (!name)
if (!name || !name[0])
return NULL;
if (gui_buffer_search_by_name (plugin_get_name (plugin), name))
@@ -432,7 +444,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
&(new_buffer->layout_number),
&(new_buffer->layout_number_merge_order));
new_buffer->name = strdup (name);
new_buffer->short_name = strdup (name);
new_buffer->short_name = NULL;
new_buffer->type = GUI_BUFFER_TYPE_FORMATTED;
new_buffer->notify = CONFIG_INTEGER(config_look_buffer_notify_default);
new_buffer->num_displayed = 0;
@@ -945,18 +957,20 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name)
void
gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name)
{
if (short_name && short_name[0])
if (buffer->short_name)
{
if (buffer->short_name)
free (buffer->short_name);
buffer->short_name = strdup (short_name);
if (buffer->mixed_lines)
gui_line_compute_buffer_max_length (buffer, buffer->mixed_lines);
gui_buffer_ask_chat_refresh (buffer, 1);
hook_signal_send ("buffer_renamed",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
free (buffer->short_name);
buffer->short_name = NULL;
}
buffer->short_name = (short_name && short_name[0]) ?
strdup (short_name) : NULL;
if (buffer->mixed_lines)
gui_line_compute_buffer_max_length (buffer, buffer->mixed_lines);
gui_buffer_ask_chat_refresh (buffer, 1);
hook_signal_send ("buffer_renamed",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
+1
View File
@@ -203,6 +203,7 @@ extern char *gui_buffer_properties_set[];
/* buffer functions */
extern const char *gui_buffer_get_plugin_name (struct t_gui_buffer *buffer);
extern const char *gui_buffer_get_short_name (struct t_gui_buffer *buffer);
extern void gui_buffer_notify_set_all ();
extern void gui_buffer_input_buffer_init (struct t_gui_buffer *buffer);
extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
+5 -3
View File
@@ -119,7 +119,7 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
{
if ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
&& (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE))
length_buffer = gui_chat_strlen_screen (buffer->short_name) + 1;
length_buffer = gui_chat_strlen_screen (gui_buffer_get_short_name (buffer)) + 1;
else
{
if (CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
@@ -507,14 +507,16 @@ gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer,
{
struct t_gui_buffer *ptr_buffer;
int length;
const char *short_name;
lines->buffer_max_length = 0;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if ((ptr_buffer->number == buffer->number) && ptr_buffer->short_name)
short_name = gui_buffer_get_short_name (ptr_buffer);
if (ptr_buffer->number == buffer->number)
{
length = gui_chat_strlen_screen (ptr_buffer->short_name);
length = gui_chat_strlen_screen (short_name);
if (length > lines->buffer_max_length)
lines->buffer_max_length = length;
}
+1 -1
View File
@@ -190,7 +190,7 @@ gui_window_get_context_at_xy (struct t_gui_window *window,
else if ((win_x >= window->coords[win_y].buffer_x1)
&& (win_x <= window->coords[win_y].buffer_x2))
{
*word = gui_color_decode ((*line)->data->buffer->short_name, NULL);
*word = gui_color_decode (gui_buffer_get_short_name ((*line)->data->buffer), NULL);
}
else if ((win_x >= window->coords[win_y].prefix_x1)
&& (win_x <= window->coords[win_y].prefix_x2))