1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

Allow clear of multiple selected buffers with /clear (patch #6112)

This commit is contained in:
Sebastien Helleu
2007-08-08 09:07:19 +00:00
parent f68a2cbfcd
commit 028d38b44e
24 changed files with 1894 additions and 1878 deletions
+22 -18
View File
@@ -91,10 +91,10 @@ t_weechat_command weechat_commands[] =
N_("command: command to execute (a '/' is automatically added if not found at beginning of command)\n"),
"%w|%i", 0, MAX_ARGS, 1, NULL, weechat_cmd_builtin },
{ "clear", N_("clear window(s)"),
N_("[-all | number]"),
N_("[-all | number [number ...]]"),
N_(" -all: clear all buffers\n"
"number: clear buffer by number"),
"-all", 0, 1, 0, weechat_cmd_clear, NULL },
"-all", 0, MAX_ARGS, 0, weechat_cmd_clear, NULL },
{ "connect", N_("connect to server(s)"),
N_("[-all [-nojoin] | servername [servername ...] [-nojoin]]"),
N_(" -all: connect to all servers\n"
@@ -1522,35 +1522,39 @@ weechat_cmd_clear (t_irc_server *server, t_irc_channel *channel,
t_gui_buffer *buffer;
char *error;
long number;
int i;
if (argc == 1)
if (argc > 0)
{
if (ascii_strcasecmp (argv[0], "-all") == 0)
gui_buffer_clear_all ();
else
{
error = NULL;
number = strtol (argv[0], &error, 10);
if ((error) && (error[0] == '\0'))
for (i = 0; i < argc; i++)
{
buffer = gui_buffer_search_by_number (number);
if (!buffer)
error = NULL;
number = strtol (argv[i], &error, 10);
if ((error) && (error[0] == '\0'))
{
buffer = gui_buffer_search_by_number (number);
if (!buffer)
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s buffer number \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, argv[i], "clear");
return -1;
}
gui_buffer_clear (buffer);
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s buffer not found for \"%s\" command\n"),
_("%s unknown option for \"%s\" command\n"),
WEECHAT_ERROR, "clear");
return -1;
}
gui_buffer_clear (buffer);
}
else
{
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unknown option for \"%s\" command\n"),
WEECHAT_ERROR, "clear");
return -1;
}
}
}