mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
core: add bar item "buffer_short_name" (task #10882)
This commit is contained in:
@@ -15,6 +15,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
|
||||
== Version 1.0 (under dev)
|
||||
|
||||
* core: add bar item "buffer_short_name" (task #10882)
|
||||
* core: add option "send" in command /input (send text to a buffer)
|
||||
* core: add option "-buffer" in command /command (closes #67)
|
||||
* core: add support of negated tags in filters (with '!')
|
||||
|
||||
+48
-4
@@ -59,9 +59,9 @@ struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */
|
||||
char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
|
||||
{ "input_paste", "input_prompt", "input_search", "input_text", "time",
|
||||
"buffer_count", "buffer_last_number", "buffer_plugin", "buffer_number",
|
||||
"buffer_name", "buffer_modes", "buffer_filter", "buffer_zoom",
|
||||
"buffer_nicklist_count", "scroll", "hotlist", "completion", "buffer_title",
|
||||
"buffer_nicklist", "window_number"
|
||||
"buffer_name", "buffer_short_name", "buffer_modes", "buffer_filter",
|
||||
"buffer_zoom", "buffer_nicklist_count", "scroll", "hotlist", "completion",
|
||||
"buffer_title", "buffer_nicklist", "window_number"
|
||||
};
|
||||
char *gui_bar_items_default_for_bars[][2] =
|
||||
{ { GUI_BAR_DEFAULT_NAME_INPUT,
|
||||
@@ -1056,12 +1056,43 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
return NULL;
|
||||
|
||||
snprintf (str_name, sizeof (str_name), "%s%s",
|
||||
gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_name))),
|
||||
gui_color_get_custom (
|
||||
gui_color_get_name (CONFIG_COLOR(config_color_status_name))),
|
||||
buffer->name);
|
||||
|
||||
return strdup (str_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default item for short name of buffer.
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_buffer_short_name (void *data,
|
||||
struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *extra_info)
|
||||
{
|
||||
char str_short_name[256];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
snprintf (str_short_name, sizeof (str_short_name), "%s%s",
|
||||
gui_color_get_custom (
|
||||
gui_color_get_name (CONFIG_COLOR(config_color_status_name))),
|
||||
buffer->short_name);
|
||||
|
||||
return strdup (str_short_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default item for modes of buffer.
|
||||
*
|
||||
@@ -1976,6 +2007,19 @@ gui_bar_item_init ()
|
||||
gui_bar_item_hook_signal ("buffer_moved",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_NAME]);
|
||||
|
||||
/* buffer short name */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME],
|
||||
&gui_bar_item_default_buffer_short_name, NULL);
|
||||
gui_bar_item_hook_signal ("window_switch",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME]);
|
||||
gui_bar_item_hook_signal ("buffer_switch",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME]);
|
||||
gui_bar_item_hook_signal ("buffer_renamed",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME]);
|
||||
gui_bar_item_hook_signal ("buffer_moved",
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_SHORT_NAME]);
|
||||
|
||||
/* buffer modes */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_BUFFER_MODES],
|
||||
|
||||
@@ -32,6 +32,7 @@ enum t_gui_bar_item_weechat
|
||||
GUI_BAR_ITEM_BUFFER_PLUGIN,
|
||||
GUI_BAR_ITEM_BUFFER_NUMBER,
|
||||
GUI_BAR_ITEM_BUFFER_NAME,
|
||||
GUI_BAR_ITEM_BUFFER_SHORT_NAME,
|
||||
GUI_BAR_ITEM_BUFFER_MODES,
|
||||
GUI_BAR_ITEM_BUFFER_FILTER,
|
||||
GUI_BAR_ITEM_BUFFER_ZOOM,
|
||||
|
||||
@@ -176,10 +176,7 @@ irc_bar_item_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *extra_info)
|
||||
irc_bar_item_buffer_name_content (struct t_gui_buffer *buffer, int short_name)
|
||||
{
|
||||
char buf[512], buf_name[256], modes[128];
|
||||
const char *name;
|
||||
@@ -187,12 +184,6 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_irc_server *server;
|
||||
struct t_irc_channel *channel;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
@@ -228,7 +219,7 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
(server && display_server) ? IRC_COLOR_BAR_DELIM : "",
|
||||
(server && display_server) ? "/" : "",
|
||||
(server && server->ssl_connected) ? IRC_COLOR_STATUS_NAME_SSL : IRC_COLOR_STATUS_NAME,
|
||||
channel->name,
|
||||
(short_name) ? weechat_buffer_get_string (buffer, "short_name") : channel->name,
|
||||
(part_from_channel) ? IRC_COLOR_BAR_DELIM : "",
|
||||
(part_from_channel) ? ")" : "");
|
||||
}
|
||||
@@ -236,7 +227,8 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
}
|
||||
else
|
||||
{
|
||||
name = weechat_buffer_get_string (buffer, "name");
|
||||
name = weechat_buffer_get_string (buffer,
|
||||
(short_name) ? "short_name" : "name");
|
||||
if (name)
|
||||
snprintf (buf_name, sizeof (buf_name), "%s", name);
|
||||
}
|
||||
@@ -249,6 +241,45 @@ irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_name": bar item with buffer name.
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_bar_item_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *extra_info)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
return irc_bar_item_buffer_name_content (buffer, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_short_name": bar item with buffer short
|
||||
* name.
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_bar_item_buffer_short_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *extra_info)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
return irc_bar_item_buffer_name_content (buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_modes": bar item with buffer modes.
|
||||
*/
|
||||
@@ -605,6 +636,7 @@ irc_bar_item_buffer_switch (void *data, const char *signal,
|
||||
weechat_bar_item_update ("away");
|
||||
weechat_bar_item_update ("buffer_title");
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
weechat_bar_item_update ("buffer_short_name");
|
||||
weechat_bar_item_update ("buffer_modes");
|
||||
weechat_bar_item_update ("irc_channel");
|
||||
weechat_bar_item_update ("lag");
|
||||
@@ -625,6 +657,7 @@ irc_bar_item_init ()
|
||||
weechat_bar_item_new ("buffer_title", &irc_bar_item_buffer_title, NULL);
|
||||
weechat_bar_item_new ("buffer_plugin", &irc_bar_item_buffer_plugin, NULL);
|
||||
weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL);
|
||||
weechat_bar_item_new ("buffer_short_name", &irc_bar_item_buffer_short_name, NULL);
|
||||
weechat_bar_item_new ("buffer_modes", &irc_bar_item_buffer_modes, NULL);
|
||||
weechat_bar_item_new ("irc_channel", &irc_bar_item_channel, NULL);
|
||||
weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL);
|
||||
|
||||
@@ -610,6 +610,7 @@ irc_config_change_look_item_display_server (void *data,
|
||||
|
||||
weechat_bar_item_update ("buffer_plugin");
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
weechat_bar_item_update ("buffer_short_name");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -4047,6 +4047,7 @@ irc_server_connect (struct t_irc_server *server)
|
||||
}
|
||||
|
||||
weechat_bar_item_update ("buffer_name");
|
||||
weechat_bar_item_update ("buffer_short_name");
|
||||
|
||||
irc_server_set_index_current_address (server,
|
||||
server->index_current_address);
|
||||
|
||||
Reference in New Issue
Block a user