mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
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
This commit is contained in:
parent
4faa743972
commit
548e5115bb
@ -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 */
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user