mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 08:43:13 +02:00
Add nick modes in bar item "input_prompt" for IRC plugin
This commit is contained in:
@@ -174,6 +174,67 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_bar_item_input_prompt: bar item with input prompt
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_bar_item_input_prompt (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width, int max_height)
|
||||
{
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_irc_server *server;
|
||||
char *buf;
|
||||
int length;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) max_width;
|
||||
(void) max_height;
|
||||
|
||||
if (!window)
|
||||
window = weechat_current_window;
|
||||
|
||||
buffer = weechat_window_get_pointer (window, "buffer");
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
irc_buffer_get_server_channel (buffer, &server, NULL);
|
||||
if (!server || !server->nick)
|
||||
return NULL;
|
||||
|
||||
length = strlen (server->nick) + 64 +
|
||||
((server->nick_modes) ? strlen (server->nick_modes) : 0) + 64 + 1;
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
if (server->nick_modes)
|
||||
{
|
||||
snprintf (buf, length, "%s%s%s(%s%s%s)",
|
||||
IRC_COLOR_INPUT_NICK,
|
||||
server->nick,
|
||||
IRC_COLOR_BAR_DELIM,
|
||||
IRC_COLOR_BAR_FG,
|
||||
server->nick_modes,
|
||||
IRC_COLOR_BAR_DELIM);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (buf, length, "%s%s",
|
||||
IRC_COLOR_INPUT_NICK,
|
||||
server->nick);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_bar_item_init: initialize IRC bar items
|
||||
*/
|
||||
@@ -183,4 +244,5 @@ irc_bar_item_init ()
|
||||
{
|
||||
weechat_bar_item_new ("buffer_name", &irc_bar_item_buffer_name, NULL);
|
||||
weechat_bar_item_new ("lag", &irc_bar_item_lag, NULL);
|
||||
weechat_bar_item_new ("input_prompt", &irc_bar_item_input_prompt, NULL);
|
||||
}
|
||||
|
||||
@@ -229,16 +229,14 @@ irc_mode_user_add (struct t_irc_server *server, char mode)
|
||||
server->nick_modes = realloc (server->nick_modes,
|
||||
strlen (server->nick_modes) + 1 + 1);
|
||||
strcat (server->nick_modes, str_mode);
|
||||
//gui_status_draw (gui_current_window->buffer, 1);
|
||||
//gui_input_draw (gui_current_window->buffer, 1);
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
server->nick_modes = malloc (2);
|
||||
strcpy (server->nick_modes, str_mode);
|
||||
//gui_status_draw (gui_current_window->buffer, 1);
|
||||
//gui_input_draw (gui_current_window->buffer, 1);
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,8 +258,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
|
||||
new_size = strlen (server->nick_modes);
|
||||
memmove (pos, pos + 1, strlen (pos + 1) + 1);
|
||||
server->nick_modes = realloc (server->nick_modes, new_size);
|
||||
//gui_status_draw (gui_current_window->buffer, 1);
|
||||
//gui_input_draw (gui_current_window->buffer, 1);
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2387,6 +2387,7 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
|
||||
{
|
||||
free (server->nick_modes);
|
||||
server->nick_modes = NULL;
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
}
|
||||
if (server->prefix)
|
||||
{
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#define IRC_COLOR_BAR_DELIM weechat_color("bar_delim")
|
||||
#define IRC_COLOR_STATUS_NUMBER weechat_color(weechat_config_string(weechat_config_get("weechat.color.status_number")))
|
||||
#define IRC_COLOR_STATUS_NAME weechat_color(weechat_config_string(weechat_config_get("weechat.color.status_name")))
|
||||
#define IRC_COLOR_INPUT_NICK weechat_color(weechat_config_string(weechat_config_get("weechat.color.input_nick")))
|
||||
|
||||
extern struct t_weechat_plugin *weechat_irc_plugin;
|
||||
extern struct t_hook *irc_hook_timer_check_away;
|
||||
|
||||
Reference in New Issue
Block a user