1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 11:13:12 +02:00

irc: add bar item "irc_nick_modes" (closes #71)

This commit is contained in:
Sébastien Helleu
2014-05-15 23:19:58 +02:00
parent 85b8e0d82b
commit 540abf0874
5 changed files with 64 additions and 1 deletions
+1
View File
@@ -104,6 +104,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* alias: change default command for alias /beep to "/print -beep"
* exec: add exec plugin: new command /exec and file exec.conf
* guile: fix module used after unload of a script
* irc: add bar item "irc_nick_modes" (closes #71)
* irc: make reason optional in command /kill
* irc: add support of message 324 (channel modes) in option
irc.look.display_join_message (closes #75)
+41
View File
@@ -503,6 +503,45 @@ irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
return buf;
}
/*
* Returns content of bar item "nick_modes": bar item with nick modes.
*/
char *
irc_bar_item_nick_modes (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,
struct t_hashtable *extra_info)
{
struct t_irc_server *server;
char *buf;
int length;
/* make C compiler happy */
(void) data;
(void) item;
(void) window;
(void) extra_info;
if (!buffer)
return NULL;
irc_buffer_get_server_and_channel (buffer, &server, NULL);
if (!server || !server->nick_modes || !server->nick_modes[0])
return NULL;
length = 64 + strlen (server->nick_modes) + 1;
buf = malloc (length);
if (buf)
{
snprintf (buf, length, "%s%s",
IRC_COLOR_ITEM_NICK_MODES,
server->nick_modes);
}
return buf;
}
/*
* Focus on nicklist.
*/
@@ -570,6 +609,7 @@ irc_bar_item_buffer_switch (void *data, const char *signal,
weechat_bar_item_update ("irc_channel");
weechat_bar_item_update ("lag");
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
return WEECHAT_RC_OK;
}
@@ -589,6 +629,7 @@ irc_bar_item_init ()
weechat_bar_item_new ("irc_channel", &irc_bar_item_channel, NULL);
weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL);
weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL);
weechat_bar_item_new ("irc_nick_modes", &irc_bar_item_nick_modes, NULL);
weechat_hook_focus ("buffer_nicklist",
&irc_bar_item_focus_buffer_nicklist, NULL);
weechat_hook_signal ("buffer_switch",
+17 -1
View File
@@ -718,6 +718,22 @@ irc_config_change_color_item_lag (void *data,
weechat_bar_item_update ("lag");
}
/*
* Callback for changes on option "irc.color.item_nick_modes".
*/
void
irc_config_change_color_item_nick_modes (void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
}
/*
* Callback for changes on option "irc.color.mirc_remap".
*/
@@ -2714,7 +2730,7 @@ irc_config_init ()
"item_nick_modes", "color",
N_("color for nick modes in bar item \"input_prompt\""),
NULL, -1, 0, "default", NULL, 0, NULL, NULL,
&irc_config_change_bar_item_input_prompt, NULL, NULL, NULL);
&irc_config_change_color_item_nick_modes, NULL, NULL, NULL);
irc_config_color_message_join = weechat_config_new_option (
irc_config_file, ptr_section,
"message_join", "color",
+4
View File
@@ -503,6 +503,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
server->nick_modes = nick_modes2;
strcat (server->nick_modes, str_mode);
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
}
}
else
@@ -510,6 +511,7 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
server->nick_modes = malloc (2);
strcpy (server->nick_modes, str_mode);
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
}
}
@@ -534,6 +536,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
if (nick_modes2)
server->nick_modes = nick_modes2;
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
}
}
}
@@ -586,4 +589,5 @@ irc_mode_user_set (struct t_irc_server *server, const char *modes,
modes++;
}
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
}
+1
View File
@@ -4333,6 +4333,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address,
free (server->nick_modes);
server->nick_modes = NULL;
weechat_bar_item_update ("input_prompt");
weechat_bar_item_update ("irc_nick_modes");
}
server->cap_away_notify = 0;
server->is_away = 0;