mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Add options irc.look.open_channel/pv_near_server
This commit is contained in:
@@ -60,6 +60,72 @@ irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_move_near_server: move new channel/pv buffer near server
|
||||
*/
|
||||
|
||||
void
|
||||
irc_channel_move_near_server (struct t_irc_server *server, int channel_type,
|
||||
struct t_gui_buffer *buffer)
|
||||
{
|
||||
int number, number_channel, number_last_channel, number_last_private;
|
||||
int number_found;
|
||||
char str_number[32];
|
||||
struct t_irc_channel *ptr_channel;
|
||||
|
||||
number = weechat_buffer_get_integer (buffer, "number");
|
||||
number_last_channel = 0;
|
||||
number_last_private = 0;
|
||||
number_found = 0;
|
||||
|
||||
if (server->channels)
|
||||
{
|
||||
/* search last channel/pv number for server */
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->buffer)
|
||||
{
|
||||
number_channel = weechat_buffer_get_integer (ptr_channel->buffer,
|
||||
"number");
|
||||
switch (ptr_channel->type)
|
||||
{
|
||||
case IRC_CHANNEL_TYPE_CHANNEL:
|
||||
if (number_channel > number_last_channel)
|
||||
number_last_channel = number_channel;
|
||||
break;
|
||||
case IRC_CHANNEL_TYPE_PRIVATE:
|
||||
if (number_channel > number_last_private)
|
||||
number_last_private = number_channel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* use last channel/pv number + 1 */
|
||||
switch (channel_type)
|
||||
{
|
||||
case IRC_CHANNEL_TYPE_CHANNEL:
|
||||
if (number_last_channel > 0)
|
||||
number_found = number_last_channel + 1;
|
||||
break;
|
||||
case IRC_CHANNEL_TYPE_PRIVATE:
|
||||
if (number_last_private > 0)
|
||||
number_found = number_last_private + 1;
|
||||
else if (number_last_channel > 0)
|
||||
number_found = number_last_channel + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* switch to number found */
|
||||
if ((number_found >= 1) && (number_found != number))
|
||||
{
|
||||
snprintf (str_number, sizeof (str_number), "%d", number_found);
|
||||
weechat_buffer_set (buffer, "number", str_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_new: allocate a new channel for a server and add it to channels
|
||||
* list
|
||||
@@ -100,6 +166,13 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
|
||||
free (new_channel);
|
||||
return NULL;
|
||||
}
|
||||
if (((channel_type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
&& weechat_config_boolean (irc_config_look_open_channel_near_server))
|
||||
|| ((channel_type == IRC_CHANNEL_TYPE_PRIVATE)
|
||||
&& weechat_config_boolean (irc_config_look_open_pv_near_server)))
|
||||
{
|
||||
irc_channel_move_near_server (server, channel_type, new_buffer);
|
||||
}
|
||||
buffer_created = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ struct t_config_section *irc_config_section_server = NULL;
|
||||
|
||||
struct t_config_option *irc_config_look_color_nicks_in_server_messages;
|
||||
struct t_config_option *irc_config_look_server_buffer;
|
||||
struct t_config_option *irc_config_look_open_near_server;
|
||||
struct t_config_option *irc_config_look_open_channel_near_server;
|
||||
struct t_config_option *irc_config_look_open_pv_near_server;
|
||||
struct t_config_option *irc_config_look_nick_prefix;
|
||||
struct t_config_option *irc_config_look_nick_suffix;
|
||||
struct t_config_option *irc_config_look_nick_completion_smart;
|
||||
@@ -1116,10 +1117,15 @@ irc_config_init ()
|
||||
"merge_with_core|merge_without_core|independent", 0, 0, "merge_with_core",
|
||||
NULL, 0, NULL, NULL,
|
||||
&irc_config_change_look_server_buffer, NULL, NULL, NULL);
|
||||
irc_config_look_open_near_server = weechat_config_new_option (
|
||||
irc_config_look_open_channel_near_server = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"open_near_server", "boolean",
|
||||
N_("open new channels/privates near server"),
|
||||
"open_channel_near_server", "boolean",
|
||||
N_("open new channels near server"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_open_pv_near_server = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"open_pv_near_server", "boolean",
|
||||
N_("open new privates near server"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_nick_prefix = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
|
||||
@@ -62,7 +62,8 @@ extern struct t_config_section *irc_config_section_server;
|
||||
|
||||
extern struct t_config_option *irc_config_look_color_nicks_in_server_messages;
|
||||
extern struct t_config_option *irc_config_look_server_buffer;
|
||||
extern struct t_config_option *irc_config_look_open_near_server;
|
||||
extern struct t_config_option *irc_config_look_open_channel_near_server;
|
||||
extern struct t_config_option *irc_config_look_open_pv_near_server;
|
||||
extern struct t_config_option *irc_config_look_nick_prefix;
|
||||
extern struct t_config_option *irc_config_look_nick_suffix;
|
||||
extern struct t_config_option *irc_config_look_nick_completion_smart;
|
||||
|
||||
Reference in New Issue
Block a user