summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/irc/irc-bar-item.c62
-rw-r--r--src/plugins/irc/irc-mode.c9
-rw-r--r--src/plugins/irc/irc-server.c1
-rw-r--r--src/plugins/irc/irc.h1
4 files changed, 67 insertions, 6 deletions
diff --git a/src/plugins/irc/irc-bar-item.c b/src/plugins/irc/irc-bar-item.c
index f128b247b..af4e7e4ad 100644
--- a/src/plugins/irc/irc-bar-item.c
+++ b/src/plugins/irc/irc-bar-item.c
@@ -175,6 +175,67 @@ irc_bar_item_lag (void *data, struct t_gui_bar_item *item,
}
/*
+ * 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);
}
diff --git a/src/plugins/irc/irc-mode.c b/src/plugins/irc/irc-mode.c
index e7520253b..c38acd159 100644
--- a/src/plugins/irc/irc-mode.c
+++ b/src/plugins/irc/irc-mode.c
@@ -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");
}
}
}
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index c49721272..f3aa38384 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -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)
{
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index a02e638a0..5d83af317 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -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;