From a9a0f4fd64eeb33ca51dc1d3e9f425a8b468eeca Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 17 Jun 2000 16:10:29 +0000 Subject: [PATCH] Added file name completion for commands /CAT, /RUN, /SAVE, /REHASH and /RAWLOG OPEN/SAVE. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@363 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/completion.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 77696826..010a2d4c 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -403,12 +403,35 @@ static void sig_complete_word(GList **list, WINDOW_REC *window, } } +/* first argument of command is file name - complete it */ +static void sig_complete_filename(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); + g_return_if_fail(line != NULL); + + if (*line != '\0') return; + + *list = filename_complete(word); + if (*list != NULL) { + *want_space = FALSE; + signal_stop(); + } +} + void completion_init(void) { complist = NULL; last_linestart = NULL; signal_add("complete word", (SIGNAL_FUNC) sig_complete_word); + signal_add("complete command cat", (SIGNAL_FUNC) sig_complete_filename); + signal_add("complete command run", (SIGNAL_FUNC) sig_complete_filename); + signal_add("complete command save", (SIGNAL_FUNC) sig_complete_filename); + signal_add("complete command rehash", (SIGNAL_FUNC) sig_complete_filename); + signal_add("complete command rawlog open", (SIGNAL_FUNC) sig_complete_filename); + signal_add("complete command rawlog save", (SIGNAL_FUNC) sig_complete_filename); } void completion_deinit(void) @@ -416,4 +439,10 @@ void completion_deinit(void) free_completions(); signal_remove("complete word", (SIGNAL_FUNC) sig_complete_word); + signal_remove("complete command cat", (SIGNAL_FUNC) sig_complete_filename); + signal_remove("complete command run", (SIGNAL_FUNC) sig_complete_filename); + signal_remove("complete command save", (SIGNAL_FUNC) sig_complete_filename); + signal_remove("complete command rehash", (SIGNAL_FUNC) sig_complete_filename); + signal_remove("complete command rawlog open", (SIGNAL_FUNC) sig_complete_filename); + signal_remove("complete command rawlog save", (SIGNAL_FUNC) sig_complete_filename); }