diff options
author | Timo Sirainen <cras@irssi.org> | 2002-02-03 21:53:37 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-02-03 21:53:37 +0000 |
commit | 7c94cb083f5354cf85453e9465887fc45bf5bcdc (patch) | |
tree | b014e28fe402bf627de7e762160223b3eb663280 /src/fe-common | |
parent | 6ea882f8932e115c32f7b3991cb0a7685a359e56 (diff) | |
download | irssi-7c94cb083f5354cf85453e9465887fc45bf5bcdc.zip |
Added target_type to send_message(), -channel and -nick parameters to /MSG
to specify if it's supposed to be to channel/nick. /MSG -channel is used
automatically by irssi when sending messages to channel (the "normal" way
without /msg). This should help with protocols that don't have any channel
name prefixes.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2383 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/chat-completion.c | 67 | ||||
-rw-r--r-- | src/fe-common/core/fe-queries.c | 13 |
2 files changed, 48 insertions, 32 deletions
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c index 6b988a1c..7be923fc 100644 --- a/src/fe-common/core/chat-completion.c +++ b/src/fe-common/core/chat-completion.c @@ -762,48 +762,62 @@ static char *expand_escapes(const char *line, SERVER_REC *server, return ret; } -static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item) +static char *auto_complete(CHANNEL_REC *channel, const char *line) { - CHANNEL_REC *channel; GList *comp; - char *line, *str, *ptr, comp_char; + const char *p; + char *nick, *ret; + + p = strstr(line, completion_char); + if (p == NULL) + return NULL; + + nick = g_strndup(line, (int) (p-line)); + + ret = NULL; + if (nicklist_find(channel, nick) == NULL) { + /* not an exact match, use the first possible completion */ + comp = completion_channel_nicks(channel, nick, NULL); + if (comp != NULL) { + ret = g_strconcat(comp->data, p, NULL); + g_list_foreach(comp, (GFunc) g_free, NULL); + g_list_free(comp); + } + } + + g_free(nick); + + return ret; +} + +static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item) +{ + char *line, *str; g_return_if_fail(data != NULL); if (item == NULL) return; line = settings_get_bool("expand_escapes") ? expand_escapes(data, server, item) : g_strdup(data); - comp_char = *completion_char; /* check for automatic nick completion */ - ptr = NULL; - comp = NULL; - channel = CHANNEL(item); - - if (completion_auto && channel != NULL && comp_char != '\0') { - ptr = strchr(line, comp_char); - if (ptr != NULL) { - *ptr++ = '\0'; - if (nicklist_find(channel, line) == NULL) { - comp = completion_channel_nicks(channel, - line, NULL); - } + if (completion_auto && IS_CHANNEL(item)) { + str = auto_complete(CHANNEL(item), line); + if (str != NULL) { + g_free(line); + line = str; } } - str = g_strdup_printf(ptr == NULL ? "%s %s" : "%s %s%c%s", item->name, - comp != NULL ? (char *) comp->data : line, - comp_char, ptr); + str = g_strdup_printf(IS_CHANNEL(item) ? "-channel %s %s" : + IS_QUERY(item) ? "-nick %s %s" : "%s %s", + item->name, line); + signal_emit("command msg", 3, str, server, item); g_free(str); g_free(line); - if (comp != NULL) { - g_list_foreach(comp, (GFunc) g_free, NULL); - g_list_free(comp); - } - signal_stop(); } @@ -840,6 +854,11 @@ static void read_settings(void) cmdchars = settings_get_str("cmdchars"); completion_auto = settings_get_bool("completion_auto"); completion_strict = settings_get_bool("completion_strict"); + + if (*completion_char == '\0') { + /* this would break.. */ + completion_auto = FALSE; + } } void chat_completion_init(void) diff --git a/src/fe-common/core/fe-queries.c b/src/fe-common/core/fe-queries.c index 9847c886..39191e5a 100644 --- a/src/fe-common/core/fe-queries.c +++ b/src/fe-common/core/fe-queries.c @@ -226,7 +226,8 @@ static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item) query = query_find(server, nick); if (query == NULL) - CHAT_PROTOCOL(server)->query_create(server->tag, nick, FALSE); + query = CHAT_PROTOCOL(server)-> + query_create(server->tag, nick, FALSE); else { /* query already exists */ WINDOW_REC *window = window_item_window(query); @@ -252,13 +253,9 @@ static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item) } if (*msg != '\0') { - /* FIXME: we'll need some function that does both - of these. and separate the , and . target handling - from own_private messagge.. */ - server->send_message(server, nick, msg); - - signal_emit("message own_private", 4, - server, msg, nick, nick); + msg = g_strdup_printf("-nick %s %s", nick, msg); + signal_emit("command msg", 3, msg, server, query); + g_free(msg); } cmd_params_free(free_arg); |