diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-05-17 13:12:21 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-05-17 13:12:21 +0000 |
commit | 548e5115bb86dc858243114654afd3584f35c240 (patch) | |
tree | 1a79099e24471023993e533c5e89a1bc0c495df8 /src | |
parent | 4faa7439720a6eb96db53e7b7a2846c7f6b5dc5c (diff) | |
download | irssi-548e5115bb86dc858243114654afd3584f35c240.zip |
Add 'word_completion_backward' command to scroll backwards in the completion
list, bug #313.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4830 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-common/core/completion.c | 10 | ||||
-rw-r--r-- | src/fe-common/core/completion.h | 2 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 15 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index f0df4123..a5bf609b 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -128,7 +128,7 @@ static void free_completions(void) } /* manual word completion - called when TAB is pressed */ -char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase) +char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, int backward) { static int startpos = 0, wordlen = 0; int old_startpos, old_wordlen; @@ -205,8 +205,12 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase) if (continue_complete) { /* complete from old list */ - complist = complist->next != NULL ? complist->next : - g_list_first(complist); + if (backward) + complist = complist->prev != NULL ? complist->prev : + g_list_last(complist); + else + complist = complist->next != NULL ? complist->next : + g_list_first(complist); want_space = last_want_space; } else { /* get new completion list */ diff --git a/src/fe-common/core/completion.h b/src/fe-common/core/completion.h index 9a8b32cb..5c1e6958 100644 --- a/src/fe-common/core/completion.h +++ b/src/fe-common/core/completion.h @@ -8,7 +8,7 @@ char *auto_word_complete(const char *line, int *pos); /* manual word completion - called when TAB is pressed. if erase is TRUE, the word is removed from completion list entirely (if possible) and next completion is used */ -char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase); +char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, int backward); GList *filename_complete(const char *path, const char *default_path); diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 6cda7fbb..61663bad 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -756,13 +756,13 @@ static void key_change_window(const char *data) signal_emit("command window goto", 3, data, active_win->active_server, active_win->active); } -static void key_completion(int erase) +static void key_completion(int erase, int backward) { char *text, *line; int pos; text = gui_entry_get_text_and_pos(active_entry, &pos); - line = word_complete(active_win, text, &pos, erase); + line = word_complete(active_win, text, &pos, erase, backward); g_free(text); if (line != NULL) { @@ -772,14 +772,19 @@ static void key_completion(int erase) } } +static void key_word_completion_backward(void) +{ + key_completion(FALSE, TRUE); +} + static void key_word_completion(void) { - key_completion(FALSE); + key_completion(FALSE, FALSE); } static void key_erase_completion(void) { - key_completion(TRUE); + key_completion(TRUE, FALSE); } static void key_check_replaces(void) @@ -1110,6 +1115,7 @@ void gui_readline_init(void) /* line transmitting */ key_bind("send_line", "Execute the input line", "return", NULL, (SIGNAL_FUNC) key_send_line); + key_bind("word_completion_backward", "", NULL, NULL, (SIGNAL_FUNC) key_word_completion_backward); key_bind("word_completion", "", "tab", NULL, (SIGNAL_FUNC) key_word_completion); key_bind("erase_completion", "", "meta-k", NULL, (SIGNAL_FUNC) key_erase_completion); key_bind("check_replaces", "Check word replaces", NULL, NULL, (SIGNAL_FUNC) key_check_replaces); @@ -1196,6 +1202,7 @@ void gui_readline_deinit(void) key_unbind("upcase_word", (SIGNAL_FUNC) key_upcase_word); key_unbind("send_line", (SIGNAL_FUNC) key_send_line); + key_unbind("word_completion_backward", (SIGNAL_FUNC) key_word_completion_backward); key_unbind("word_completion", (SIGNAL_FUNC) key_word_completion); key_unbind("erase_completion", (SIGNAL_FUNC) key_erase_completion); key_unbind("check_replaces", (SIGNAL_FUNC) key_check_replaces); |