mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 16:23:14 +02:00
irc: remove IRC color codes from buffer title in channels (closes #237)
This commit is contained in:
@@ -87,39 +87,6 @@ irc_bar_item_away (void *data, struct t_gui_bar_item *item,
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_title": bar item with buffer title.
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_bar_item_buffer_title (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *extra_info)
|
||||
{
|
||||
const char *title;
|
||||
char *title_color;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
title = weechat_buffer_get_string (buffer, "title");
|
||||
if (!title)
|
||||
return NULL;
|
||||
|
||||
title_color = irc_color_decode (title,
|
||||
(weechat_config_boolean (irc_config_look_topic_strip_colors)) ?
|
||||
0 : 1);
|
||||
|
||||
return (title_color) ? title_color : strdup (title);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "buffer_plugin": bar item with buffer plugin.
|
||||
*/
|
||||
@@ -634,7 +601,6 @@ irc_bar_item_buffer_switch (void *data, const char *signal,
|
||||
(void) signal_data;
|
||||
|
||||
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");
|
||||
@@ -666,7 +632,6 @@ void
|
||||
irc_bar_item_init ()
|
||||
{
|
||||
weechat_bar_item_new ("away", &irc_bar_item_away, NULL);
|
||||
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);
|
||||
|
||||
@@ -388,6 +388,26 @@ irc_channel_add_nicklist_groups (struct t_irc_server *server,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the buffer title with the channel topic.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_set_buffer_title (struct t_irc_channel *channel)
|
||||
{
|
||||
char *title_color;
|
||||
|
||||
if (channel->topic)
|
||||
{
|
||||
title_color = irc_color_decode (
|
||||
channel->topic,
|
||||
(weechat_config_boolean (irc_config_look_topic_strip_colors)) ? 0 : 1);
|
||||
weechat_buffer_set (channel->buffer, "title", title_color);
|
||||
}
|
||||
else
|
||||
weechat_buffer_set (channel->buffer, "title", "");
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets topic for a channel.
|
||||
*/
|
||||
@@ -397,10 +417,9 @@ irc_channel_set_topic (struct t_irc_channel *channel, const char *topic)
|
||||
{
|
||||
if (channel->topic)
|
||||
free (channel->topic);
|
||||
|
||||
channel->topic = (topic) ? strdup (topic) : NULL;
|
||||
weechat_buffer_set (channel->buffer, "title",
|
||||
(channel->topic) ? channel->topic : "");
|
||||
|
||||
irc_channel_set_buffer_title (channel);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -85,6 +85,7 @@ extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server,
|
||||
int auto_switch);
|
||||
extern void irc_channel_add_nicklist_groups (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel);
|
||||
extern void irc_channel_set_buffer_title (struct t_irc_channel *channel);
|
||||
extern void irc_channel_set_topic (struct t_irc_channel *channel,
|
||||
const char *topic);
|
||||
extern void irc_channel_set_modes (struct t_irc_channel *channel,
|
||||
|
||||
@@ -652,11 +652,23 @@ void
|
||||
irc_config_change_look_topic_strip_colors (void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
weechat_bar_item_update ("buffer_title");
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->buffer)
|
||||
irc_channel_set_buffer_title (ptr_channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user