mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 06:16:40 +02:00
irc: add buffer for /list reply (closes #1972)
New options: - irc.color.list_buffer_line_selected - irc.color.list_buffer_line_selected_bg - irc.look.list_buffer_sort - irc.look.list_buffer_scroll_horizontal - irc.look.new_list_position - irc.look.list_buffer_topic_strip_colors
This commit is contained in:
@@ -1433,7 +1433,7 @@ fset_buffer_input_cb (const void *pointer, void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* execute action on an option */
|
||||
/* execute action */
|
||||
for (i = 0; actions[i][0]; i++)
|
||||
{
|
||||
if (strcmp (input_data, actions[i][0]) == 0)
|
||||
|
||||
@@ -32,6 +32,7 @@ add_library(irc MODULE
|
||||
irc-ignore.c irc-ignore.h
|
||||
irc-info.c irc-info.h
|
||||
irc-input.c irc-input.h
|
||||
irc-list.c irc-list.h
|
||||
irc-join.c irc-join.h
|
||||
irc-message.c irc-message.h
|
||||
irc-mode.c irc-mode.h
|
||||
|
||||
+152
-28
@@ -31,6 +31,7 @@
|
||||
#include "irc-command.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-join.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-raw.h"
|
||||
#include "irc-server.h"
|
||||
|
||||
@@ -67,6 +68,13 @@ irc_buffer_get_server_and_channel (struct t_gui_buffer *buffer,
|
||||
return;
|
||||
}
|
||||
|
||||
if (ptr_server->list->buffer == buffer)
|
||||
{
|
||||
if (server)
|
||||
*server = ptr_server;
|
||||
return;
|
||||
}
|
||||
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
@@ -204,41 +212,52 @@ irc_buffer_close_cb (const void *pointer, void *data,
|
||||
}
|
||||
irc_channel_free (ptr_server, ptr_channel);
|
||||
}
|
||||
else
|
||||
else if (ptr_server && (ptr_server->buffer == buffer))
|
||||
{
|
||||
if (ptr_server)
|
||||
if (!ptr_server->disconnected)
|
||||
{
|
||||
if (!ptr_server->disconnected)
|
||||
{
|
||||
/* send QUIT to server, then disconnect */
|
||||
irc_command_quit_server (ptr_server, NULL);
|
||||
irc_server_disconnect (ptr_server, 0, 0);
|
||||
}
|
||||
/* send QUIT to server, then disconnect */
|
||||
irc_command_quit_server (ptr_server, NULL);
|
||||
irc_server_disconnect (ptr_server, 0, 0);
|
||||
}
|
||||
|
||||
/* disable reconnection */
|
||||
ptr_server->reconnect_delay = 0;
|
||||
ptr_server->reconnect_start = 0;
|
||||
/* disable reconnection */
|
||||
ptr_server->reconnect_delay = 0;
|
||||
ptr_server->reconnect_start = 0;
|
||||
|
||||
/* consider auto-join has never been done */
|
||||
ptr_server->autojoin_done = 0;
|
||||
/* consider auto-join has never been done */
|
||||
ptr_server->autojoin_done = 0;
|
||||
|
||||
/* close server channels/privates */
|
||||
ptr_channel = ptr_server->channels;
|
||||
while (ptr_channel)
|
||||
{
|
||||
next_channel = ptr_channel->next_channel;
|
||||
if (ptr_channel->buffer != buffer)
|
||||
weechat_buffer_close (ptr_channel->buffer);
|
||||
ptr_channel = next_channel;
|
||||
}
|
||||
/* close server channels/privates */
|
||||
ptr_channel = ptr_server->channels;
|
||||
while (ptr_channel)
|
||||
{
|
||||
next_channel = ptr_channel->next_channel;
|
||||
if (ptr_channel->buffer != buffer)
|
||||
weechat_buffer_close (ptr_channel->buffer);
|
||||
ptr_channel = next_channel;
|
||||
}
|
||||
|
||||
/*
|
||||
* close remaining channels/privates
|
||||
* (which are not yet in server->channels)
|
||||
*/
|
||||
irc_buffer_close_server_channels (ptr_server);
|
||||
/*
|
||||
* close remaining channels/privates
|
||||
* (which are not yet in server->channels)
|
||||
*/
|
||||
irc_buffer_close_server_channels (ptr_server);
|
||||
|
||||
ptr_server->buffer = NULL;
|
||||
ptr_server->buffer = NULL;
|
||||
}
|
||||
else if (ptr_server && (ptr_server->list->buffer == buffer))
|
||||
{
|
||||
ptr_server->list->buffer = NULL;
|
||||
if (ptr_server->list->channels)
|
||||
{
|
||||
weechat_arraylist_free (ptr_server->list->channels);
|
||||
ptr_server->list->channels = NULL;
|
||||
}
|
||||
if (ptr_server->list->filter_channels)
|
||||
{
|
||||
weechat_arraylist_free (ptr_server->list->filter_channels);
|
||||
ptr_server->list->filter_channels = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,3 +376,108 @@ irc_buffer_search_private_lowest_number (struct t_irc_server *server)
|
||||
}
|
||||
return ptr_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Moves new channel/pv or list buffer near server.
|
||||
*
|
||||
* Parameters:
|
||||
* list_buffer: 1 if it is a /list buffer, 0 otherwise
|
||||
* channel_type: -1, IRC_CHANNEL_TYPE_CHANNEL or IRC_CHANNEL_TYPE_PRIVATE
|
||||
*/
|
||||
|
||||
void
|
||||
irc_buffer_move_near_server (struct t_irc_server *server,
|
||||
int list_buffer, 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];
|
||||
const char *ptr_type, *ptr_server_name;
|
||||
struct t_hdata *hdata_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
number = weechat_buffer_get_integer (buffer, "number");
|
||||
number_last_channel = 0;
|
||||
number_last_private = 0;
|
||||
number_found = 0;
|
||||
|
||||
hdata_buffer = weechat_hdata_get ("buffer");
|
||||
ptr_buffer = weechat_hdata_get_list (hdata_buffer, "gui_buffers");
|
||||
while (ptr_buffer)
|
||||
{
|
||||
if ((ptr_buffer != buffer)
|
||||
&& (weechat_buffer_get_pointer (ptr_buffer,
|
||||
"plugin") == weechat_irc_plugin))
|
||||
{
|
||||
ptr_type = weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_type");
|
||||
ptr_server_name = weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_server");
|
||||
number_channel = weechat_buffer_get_integer (ptr_buffer,
|
||||
"number");
|
||||
if (ptr_type && ptr_type[0]
|
||||
&& ptr_server_name && ptr_server_name[0]
|
||||
&& (strcmp (ptr_server_name, server->name) == 0))
|
||||
{
|
||||
if (strcmp (ptr_type, "channel") == 0)
|
||||
{
|
||||
if (number_channel > number_last_channel)
|
||||
number_last_channel = number_channel;
|
||||
}
|
||||
else if (strcmp (ptr_type, "private") == 0)
|
||||
{
|
||||
if (number_channel > number_last_private)
|
||||
number_last_private = number_channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* move to next buffer */
|
||||
ptr_buffer = weechat_hdata_move (hdata_buffer, ptr_buffer, 1);
|
||||
}
|
||||
|
||||
if (list_buffer)
|
||||
{
|
||||
if ((number_last_private > 0)
|
||||
&& (number_last_private > number_last_channel))
|
||||
{
|
||||
number_found = number_last_private + 1;
|
||||
}
|
||||
else if ((number_last_channel > 0)
|
||||
&& (number_last_channel > number_last_private))
|
||||
{
|
||||
number_found = number_last_channel + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
if ((number_found == 0)
|
||||
&& (weechat_config_enum (irc_config_look_server_buffer) ==
|
||||
IRC_CONFIG_LOOK_SERVER_BUFFER_INDEPENDENT))
|
||||
{
|
||||
number_found = weechat_buffer_get_integer (server->buffer, "number") + 1;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,5 +54,8 @@ extern int irc_buffer_nickcmp_cb (const void *pointer, void *data,
|
||||
const char *nick1, const char *nick2);
|
||||
extern struct t_gui_buffer *irc_buffer_search_server_lowest_number ();
|
||||
extern struct t_gui_buffer *irc_buffer_search_private_lowest_number (struct t_irc_server *server);
|
||||
extern void irc_buffer_move_near_server (struct t_irc_server *server,
|
||||
int list_buffer, int channel_type,
|
||||
struct t_gui_buffer *buffer);
|
||||
|
||||
#endif /* WEECHAT_PLUGIN_IRC_BUFFER_H */
|
||||
|
||||
@@ -75,90 +75,6 @@ irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Moves 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];
|
||||
const char *ptr_type, *ptr_server_name;
|
||||
struct t_hdata *hdata_buffer;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
number = weechat_buffer_get_integer (buffer, "number");
|
||||
number_last_channel = 0;
|
||||
number_last_private = 0;
|
||||
number_found = 0;
|
||||
|
||||
hdata_buffer = weechat_hdata_get ("buffer");
|
||||
ptr_buffer = weechat_hdata_get_list (hdata_buffer, "gui_buffers");
|
||||
while (ptr_buffer)
|
||||
{
|
||||
if ((ptr_buffer != buffer)
|
||||
&& (weechat_buffer_get_pointer (ptr_buffer,
|
||||
"plugin") == weechat_irc_plugin))
|
||||
{
|
||||
ptr_type = weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_type");
|
||||
ptr_server_name = weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_server");
|
||||
number_channel = weechat_buffer_get_integer (ptr_buffer,
|
||||
"number");
|
||||
if (ptr_type && ptr_type[0]
|
||||
&& ptr_server_name && ptr_server_name[0]
|
||||
&& (strcmp (ptr_server_name, server->name) == 0))
|
||||
{
|
||||
if (strcmp (ptr_type, "channel") == 0)
|
||||
{
|
||||
if (number_channel > number_last_channel)
|
||||
number_last_channel = number_channel;
|
||||
}
|
||||
else if (strcmp (ptr_type, "private") == 0)
|
||||
{
|
||||
if (number_channel > number_last_private)
|
||||
number_last_private = number_channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* move to next buffer */
|
||||
ptr_buffer = weechat_hdata_move (hdata_buffer, ptr_buffer, 1);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
if ((number_found == 0)
|
||||
&& (weechat_config_enum (irc_config_look_server_buffer) ==
|
||||
IRC_CONFIG_LOOK_SERVER_BUFFER_INDEPENDENT))
|
||||
{
|
||||
number_found = weechat_buffer_get_integer (server->buffer, "number") + 1;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for a channel by name.
|
||||
*
|
||||
@@ -374,8 +290,11 @@ irc_channel_create_buffer (struct t_irc_server *server,
|
||||
break;
|
||||
case IRC_CONFIG_LOOK_BUFFER_POSITION_NEAR_SERVER:
|
||||
/* move buffer after last channel/pv of server */
|
||||
irc_channel_move_near_server (server, channel_type,
|
||||
ptr_buffer);
|
||||
irc_buffer_move_near_server (
|
||||
server,
|
||||
0, /* list_buffer */
|
||||
channel_type,
|
||||
ptr_buffer);
|
||||
break;
|
||||
}
|
||||
if (ptr_buffer_for_merge)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-input.h"
|
||||
#include "irc-join.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-message.h"
|
||||
#include "irc-mode.h"
|
||||
#include "irc-modelist.h"
|
||||
@@ -3369,15 +3370,38 @@ IRC_COMMAND_CALLBACK(links)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets an integer argument given to the /list command.
|
||||
*/
|
||||
|
||||
int
|
||||
irc_command_list_get_int_arg (int argc, char **argv, int arg_number,
|
||||
int default_value)
|
||||
{
|
||||
long value;
|
||||
char *error;
|
||||
|
||||
value = default_value;
|
||||
if (argc > arg_number)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (argv[arg_number], &error, 10);
|
||||
if (!error || error[0])
|
||||
value = default_value;
|
||||
}
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for command "/list": lists channels and their topics.
|
||||
*/
|
||||
|
||||
IRC_COMMAND_CALLBACK(list)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
char buf[512], *ptr_channel_name, *ptr_server_name, *ptr_regex;
|
||||
regex_t *new_regexp;
|
||||
int i, ret;
|
||||
int i, ret, value;
|
||||
|
||||
IRC_BUFFER_GET_SERVER(buffer);
|
||||
|
||||
@@ -3390,6 +3414,69 @@ IRC_COMMAND_CALLBACK(list)
|
||||
ptr_regex = NULL;
|
||||
new_regexp = NULL;
|
||||
|
||||
if ((argc > 0) && (weechat_strcmp (argv[1], "-up") == 0))
|
||||
{
|
||||
if (ptr_server && ptr_server->list->buffer)
|
||||
{
|
||||
irc_list_move_line_relative (
|
||||
ptr_server,
|
||||
-1 * irc_command_list_get_int_arg (argc, argv, 2, 1));
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if ((argc > 0) && (weechat_strcmp (argv[1], "-down") == 0))
|
||||
{
|
||||
if (ptr_server && ptr_server->list->buffer)
|
||||
{
|
||||
irc_list_move_line_relative (
|
||||
ptr_server,
|
||||
irc_command_list_get_int_arg (argc, argv, 2, 1));
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if ((argc > 0) && (weechat_strcmp (argv[1], "-go") == 0))
|
||||
{
|
||||
if (ptr_server && ptr_server->list->buffer)
|
||||
{
|
||||
if (argc < 3)
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
value = (weechat_strcmp (argv[2], "end") == 0) ?
|
||||
-1 : irc_command_list_get_int_arg (argc, argv, 2, -2);
|
||||
if (value < -1)
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
irc_list_move_line_absolute (ptr_server, value);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if ((argc > 0) && (weechat_strcmp (argv[1], "-left") == 0))
|
||||
{
|
||||
if (ptr_server && ptr_server->list->buffer)
|
||||
{
|
||||
value = irc_command_list_get_int_arg (
|
||||
argc, argv, 2,
|
||||
weechat_config_integer (irc_config_look_list_buffer_scroll_horizontal));
|
||||
irc_list_scroll_horizontal (ptr_server, -1 * value);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if ((argc > 0) && (weechat_strcmp (argv[1], "-right") == 0))
|
||||
{
|
||||
if (ptr_server && ptr_server->list->buffer)
|
||||
{
|
||||
value = irc_command_list_get_int_arg (
|
||||
argc, argv, 2,
|
||||
weechat_config_integer (irc_config_look_list_buffer_scroll_horizontal));
|
||||
irc_list_scroll_horizontal (ptr_server, value);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
if ((argc > 0) && (weechat_strcmp (argv[1], "-join") == 0))
|
||||
{
|
||||
if (ptr_server && ptr_server->list->buffer)
|
||||
irc_list_join_channel (ptr_server);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (weechat_strcmp (argv[i], "-server") == 0)
|
||||
@@ -3458,6 +3545,39 @@ IRC_COMMAND_CALLBACK(list)
|
||||
ptr_server->cmd_list_regexp = NULL;
|
||||
}
|
||||
|
||||
if (ptr_server->list && !ptr_server->cmd_list_regexp)
|
||||
{
|
||||
hashtable = weechat_hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
if (hashtable)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, "server", ptr_server->name);
|
||||
weechat_hashtable_set (hashtable, "pattern", "list");
|
||||
snprintf (buf, sizeof (buf), "server_%s", ptr_server->name);
|
||||
weechat_hashtable_set (hashtable, "signal", buf);
|
||||
weechat_hook_hsignal_send ("irc_redirect_command", hashtable);
|
||||
weechat_hashtable_free (hashtable);
|
||||
}
|
||||
|
||||
irc_list_reset (ptr_server);
|
||||
|
||||
if (ptr_server->list->buffer)
|
||||
weechat_buffer_clear (ptr_server->list->buffer);
|
||||
else
|
||||
ptr_server->list->buffer = irc_list_create_buffer (ptr_server);
|
||||
if (ptr_server->list->buffer)
|
||||
{
|
||||
weechat_printf_y (ptr_server->list->buffer, 1,
|
||||
"%s",
|
||||
_("Receiving list of channels, please wait..."));
|
||||
irc_list_buffer_set_title (ptr_server);
|
||||
weechat_buffer_set (ptr_server->list->buffer, "display", "1");
|
||||
}
|
||||
}
|
||||
|
||||
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
|
||||
"LIST%s%s%s%s",
|
||||
(ptr_channel_name) ? " " : "",
|
||||
@@ -7155,24 +7275,84 @@ irc_command_init ()
|
||||
"list",
|
||||
N_("list channels and their topics"),
|
||||
N_("[-server <server>] [-re <regex>] [<channel>[,<channel>...]] "
|
||||
"[<target>]"),
|
||||
"[<target>]"
|
||||
" || -up|-down [<number>]"
|
||||
" || -left|-right [<percent>]"
|
||||
" || -go <line>|end"
|
||||
" || -join"),
|
||||
N_(" server: send to this server (internal name)\n"
|
||||
" regex: POSIX extended regular expression used to filter results "
|
||||
"(case insensitive, can start by \"(?-i)\" to become case "
|
||||
"sensitive)\n"
|
||||
"channel: channel to list\n"
|
||||
" target: server name\n"
|
||||
" -up: move the selected line up by \"number\" lines\n"
|
||||
" -down: move the selected line down by \"number\" lines\n"
|
||||
" -left: scroll the list buffer by \"percent\" of width "
|
||||
"on the left\n"
|
||||
" -right: scroll the list buffer by \"percent\" of width "
|
||||
"on the right\n"
|
||||
" -go: select a line by number, first line number is 0 "
|
||||
"(\"end\" to select the last line)\n"
|
||||
" -join: join the channel on the selected line\n"
|
||||
"\n"
|
||||
"Keys and input on /list buffer:\n"
|
||||
" up move one line up\n"
|
||||
" down move one line down\n"
|
||||
" pgup move one page up\n"
|
||||
" pgdn move one page down\n"
|
||||
" alt-home << move to first line\n"
|
||||
" alt-end >> move to last line\n"
|
||||
" F11 < scroll horizontally on the left\n"
|
||||
" F12 > scroll horizontally on the right\n"
|
||||
" * show all channels (no filter)\n"
|
||||
" xxx show only channels with \"xxx\" in name or topic (case insensitive)\n"
|
||||
" n:xxx show only channels with \"xxx\" in name (case insensitive)\n"
|
||||
" u:n show only channels with at least \"n\" users\n"
|
||||
" u:>n show only channels with more than \"n\" users\n"
|
||||
" u:<n show only channels with less than \"n\" users\n"
|
||||
" t:xxx show only channels with \"xxx\" in topic (case insensitive)\n"
|
||||
" c:xxx show only channels matching the evaluated "
|
||||
"condition \"xxx\", using following variables: name, name2, users, "
|
||||
"topic\n"
|
||||
" ctrl-j j join channel on selected line\n"
|
||||
" s:x,y sort channels by fields x,y (see below)\n"
|
||||
" s: reset sort to its default value (see below)\n"
|
||||
" $ refresh list\n"
|
||||
" q close buffer\n"
|
||||
"\n"
|
||||
"Sort keys on /list buffer:\n"
|
||||
" name channel name (eg: \"##test\")\n"
|
||||
" name2 channel name without prefix (eg: \"test\")\n"
|
||||
" users number of users on channel\n"
|
||||
" topic channel topic\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" list all channels on server (can be very slow on large networks):\n"
|
||||
" list all channels on server and display them in a dedicated buffer "
|
||||
"(can be slow on large networks):\n"
|
||||
" /list\n"
|
||||
" list channel #weechat:\n"
|
||||
" /list #weechat\n"
|
||||
" list all channels beginning with \"#weechat\" (can be very slow "
|
||||
"on large networks):\n"
|
||||
" /list -re #weechat.*"),
|
||||
" /list -re #weechat.*\n"
|
||||
" on /list buffer:\n"
|
||||
" channels with \"weechat\" in name:\n"
|
||||
" n:weechat\n"
|
||||
" channels with at least 100 users:\n"
|
||||
" u:100\n"
|
||||
" channels with \"freebsd\" (case insensitive) in topic and more than 10 users:\n"
|
||||
" c:${topic} =- freebsd && ${users} > 10\n"
|
||||
" sort channels by users (big channels first), then name2 (name without prefix):\n"
|
||||
" s:-users,name2"),
|
||||
"-server %(irc_servers)"
|
||||
" || -re",
|
||||
" || -re"
|
||||
" || -up 1|2|3|4|5"
|
||||
" || -down 1|2|3|4|5"
|
||||
" || -left 10|20|30|40|50|60|70|80|90|100"
|
||||
" || -right 10|20|30|40|50|60|70|80|90|100"
|
||||
" || -go 0|end"
|
||||
" || -join",
|
||||
&irc_command_list, NULL, NULL);
|
||||
weechat_hook_command (
|
||||
"lusers",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "irc-channel.h"
|
||||
#include "irc-ctcp.h"
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-mode.h"
|
||||
#include "irc-msgbuffer.h"
|
||||
#include "irc-nick.h"
|
||||
@@ -91,8 +92,12 @@ struct t_config_option *irc_config_look_item_display_server = NULL;
|
||||
struct t_config_option *irc_config_look_item_nick_modes = NULL;
|
||||
struct t_config_option *irc_config_look_item_nick_prefix = NULL;
|
||||
struct t_config_option *irc_config_look_join_auto_add_chantype = NULL;
|
||||
struct t_config_option *irc_config_look_list_buffer_scroll_horizontal = NULL;
|
||||
struct t_config_option *irc_config_look_list_buffer_sort = NULL;
|
||||
struct t_config_option *irc_config_look_list_buffer_topic_strip_colors = NULL;
|
||||
struct t_config_option *irc_config_look_msgbuffer_fallback = NULL;
|
||||
struct t_config_option *irc_config_look_new_channel_position = NULL;
|
||||
struct t_config_option *irc_config_look_new_list_position = NULL;
|
||||
struct t_config_option *irc_config_look_new_pv_position = NULL;
|
||||
struct t_config_option *irc_config_look_nick_completion_smart = NULL;
|
||||
struct t_config_option *irc_config_look_nick_mode = NULL;
|
||||
@@ -133,6 +138,8 @@ struct t_config_option *irc_config_color_item_nick_modes = NULL;
|
||||
struct t_config_option *irc_config_color_item_tls_version_deprecated = NULL;
|
||||
struct t_config_option *irc_config_color_item_tls_version_insecure = NULL;
|
||||
struct t_config_option *irc_config_color_item_tls_version_ok = NULL;
|
||||
struct t_config_option *irc_config_color_list_buffer_line_selected = NULL;
|
||||
struct t_config_option *irc_config_color_list_buffer_line_selected_bg = NULL;
|
||||
struct t_config_option *irc_config_color_message_account = NULL;
|
||||
struct t_config_option *irc_config_color_message_chghost = NULL;
|
||||
struct t_config_option *irc_config_color_message_join = NULL;
|
||||
@@ -735,6 +742,29 @@ irc_config_change_color_item_tls_version (const void *pointer, void *data,
|
||||
weechat_bar_item_update ("tls_version");
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on options "irc.color.list_buffer_*".
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_color_list_buffer (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;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->list->buffer)
|
||||
irc_list_buffer_refresh (ptr_server, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "irc.color.mirc_remap".
|
||||
*/
|
||||
@@ -3230,6 +3260,34 @@ irc_config_init ()
|
||||
"will in fact send: \"/join #weechat\""),
|
||||
NULL, 0, 0, "off", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_list_buffer_scroll_horizontal = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
"list_buffer_scroll_horizontal", "integer",
|
||||
N_("left/right scroll in /list buffer (percent of width)"),
|
||||
NULL, 1, 100, "10", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_look_list_buffer_sort = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
"list_buffer_sort", "string",
|
||||
N_("comma-separated list of fields to sort channels (see /help list "
|
||||
"for a list of fields); char \"-\" can be used before field to "
|
||||
"reverse order, char \"~\" can be used to do a case insensitive "
|
||||
"comparison; example: \"-count,~name\" for biggest channels "
|
||||
"first then case insensitive sort on name"),
|
||||
NULL, 0, 0, "~name2", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_look_list_buffer_topic_strip_colors = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
"list_buffer_topic_strip_colors", "boolean",
|
||||
N_("strip channel topic colors in /list buffer"),
|
||||
NULL, 0, 0, "on", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_look_msgbuffer_fallback = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
"msgbuffer_fallback", "enum",
|
||||
@@ -3246,6 +3304,15 @@ irc_config_init ()
|
||||
"of server)"),
|
||||
"none|next|near_server", 0, 0, "none", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_new_list_position = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
"new_list_position", "enum",
|
||||
N_("force position of new /list buffer in list of buffers "
|
||||
"(none = default position (should be last buffer), "
|
||||
"next = current buffer + 1, near_server = after last channel/pv "
|
||||
"of server)"),
|
||||
"none|next|near_server", 0, 0, "none", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_new_pv_position = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_look,
|
||||
"new_pv_position", "enum",
|
||||
@@ -3564,6 +3631,22 @@ irc_config_init ()
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_color_item_tls_version, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_color_list_buffer_line_selected = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
"list_buffer_line_selected", "color",
|
||||
N_("color for selected line on /list buffer"),
|
||||
NULL, -1, 0, "white", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_color_list_buffer, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_color_list_buffer_line_selected_bg = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
"list_buffer_line_selected_bg", "color",
|
||||
N_("background color for selected line on /list buffer"),
|
||||
NULL, -1, 0, "24", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&irc_config_change_color_list_buffer, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
irc_config_color_message_account = weechat_config_new_option (
|
||||
irc_config_file, irc_config_section_color,
|
||||
"message_account", "color",
|
||||
|
||||
@@ -127,8 +127,12 @@ extern struct t_config_option *irc_config_look_item_display_server;
|
||||
extern struct t_config_option *irc_config_look_item_nick_modes;
|
||||
extern struct t_config_option *irc_config_look_item_nick_prefix;
|
||||
extern struct t_config_option *irc_config_look_join_auto_add_chantype;
|
||||
extern struct t_config_option *irc_config_look_list_buffer_scroll_horizontal;
|
||||
extern struct t_config_option *irc_config_look_list_buffer_sort;
|
||||
extern struct t_config_option *irc_config_look_list_buffer_topic_strip_colors;
|
||||
extern struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
extern struct t_config_option *irc_config_look_new_channel_position;
|
||||
extern struct t_config_option *irc_config_look_new_list_position;
|
||||
extern struct t_config_option *irc_config_look_new_pv_position;
|
||||
extern struct t_config_option *irc_config_look_nick_completion_smart;
|
||||
extern struct t_config_option *irc_config_look_nick_mode;
|
||||
@@ -167,6 +171,8 @@ extern struct t_config_option *irc_config_color_item_nick_modes;
|
||||
extern struct t_config_option *irc_config_color_item_tls_version_deprecated;
|
||||
extern struct t_config_option *irc_config_color_item_tls_version_insecure;
|
||||
extern struct t_config_option *irc_config_color_item_tls_version_ok;
|
||||
extern struct t_config_option *irc_config_color_list_buffer_line_selected;
|
||||
extern struct t_config_option *irc_config_color_list_buffer_line_selected_bg;
|
||||
extern struct t_config_option *irc_config_color_message_account;
|
||||
extern struct t_config_option *irc_config_color_message_chghost;
|
||||
extern struct t_config_option *irc_config_color_message_join;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "irc-color.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-message.h"
|
||||
#include "irc-modelist.h"
|
||||
#include "irc-nick.h"
|
||||
@@ -1384,4 +1385,10 @@ irc_info_init ()
|
||||
weechat_hook_hdata (
|
||||
"irc_batch", N_("irc batch"),
|
||||
&irc_batch_hdata_batch_cb, NULL, NULL);
|
||||
weechat_hook_hdata (
|
||||
"irc_list_channel", N_("irc channel on /list buffer"),
|
||||
&irc_list_hdata_list_channel_cb, NULL, NULL);
|
||||
weechat_hook_hdata (
|
||||
"irc_list", N_("irc data for /list buffer"),
|
||||
&irc_list_hdata_list_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "irc-nick.h"
|
||||
#include "irc-color.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-msgbuffer.h"
|
||||
#include "irc-protocol.h"
|
||||
#include "irc-raw.h"
|
||||
@@ -365,6 +366,12 @@ irc_input_data (struct t_gui_buffer *buffer, const char *input_data, int flags,
|
||||
else
|
||||
irc_raw_filter_options (input_data);
|
||||
}
|
||||
else if (weechat_strcmp (
|
||||
weechat_buffer_get_string (buffer,
|
||||
"localvar_type"), "irc_list") == 0)
|
||||
{
|
||||
irc_list_buffer_input_data (buffer, input_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
|
||||
*
|
||||
* This file is part of WeeChat, the extensible chat client.
|
||||
*
|
||||
* WeeChat is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WeeChat is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WEECHAT_PLUGIN_IRC_LIST_H
|
||||
#define WEECHAT_PLUGIN_IRC_LIST_H
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#define IRC_LIST_MOUSE_HSIGNAL "irc_list_mouse"
|
||||
|
||||
struct t_irc_server;
|
||||
|
||||
struct t_irc_list_channel
|
||||
{
|
||||
char *name; /* channel name */
|
||||
char *name2; /* channel name without prefix ('#') */
|
||||
int users; /* number of users in the channel */
|
||||
char *topic; /* channel topic */
|
||||
};
|
||||
|
||||
struct t_irc_list
|
||||
{
|
||||
struct t_gui_buffer *buffer; /* buffer for /list */
|
||||
struct t_arraylist *channels; /* channels received in /list reply */
|
||||
struct t_arraylist *filter_channels; /* filtered channels */
|
||||
int name_max_length; /* max length for channel name */
|
||||
char *filter; /* filter for channels */
|
||||
char *sort; /* sort for channels */
|
||||
char **sort_fields; /* sort fields */
|
||||
int sort_fields_count; /* number of sort fields */
|
||||
int selected_line; /* selected line */
|
||||
};
|
||||
|
||||
extern void irc_list_buffer_set_title (struct t_irc_server *server);
|
||||
extern void irc_list_buffer_refresh (struct t_irc_server *server, int clear);
|
||||
extern int irc_list_window_scrolled_cb (const void *pointer, void *data,
|
||||
const char *signal,
|
||||
const char *type_data,
|
||||
void *signal_data);
|
||||
extern void irc_list_move_line_relative (struct t_irc_server *server,
|
||||
int num_lines);
|
||||
extern void irc_list_move_line_absolute (struct t_irc_server *server,
|
||||
int line_number);
|
||||
extern void irc_list_scroll_horizontal (struct t_irc_server *server,
|
||||
int percent);
|
||||
extern void irc_list_join_channel (struct t_irc_server *server);
|
||||
extern int irc_list_buffer_input_data (struct t_gui_buffer *buffer,
|
||||
const char *input_data);
|
||||
extern struct t_gui_buffer *irc_list_create_buffer (struct t_irc_server *server);
|
||||
extern int irc_list_hsignal_redirect_list_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *signal,
|
||||
struct t_hashtable *hashtable);
|
||||
extern void irc_list_reset (struct t_irc_server *server);
|
||||
extern struct t_irc_list *irc_list_alloc ();
|
||||
extern void irc_list_free (struct t_irc_server *server);
|
||||
extern struct t_hdata *irc_list_hdata_list_channel_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *hdata_name);
|
||||
extern struct t_hdata *irc_list_hdata_list_cb (const void *pointer, void *data,
|
||||
const char *hdata_name);
|
||||
extern void irc_list_init ();
|
||||
extern void irc_list_end ();
|
||||
|
||||
#endif /* WEECHAT_PLUGIN_IRC_LIST_H */
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "irc-command.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-input.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-message.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-notify.h"
|
||||
@@ -1740,6 +1741,7 @@ irc_server_alloc (const char *name)
|
||||
weechat_config_integer (irc_config_network_lag_check);
|
||||
new_server->lag_last_refresh = 0;
|
||||
new_server->cmd_list_regexp = NULL;
|
||||
new_server->list = irc_list_alloc (new_server);
|
||||
new_server->last_user_message = 0;
|
||||
new_server->last_away_check = 0;
|
||||
new_server->last_data_purge = 0;
|
||||
@@ -2325,6 +2327,8 @@ irc_server_free_data (struct t_irc_server *server)
|
||||
regfree (server->cmd_list_regexp);
|
||||
free (server->cmd_list_regexp);
|
||||
}
|
||||
if (server->list)
|
||||
irc_list_free (server);
|
||||
if (server->buffer_as_string)
|
||||
free (server->buffer_as_string);
|
||||
}
|
||||
@@ -6474,6 +6478,7 @@ irc_server_hdata_server_cb (const void *pointer, void *data,
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, lag_next_check, TIME, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, lag_last_refresh, TIME, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, cmd_list_regexp, POINTER, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, list, POINTER, 0, NULL, "irc_list");
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_user_message, TIME, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_away_check, TIME, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_irc_server, last_data_purge, TIME, 0, NULL, NULL);
|
||||
@@ -7255,6 +7260,13 @@ irc_server_print_log ()
|
||||
weechat_log_printf (" lag_next_check. . . . . . : %lld", (long long)ptr_server->lag_next_check);
|
||||
weechat_log_printf (" lag_last_refresh. . . . . : %lld", (long long)ptr_server->lag_last_refresh);
|
||||
weechat_log_printf (" cmd_list_regexp . . . . . : 0x%lx", ptr_server->cmd_list_regexp);
|
||||
weechat_log_printf (" list. . . . . . . . . . . : 0x%lx", ptr_server->list);
|
||||
if (ptr_server->list)
|
||||
{
|
||||
weechat_log_printf (" buffer. . . . . . . . . : 0x%lx", ptr_server->list->buffer);
|
||||
weechat_log_printf (" channels. . . . . . . . : 0x%lx", ptr_server->list->channels);
|
||||
weechat_log_printf (" filter_channels . . . . : 0x%lx", ptr_server->list->filter_channels);
|
||||
}
|
||||
weechat_log_printf (" last_user_message . . . . : %lld", (long long)ptr_server->last_user_message);
|
||||
weechat_log_printf (" last_away_check . . . . . : %lld", (long long)ptr_server->last_away_check);
|
||||
weechat_log_printf (" last_data_purge . . . . . : %lld", (long long)ptr_server->last_data_purge);
|
||||
|
||||
@@ -280,6 +280,7 @@ struct t_irc_server
|
||||
time_t lag_next_check; /* time for next check */
|
||||
time_t lag_last_refresh; /* last refresh of lag item */
|
||||
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
|
||||
struct t_irc_list *list; /* /list buffer management */
|
||||
time_t last_user_message; /* time of last user message (anti flood)*/
|
||||
time_t last_away_check; /* time of last away check on server */
|
||||
time_t last_data_purge; /* time of last purge (some hashtables) */
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "irc-channel.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-input.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-modelist.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-notify.h"
|
||||
@@ -323,6 +324,15 @@ irc_upgrade_set_buffer_callbacks ()
|
||||
ptr_server);
|
||||
}
|
||||
}
|
||||
if (type && (strcmp (type, "irc_list") == 0))
|
||||
{
|
||||
ptr_server = irc_server_search (
|
||||
weechat_buffer_get_string (ptr_buffer,
|
||||
"localvar_server"));
|
||||
if (ptr_server)
|
||||
ptr_server->list->buffer = ptr_buffer;
|
||||
irc_list_buffer_refresh (ptr_server, 1);
|
||||
}
|
||||
if (strcmp (weechat_infolist_string (infolist, "name"),
|
||||
IRC_RAW_BUFFER_NAME) == 0)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-info.h"
|
||||
#include "irc-input.h"
|
||||
#include "irc-list.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-notify.h"
|
||||
#include "irc-protocol.h"
|
||||
@@ -197,6 +198,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
|
||||
irc_config_read ();
|
||||
|
||||
irc_list_init ();
|
||||
|
||||
irc_raw_init ();
|
||||
|
||||
irc_command_init ();
|
||||
@@ -223,12 +226,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
&irc_input_send_cb, NULL, NULL);
|
||||
weechat_hook_signal ("typing_self_*",
|
||||
&irc_typing_signal_typing_self_cb, NULL, NULL);
|
||||
weechat_hook_signal ("window_scrolled",
|
||||
&irc_list_window_scrolled_cb, NULL, NULL);
|
||||
|
||||
/* hook hsignals for redirection */
|
||||
weechat_hook_hsignal ("irc_redirect_pattern",
|
||||
&irc_redirect_pattern_hsignal_cb, NULL, NULL);
|
||||
weechat_hook_hsignal ("irc_redirect_command",
|
||||
&irc_redirect_command_hsignal_cb, NULL, NULL);
|
||||
weechat_hook_hsignal ("irc_redirection_server_*_list",
|
||||
&irc_list_hsignal_redirect_list_cb, NULL, NULL);
|
||||
|
||||
/* modifiers */
|
||||
weechat_hook_modifier ("irc_color_decode",
|
||||
@@ -322,6 +329,8 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
|
||||
|
||||
irc_ignore_free_all ();
|
||||
|
||||
irc_list_end ();
|
||||
|
||||
irc_raw_end ();
|
||||
|
||||
irc_server_free_all ();
|
||||
|
||||
Reference in New Issue
Block a user