mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
More tab completion: /DISCONNECT, /SERVER ADD|REMOVE, /STATS
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2954 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
fa1687596c
commit
fb5c4c8037
@ -35,6 +35,7 @@
|
|||||||
#include "nicklist.h"
|
#include "nicklist.h"
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
#include "chat-completion.h"
|
||||||
#include "window-items.h"
|
#include "window-items.h"
|
||||||
|
|
||||||
static int keep_privates_count, keep_publics_count;
|
static int keep_privates_count, keep_publics_count;
|
||||||
@ -485,6 +486,32 @@ static GList *completion_joinlist(GList *list1, GList *list2)
|
|||||||
return list1;
|
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 *completion_get_channels(SERVER_REC *server, const char *word)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
@ -492,7 +519,6 @@ GList *completion_get_channels(SERVER_REC *server, const char *word)
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
g_return_val_if_fail(word != NULL, NULL);
|
g_return_val_if_fail(word != NULL, NULL);
|
||||||
g_return_val_if_fail(*word != '\0', NULL);
|
|
||||||
|
|
||||||
len = strlen(word);
|
len = strlen(word);
|
||||||
list = NULL;
|
list = NULL;
|
||||||
@ -772,6 +798,17 @@ static void sig_complete_connect(GList **list, WINDOW_REC *window,
|
|||||||
if (*list != NULL) signal_stop();
|
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,
|
static void sig_complete_topic(GList **list, WINDOW_REC *window,
|
||||||
const char *word, const char *line,
|
const char *word, const char *line,
|
||||||
int *want_space)
|
int *want_space)
|
||||||
@ -854,6 +891,17 @@ static void sig_complete_channel(GList **list, WINDOW_REC *window,
|
|||||||
if (*list != NULL) signal_stop();
|
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 \\ */
|
/* expand \n, \t and \\ */
|
||||||
static char *expand_escapes(const char *line, SERVER_REC *server,
|
static char *expand_escapes(const char *line, SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
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 erase command action", (SIGNAL_FUNC) sig_erase_complete_msg);
|
||||||
signal_add("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
|
signal_add("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
|
||||||
signal_add("complete command server", (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 topic", (SIGNAL_FUNC) sig_complete_topic);
|
||||||
signal_add("complete command away", (SIGNAL_FUNC) sig_complete_away);
|
signal_add("complete command away", (SIGNAL_FUNC) sig_complete_away);
|
||||||
signal_add("complete command unalias", (SIGNAL_FUNC) sig_complete_unalias);
|
signal_add("complete command unalias", (SIGNAL_FUNC) sig_complete_unalias);
|
||||||
signal_add("complete command alias", (SIGNAL_FUNC) sig_complete_alias);
|
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 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 public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_add("message join", (SIGNAL_FUNC) sig_message_join);
|
signal_add("message join", (SIGNAL_FUNC) sig_message_join);
|
||||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
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 erase command action", (SIGNAL_FUNC) sig_erase_complete_msg);
|
||||||
signal_remove("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
|
signal_remove("complete command connect", (SIGNAL_FUNC) sig_complete_connect);
|
||||||
signal_remove("complete command server", (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 topic", (SIGNAL_FUNC) sig_complete_topic);
|
||||||
signal_remove("complete command away", (SIGNAL_FUNC) sig_complete_away);
|
signal_remove("complete command away", (SIGNAL_FUNC) sig_complete_away);
|
||||||
signal_remove("complete command unalias", (SIGNAL_FUNC) sig_complete_unalias);
|
signal_remove("complete command unalias", (SIGNAL_FUNC) sig_complete_unalias);
|
||||||
signal_remove("complete command alias", (SIGNAL_FUNC) sig_complete_alias);
|
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 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 public", (SIGNAL_FUNC) sig_message_public);
|
||||||
signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
|
signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
|
||||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#ifndef __CHAT_COMPLETION_H
|
#ifndef __CHAT_COMPLETION_H
|
||||||
#define __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_add(const char *nick);
|
||||||
void completion_last_message_remove(const char *nick);
|
void completion_last_message_remove(const char *nick);
|
||||||
void completion_last_message_rename(const char *oldnick, const char *newnick);
|
void completion_last_message_rename(const char *oldnick, const char *newnick);
|
||||||
|
@ -25,6 +25,7 @@ real_sources = \
|
|||||||
fe-netjoin.c \
|
fe-netjoin.c \
|
||||||
fe-netsplit.c \
|
fe-netsplit.c \
|
||||||
fe-common-irc.c \
|
fe-common-irc.c \
|
||||||
|
irc-completion.c \
|
||||||
module-formats.c
|
module-formats.c
|
||||||
|
|
||||||
libfe_common_irc_a_SOURCES = \
|
libfe_common_irc_a_SOURCES = \
|
||||||
|
@ -68,6 +68,9 @@ void fe_netsplit_deinit(void);
|
|||||||
void fe_netjoin_init(void);
|
void fe_netjoin_init(void);
|
||||||
void fe_netjoin_deinit(void);
|
void fe_netjoin_deinit(void);
|
||||||
|
|
||||||
|
void irc_completion_init(void);
|
||||||
|
void irc_completion_deinit(void);
|
||||||
|
|
||||||
void fe_common_irc_init(void)
|
void fe_common_irc_init(void)
|
||||||
{
|
{
|
||||||
settings_add_bool("lookandfeel", "show_away_once", TRUE);
|
settings_add_bool("lookandfeel", "show_away_once", TRUE);
|
||||||
@ -86,6 +89,7 @@ void fe_common_irc_init(void)
|
|||||||
fe_modes_init();
|
fe_modes_init();
|
||||||
fe_netsplit_init();
|
fe_netsplit_init();
|
||||||
fe_netjoin_init();
|
fe_netjoin_init();
|
||||||
|
irc_completion_init();
|
||||||
|
|
||||||
settings_check();
|
settings_check();
|
||||||
module_register("core", "fe-irc");
|
module_register("core", "fe-irc");
|
||||||
@ -109,6 +113,7 @@ void fe_common_irc_deinit(void)
|
|||||||
fe_modes_deinit();
|
fe_modes_deinit();
|
||||||
fe_netsplit_deinit();
|
fe_netsplit_deinit();
|
||||||
fe_netjoin_deinit();
|
fe_netjoin_deinit();
|
||||||
|
irc_completion_deinit();
|
||||||
|
|
||||||
theme_unregister();
|
theme_unregister();
|
||||||
}
|
}
|
||||||
|
41
src/fe-common/irc/irc-completion.c
Normal file
41
src/fe-common/irc/irc-completion.c
Normal file
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user