You can send message to different server with /MSG -<server tag> nick...

Tab-completion changes:
 - in empty line, it completed /MSG nick1 fine, but another tab press
   didn't give the next nick.
 - "/command <tab>" doesn't try to complete /command, but instead it tries
   to complete it's subcommand or first parameter.
 - /MSG completion now goes through nicks in ALL servers prefixing the nick
   with -<server tag> if needed.
 - /MSG -tag <tab> completes only nicks in "tag" server.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@388 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-06-28 20:00:39 +00:00 committed by cras
commit 8fc1e0535c
8 changed files with 181 additions and 79 deletions

View file

@ -41,6 +41,7 @@ noinst_HEADERS = \
channels-setup.h \
ignore.h \
irc.h \
irc-commands.h \
irc-server.h \
ircnet-setup.h \
masks.h \

View file

@ -45,6 +45,29 @@ typedef struct {
static GString *tmpstr;
static int knockout_tag;
/* `optlist' should contain only one key - the server tag.
returns NULL if there was unknown -option */
IRC_SERVER_REC *irccmd_options_get_server(GHashTable *optlist, IRC_SERVER_REC *defserver)
{
SERVER_REC *server;
GSList *list;
/* -<server tag> */
list = hashtable_get_keys(optlist);
if (list == NULL) return defserver;
server = server_find_tag(list->data);
if (server == NULL || list->next != NULL) {
/* unknown option (not server tag) */
signal_emit("error command", 2, GINT_TO_POINTER(CMDERR_OPTION_UNKNOWN), list->data);
server = NULL;
}
g_slist_free(list);
return (IRC_SERVER_REC *) server;
}
static IRC_SERVER_REC *connect_server(const char *data)
{
IRC_SERVER_CONNECT_REC *conn;
@ -206,16 +229,20 @@ static void cmd_quit(const char *data)
static void cmd_msg(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item)
{
GHashTable *optlist;
char *target, *msg;
void *free_arg;
int free_ret;
g_return_if_fail(data != NULL);
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &msg))
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
"msg", &optlist, &target, &msg))
return;
if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
server = irccmd_options_get_server(optlist, server);
if (server == NULL || !server->connected || !irc_server_check(server))
cmd_param_error(CMDERR_NOT_CONNECTED);
@ -300,7 +327,6 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server)
static void cmd_join(const char *data, IRC_SERVER_REC *server)
{
GHashTable *optlist;
GSList *list;
char *channels;
void *free_arg;
@ -317,18 +343,7 @@ static void cmd_join(const char *data, IRC_SERVER_REC *server)
channels_join(server, server->last_invite, FALSE);
} else {
/* -<server tag> */
list = hashtable_get_keys(optlist);
if (list != NULL) {
server = (IRC_SERVER_REC *) server_find_tag(list->data);
if (server == NULL) {
/* unknown option (not server tag) */
signal_emit("error command", 2, GINT_TO_POINTER(CMDERR_OPTION_UNKNOWN), list->data);
signal_stop();
}
g_slist_free(list);
}
server = irccmd_options_get_server(optlist, server);
if (server != NULL) channels_join(server, channels, FALSE);
}

View file

@ -0,0 +1,8 @@
#ifndef __IRC_COMMANDS_H
#define __IRC_COMMANDS_H
/* `optlist' should contain only one key - the server tag.
returns NULL if there was unknown -option */
IRC_SERVER_REC *irccmd_options_get_server(GHashTable *optlist, IRC_SERVER_REC *defserver);
#endif

View file

@ -183,25 +183,6 @@ void irc_send_cmd_split(IRC_SERVER_REC *server, const char *cmd,
g_free(str);
}
/* Nick can be in format "servertag/nick" - Update `nick' to
position "nick" and return "servertag" which you need to free */
char *irc_nick_get_server(char **nick)
{
char *ptr, *tag;
ptr = strchr(*nick, '/');
if (ptr == NULL) return NULL;
if (ptr == *nick) {
(*nick)++;
return NULL;
}
tag = g_strndup(*nick, (int) (ptr-*nick));
*nick = ptr+1;
return tag;
}
/* Get next parameter */
char *event_get_param(char **data)
{

View file

@ -70,10 +70,6 @@ void irc_send_cmd_split(IRC_SERVER_REC *server, const char *cmd,
and queues. */
void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd);
/* Nick can be in format "servertag/nick" - Update `nick' to
position "nick" and return "servertag" which you need to free */
char *irc_nick_get_server(char **nick);
#include "commands.h" /* contains the generic PARAM_FLAG_xxx defines */
/* IRC specific: optional channel in first argument */