mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: remove redefinition of bar item "input_prompt"
The new buffer property "input_prompt" is used instead.
This commit is contained in:
@@ -590,90 +590,6 @@ irc_bar_item_tls_version (const void *pointer, void *data,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns content of bar item "input_prompt": bar item with input prompt.
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_bar_item_input_prompt (const void *pointer, 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;
|
||||
struct t_irc_channel *channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
char *buf, str_prefix[64];
|
||||
int length;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) extra_info;
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
irc_buffer_get_server_and_channel (buffer, &server, &channel);
|
||||
if (!server || !server->nick)
|
||||
return NULL;
|
||||
|
||||
/* build prefix */
|
||||
str_prefix[0] = '\0';
|
||||
if (weechat_config_boolean (irc_config_look_item_nick_prefix)
|
||||
&& channel
|
||||
&& (channel->type == IRC_CHANNEL_TYPE_CHANNEL))
|
||||
{
|
||||
ptr_nick = irc_nick_search (server, channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_nick_mode_empty)
|
||||
|| (ptr_nick->prefix[0] != ' '))
|
||||
{
|
||||
snprintf (str_prefix, sizeof (str_prefix), "%s%s",
|
||||
weechat_color (
|
||||
irc_nick_get_prefix_color_name (
|
||||
server, ptr_nick->prefix[0])),
|
||||
ptr_nick->prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* build bar item */
|
||||
length = 64 + strlen (server->nick) + 64 +
|
||||
((server->nick_modes) ? strlen (server->nick_modes) : 0) + 64 + 1;
|
||||
|
||||
buf = malloc (length);
|
||||
if (buf)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_item_nick_modes)
|
||||
&& server->nick_modes && server->nick_modes[0])
|
||||
{
|
||||
snprintf (buf, length, "%s%s%s%s(%s%s%s)",
|
||||
str_prefix,
|
||||
IRC_COLOR_INPUT_NICK,
|
||||
server->nick,
|
||||
IRC_COLOR_BAR_DELIM,
|
||||
IRC_COLOR_ITEM_NICK_MODES,
|
||||
server->nick_modes,
|
||||
IRC_COLOR_BAR_DELIM);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf (buf, length, "%s%s%s",
|
||||
str_prefix,
|
||||
IRC_COLOR_INPUT_NICK,
|
||||
server->nick);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns content of bar item "nick_modes": bar item with nick modes.
|
||||
*/
|
||||
@@ -888,8 +804,6 @@ irc_bar_item_init ()
|
||||
&irc_bar_item_nick_host, NULL, NULL);
|
||||
weechat_bar_item_new ("lag",
|
||||
&irc_bar_item_lag, NULL, NULL);
|
||||
weechat_bar_item_new ("input_prompt",
|
||||
&irc_bar_item_input_prompt, NULL, NULL);
|
||||
weechat_bar_item_new ("irc_nick_modes",
|
||||
&irc_bar_item_nick_modes, NULL, NULL);
|
||||
weechat_bar_item_new ("irc_nick_prefix",
|
||||
|
||||
@@ -570,6 +570,68 @@ irc_channel_add_nicklist_groups (struct t_irc_server *server,
|
||||
"weechat.color.nicklist_group", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets input prompt on channel.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_set_buffer_input_prompt (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
int display_modes;
|
||||
char str_prefix[64], *prompt;
|
||||
|
||||
if (!server || !channel || !channel->buffer)
|
||||
return;
|
||||
|
||||
if (server->nick)
|
||||
{
|
||||
/* build prefix */
|
||||
str_prefix[0] = '\0';
|
||||
if (weechat_config_boolean (irc_config_look_item_nick_prefix)
|
||||
&& (channel->type == IRC_CHANNEL_TYPE_CHANNEL))
|
||||
{
|
||||
ptr_nick = irc_nick_search (server, channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_nick_mode_empty)
|
||||
|| (ptr_nick->prefix[0] != ' '))
|
||||
{
|
||||
snprintf (str_prefix, sizeof (str_prefix), "%s%s",
|
||||
weechat_color (
|
||||
irc_nick_get_prefix_color_name (
|
||||
server, ptr_nick->prefix[0])),
|
||||
ptr_nick->prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
display_modes = (weechat_config_boolean (irc_config_look_item_nick_modes)
|
||||
&& server->nick_modes && server->nick_modes[0]);
|
||||
|
||||
weechat_asprintf (&prompt, "%s%s%s%s%s%s%s%s%s",
|
||||
str_prefix,
|
||||
IRC_COLOR_INPUT_NICK,
|
||||
server->nick,
|
||||
(display_modes) ? IRC_COLOR_BAR_DELIM : "",
|
||||
(display_modes) ? "(" : "",
|
||||
(display_modes) ? IRC_COLOR_ITEM_NICK_MODES : "",
|
||||
(display_modes) ? server->nick_modes : "",
|
||||
(display_modes) ? IRC_COLOR_BAR_DELIM : "",
|
||||
(display_modes) ? ")" : "");
|
||||
if (prompt)
|
||||
{
|
||||
weechat_buffer_set (channel->buffer, "input_prompt", prompt);
|
||||
free (prompt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_buffer_set (channel->buffer, "input_prompt", "");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the buffer title with the channel topic.
|
||||
*/
|
||||
|
||||
@@ -116,6 +116,8 @@ extern void irc_channel_pv_rename (struct t_irc_server *server,
|
||||
const char *new_name);
|
||||
extern void irc_channel_add_nicklist_groups (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel);
|
||||
extern void irc_channel_set_buffer_input_prompt (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);
|
||||
|
||||
@@ -661,19 +661,26 @@ irc_config_change_look_topic_strip_colors (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on an option affecting bar item "input_prompt".
|
||||
* Callback for changes on an option affecting input prompt.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_bar_item_input_prompt (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
irc_config_change_input_prompt (const void *pointer, void *data,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_irc_server *ptr_server;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->buffer)
|
||||
irc_server_set_buffer_input_prompt (ptr_server);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -722,7 +729,7 @@ irc_config_change_color_item_nick_modes (const void *pointer, void *data,
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
irc_config_change_input_prompt (NULL, NULL, NULL);
|
||||
weechat_bar_item_update ("irc_nick_modes");
|
||||
}
|
||||
|
||||
@@ -872,7 +879,7 @@ irc_config_change_color_nick_prefixes (const void *pointer, void *data,
|
||||
|
||||
irc_nick_nicklist_set_prefix_color_all ();
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
irc_config_change_input_prompt (NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3377,7 +3384,7 @@ irc_config_init ()
|
||||
N_("display nick modes in bar item \"input_prompt\""),
|
||||
NULL, 0, 0, "on", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_bar_item_input_prompt, NULL, NULL,
|
||||
&irc_config_change_input_prompt, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_look_item_nick_prefix = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
@@ -3385,7 +3392,7 @@ irc_config_init ()
|
||||
N_("display nick prefix in bar item \"input_prompt\""),
|
||||
NULL, 0, 0, "on", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_bar_item_input_prompt, NULL, NULL,
|
||||
&irc_config_change_input_prompt, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_look_join_auto_add_chantype = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
@@ -3489,7 +3496,7 @@ irc_config_init ()
|
||||
"(not op, voice, ...)"),
|
||||
NULL, 0, 0, "off", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_bar_item_input_prompt, NULL, NULL,
|
||||
&irc_config_change_input_prompt, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_look_nicks_hide_password = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
@@ -3722,7 +3729,7 @@ irc_config_init ()
|
||||
N_("color for nick in input bar"),
|
||||
NULL, -1, 0, "lightcyan", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_bar_item_input_prompt, NULL, NULL,
|
||||
&irc_config_change_input_prompt, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_color_item_channel_modes = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
|
||||
@@ -599,7 +599,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");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick_modes");
|
||||
}
|
||||
}
|
||||
@@ -607,7 +607,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");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick_modes");
|
||||
}
|
||||
|
||||
@@ -642,7 +642,7 @@ irc_mode_user_remove (struct t_irc_server *server, char mode)
|
||||
nick_modes2 = realloc (server->nick_modes, new_size);
|
||||
if (nick_modes2)
|
||||
server->nick_modes = nick_modes2;
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick_modes");
|
||||
}
|
||||
}
|
||||
@@ -700,7 +700,7 @@ irc_mode_user_set (struct t_irc_server *server, const char *modes,
|
||||
break;
|
||||
modes++;
|
||||
}
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick_modes");
|
||||
}
|
||||
|
||||
|
||||
@@ -692,7 +692,7 @@ irc_nick_set_mode (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
|
||||
if (irc_server_strcasecmp (server, nick->name, server->nick) == 0)
|
||||
{
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick");
|
||||
weechat_bar_item_update ("irc_nick_host");
|
||||
}
|
||||
@@ -813,6 +813,8 @@ irc_nick_free_all (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
|
||||
/* should be zero, but prevent any bug :D */
|
||||
channel->nicks_count = 0;
|
||||
|
||||
irc_channel_set_buffer_input_prompt (server, channel);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2384,6 +2384,8 @@ IRC_PROTOCOL_CALLBACK(nick)
|
||||
|
||||
/* enable hotlist */
|
||||
weechat_buffer_set (NULL, "hotlist", "+");
|
||||
|
||||
irc_server_set_buffer_input_prompt (ctxt->server);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6769,10 +6771,9 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
{
|
||||
weechat_hashtable_set (ptr_channel->join_msg_received, "353", "1");
|
||||
weechat_hashtable_set (ptr_channel->join_msg_received, "366", "1");
|
||||
irc_channel_set_buffer_input_prompt (ctxt->server, ptr_channel);
|
||||
}
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -879,7 +879,7 @@ irc_server_set_nick (struct t_irc_server *server, const char *nick)
|
||||
weechat_buffer_set (ptr_channel->buffer, "localvar_set_nick", nick);
|
||||
}
|
||||
|
||||
weechat_bar_item_update ("input_prompt");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick");
|
||||
weechat_bar_item_update ("irc_nick_host");
|
||||
}
|
||||
@@ -1582,6 +1582,53 @@ irc_server_get_default_msg (const char *default_msg,
|
||||
return msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets input prompt on server, channels and private buffers.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_set_buffer_input_prompt (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
int display_modes;
|
||||
char *prompt;
|
||||
|
||||
if (!server || !server->buffer)
|
||||
return;
|
||||
|
||||
display_modes = (weechat_config_boolean (irc_config_look_item_nick_modes)
|
||||
&& server->nick_modes && server->nick_modes[0]);
|
||||
|
||||
if (server->nick)
|
||||
{
|
||||
weechat_asprintf (&prompt, "%s%s%s%s%s%s%s%s",
|
||||
IRC_COLOR_INPUT_NICK,
|
||||
server->nick,
|
||||
(display_modes) ? IRC_COLOR_BAR_DELIM : "",
|
||||
(display_modes) ? "(" : "",
|
||||
(display_modes) ? IRC_COLOR_ITEM_NICK_MODES : "",
|
||||
(display_modes) ? server->nick_modes : "",
|
||||
(display_modes) ? IRC_COLOR_BAR_DELIM : "",
|
||||
(display_modes) ? ")" : "");
|
||||
if (prompt)
|
||||
{
|
||||
weechat_buffer_set (server->buffer, "input_prompt", prompt);
|
||||
free (prompt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_buffer_set (server->buffer, "input_prompt", "");
|
||||
}
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->buffer)
|
||||
irc_channel_set_buffer_input_prompt (server, ptr_channel);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets "input_multiline" to 1 or 0, according to capability draft/multiline
|
||||
* on all channels and private buffers.
|
||||
@@ -1593,6 +1640,9 @@ irc_server_set_buffer_input_multiline (struct t_irc_server *server,
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -1614,6 +1664,9 @@ irc_server_has_channels (struct t_irc_server *server)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server)
|
||||
return 0;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -5712,7 +5765,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");
|
||||
irc_server_set_buffer_input_prompt (server);
|
||||
weechat_bar_item_update ("irc_nick_modes");
|
||||
}
|
||||
if (server->host)
|
||||
|
||||
@@ -382,6 +382,7 @@ extern char *irc_server_get_default_msg (const char *default_msg,
|
||||
struct t_irc_server *server,
|
||||
const char *channel_name,
|
||||
const char *target_nick);
|
||||
extern void irc_server_set_buffer_input_prompt (struct t_irc_server *server);
|
||||
extern void irc_server_set_buffer_input_multiline (struct t_irc_server *server,
|
||||
int multiline);
|
||||
extern int irc_server_has_channels (struct t_irc_server *server);
|
||||
|
||||
Reference in New Issue
Block a user