summaryrefslogtreecommitdiff
path: root/src/fe-common/core/chat-completion.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-10-14 16:12:01 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-10-14 16:12:01 +0000
commitfb5c4c8037b51e42ad89fe5fa4f979496bd314af (patch)
treec43d6488c070b0ba4c6c2c74f573ca97520ffe75 /src/fe-common/core/chat-completion.c
parentfa1687596c0d04dc381851b5d375be893574d3fc (diff)
downloadirssi-fb5c4c8037b51e42ad89fe5fa4f979496bd314af.zip
More tab completion: /DISCONNECT, /SERVER ADD|REMOVE, /STATS
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2954 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/chat-completion.c')
-rw-r--r--src/fe-common/core/chat-completion.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c
index 06e09bd7..9ce52589 100644
--- a/src/fe-common/core/chat-completion.c
+++ b/src/fe-common/core/chat-completion.c
@@ -35,6 +35,7 @@
#include "nicklist.h"
#include "completion.h"
+#include "chat-completion.h"
#include "window-items.h"
static int keep_privates_count, keep_publics_count;
@@ -485,6 +486,32 @@ static GList *completion_joinlist(GList *list1, GList *list2)
return list1;
}
+GList *completion_get_servertags(const char *word)
+{
+ GList *list;
+ GSList *tmp;
+ int len;
+
+ g_return_val_if_fail(word != NULL, NULL);
+
+ len = strlen(word);
+ list = NULL;
+
+ for (tmp = servers; tmp != NULL; tmp = tmp->next) {
+ SERVER_REC *rec = tmp->data;
+
+ if (g_strncasecmp(rec->tag, word, len) == 0) {
+ if (rec == active_win->active_server)
+ list = g_list_prepend(list, g_strdup(rec->tag));
+ else
+ list = g_list_append(list, g_strdup(rec->tag));
+ }
+
+ }
+
+ return list;
+}
+
GList *completion_get_channels(SERVER_REC *server, const char *word)
{
GList *list;
@@ -492,7 +519,6 @@ GList *completion_get_channels(SERVER_REC *server, const char *word)
int len;
g_return_val_if_fail(word != NULL, NULL);
- g_return_val_if_fail(*word != '\0', NULL);
len = strlen(word);
list = NULL;
@@ -772,6 +798,17 @@ static void sig_complete_connect(GList **list, WINDOW_REC *window,
if (*list != NULL) signal_stop();
}
+static void sig_complete_tag(GList **list, WINDOW_REC *window,
+ const char *word, const char *line,
+ int *want_space)
+{
+ g_return_if_fail(list != NULL);
+ g_return_if_fail(word != NULL);
+
+ *list = completion_get_servertags(word);
+ if (*list != NULL) signal_stop();
+}
+
static void sig_complete_topic(GList **list, WINDOW_REC *window,
const char *word, const char *line,
int *want_space)
@@ -854,6 +891,17 @@ static void sig_complete_channel(GList **list, WINDOW_REC *window,
if (*list != NULL) signal_stop();
}
+static void sig_complete_server(GList **list, WINDOW_REC *window,
+ const char *word, const char *line,
+ int *want_space)
+{
+ g_return_if_fail(list != NULL);
+ g_return_if_fail(word != NULL);
+
+ *list = completion_get_servers(word);
+ if (*list != NULL) signal_stop();
+}
+
/* expand \n, \t and \\ */
static char *expand_escapes(const char *line, SERVER_REC *server,
WI_ITEM_REC *item)
@@ -1031,11 +1079,14 @@ void chat_completion_init(void)
signal_add("complete erase command action", (SIGNAL_FUNC) sig_erase_complete_msg);
signal_add("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
signal_add("complete command server", (SIGNAL_FUNC) sig_complete_connect);
+ signal_add("complete command disconnect", (SIGNAL_FUNC) sig_complete_tag);
signal_add("complete command topic", (SIGNAL_FUNC) sig_complete_topic);
signal_add("complete command away", (SIGNAL_FUNC) sig_complete_away);
signal_add("complete command unalias", (SIGNAL_FUNC) sig_complete_unalias);
signal_add("complete command alias", (SIGNAL_FUNC) sig_complete_alias);
signal_add("complete command window item move", (SIGNAL_FUNC) sig_complete_channel);
+ signal_add("complete command server add", (SIGNAL_FUNC) sig_complete_server);
+ signal_add("complete command server remove", (SIGNAL_FUNC) sig_complete_server);
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
signal_add("message join", (SIGNAL_FUNC) sig_message_join);
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
@@ -1063,11 +1114,14 @@ void chat_completion_deinit(void)
signal_remove("complete erase command action", (SIGNAL_FUNC) sig_erase_complete_msg);
signal_remove("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
signal_remove("complete command server", (SIGNAL_FUNC) sig_complete_connect);
+ signal_remove("complete command disconnect", (SIGNAL_FUNC) sig_complete_tag);
signal_remove("complete command topic", (SIGNAL_FUNC) sig_complete_topic);
signal_remove("complete command away", (SIGNAL_FUNC) sig_complete_away);
signal_remove("complete command unalias", (SIGNAL_FUNC) sig_complete_unalias);
signal_remove("complete command alias", (SIGNAL_FUNC) sig_complete_alias);
signal_remove("complete command window item move", (SIGNAL_FUNC) sig_complete_channel);
+ signal_remove("complete command server add", (SIGNAL_FUNC) sig_complete_server);
+ signal_remove("complete command server remove", (SIGNAL_FUNC) sig_complete_server);
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);