diff options
author | Timo Sirainen <cras@irssi.org> | 2002-10-14 16:12:01 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-10-14 16:12:01 +0000 |
commit | fb5c4c8037b51e42ad89fe5fa4f979496bd314af (patch) | |
tree | c43d6488c070b0ba4c6c2c74f573ca97520ffe75 | |
parent | fa1687596c0d04dc381851b5d375be893574d3fc (diff) | |
download | irssi-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
-rw-r--r-- | src/fe-common/core/chat-completion.c | 56 | ||||
-rw-r--r-- | src/fe-common/core/chat-completion.h | 6 | ||||
-rw-r--r-- | src/fe-common/irc/Makefile.am | 1 | ||||
-rw-r--r-- | src/fe-common/irc/fe-common-irc.c | 5 | ||||
-rw-r--r-- | src/fe-common/irc/irc-completion.c | 41 |
5 files changed, 108 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); diff --git a/src/fe-common/core/chat-completion.h b/src/fe-common/core/chat-completion.h index 3cb70ca5..ff6098b1 100644 --- a/src/fe-common/core/chat-completion.h +++ b/src/fe-common/core/chat-completion.h @@ -1,6 +1,12 @@ #ifndef __CHAT_COMPLETION_H #define __CHAT_COMPLETION_H +GList *completion_get_chatnets(const char *word); +GList *completion_get_servers(const char *word); +GList *completion_get_servertags(const char *word); +GList *completion_get_channels(SERVER_REC *server, const char *word); +GList *completion_get_aliases(const char *word); + void completion_last_message_add(const char *nick); void completion_last_message_remove(const char *nick); void completion_last_message_rename(const char *oldnick, const char *newnick); diff --git a/src/fe-common/irc/Makefile.am b/src/fe-common/irc/Makefile.am index d633d247..99e3aa44 100644 --- a/src/fe-common/irc/Makefile.am +++ b/src/fe-common/irc/Makefile.am @@ -25,6 +25,7 @@ real_sources = \ fe-netjoin.c \ fe-netsplit.c \ fe-common-irc.c \ + irc-completion.c \ module-formats.c libfe_common_irc_a_SOURCES = \ diff --git a/src/fe-common/irc/fe-common-irc.c b/src/fe-common/irc/fe-common-irc.c index 9c0f6716..5168481f 100644 --- a/src/fe-common/irc/fe-common-irc.c +++ b/src/fe-common/irc/fe-common-irc.c @@ -68,6 +68,9 @@ void fe_netsplit_deinit(void); void fe_netjoin_init(void); void fe_netjoin_deinit(void); +void irc_completion_init(void); +void irc_completion_deinit(void); + void fe_common_irc_init(void) { settings_add_bool("lookandfeel", "show_away_once", TRUE); @@ -86,6 +89,7 @@ void fe_common_irc_init(void) fe_modes_init(); fe_netsplit_init(); fe_netjoin_init(); + irc_completion_init(); settings_check(); module_register("core", "fe-irc"); @@ -109,6 +113,7 @@ void fe_common_irc_deinit(void) fe_modes_deinit(); fe_netsplit_deinit(); fe_netjoin_deinit(); + irc_completion_deinit(); theme_unregister(); } diff --git a/src/fe-common/irc/irc-completion.c b/src/fe-common/irc/irc-completion.c new file mode 100644 index 00000000..1d3b9a75 --- /dev/null +++ b/src/fe-common/irc/irc-completion.c @@ -0,0 +1,41 @@ +/* + irc-completion.c : irssi + + Copyright (C) 1999-2000 Timo Sirainen + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "chat-completion.h" + +static void sig_complete_stats(GList **list, WINDOW_REC *window, + const char *word, const char *line, + int *want_space) +{ + *list = completion_get_servers(word); + if (*list != NULL) signal_stop(); +} + +void irc_completion_init(void) +{ + signal_add("complete command stats", (SIGNAL_FUNC) sig_complete_stats); +} + +void irc_completion_deinit(void) +{ + signal_remove("complete command stats", (SIGNAL_FUNC) sig_complete_stats); +} |