diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-completion.c | 10 | ||||
-rw-r--r-- | src/gui/gui-completion.h | 6 | ||||
-rw-r--r-- | src/gui/gui-input.c | 38 |
3 files changed, 31 insertions, 23 deletions
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index c36ab940a..599205365 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -1370,15 +1370,15 @@ gui_completion_auto (struct t_gui_completion *completion) * Completes word according to context. */ -void +int gui_completion_search (struct t_gui_completion *completion, const char *data, int position, int direction) { char *old_word_found; int real_position; - if (!data) - return; + if (!completion || !data || (position < 0)) + return 0; real_position = utf8_real_pos (data, position); @@ -1404,7 +1404,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, /* should never be executed */ if (old_word_found) free (old_word_found); - return; + return 0; case GUI_COMPLETION_COMMAND: gui_completion_command (completion); break; @@ -1440,6 +1440,8 @@ gui_completion_search (struct t_gui_completion *completion, const char *data, } if (old_word_found) free (old_word_found); + + return 1; } /* diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h index 8056d1bf8..193cbff5e 100644 --- a/src/gui/gui-completion.h +++ b/src/gui/gui-completion.h @@ -88,9 +88,9 @@ extern void gui_completion_stop (struct t_gui_completion *completion); extern void gui_completion_list_add (struct t_gui_completion *completion, const char *word, int nick_completion, const char *where); -extern void gui_completion_search (struct t_gui_completion *completion, - const char *data, int position, - int direction); +extern int gui_completion_search (struct t_gui_completion *completion, + const char *data, int position, + int direction); extern const char *gui_completion_get_string (struct t_gui_completion *completion, const char *property); extern struct t_hdata *gui_completion_hdata_completion_cb (const void *pointer, diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index cab58f6f7..1614266ad 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -532,14 +532,17 @@ gui_input_complete_next (struct t_gui_buffer *buffer) && (buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) { gui_buffer_undo_snap (buffer); - gui_completion_search (buffer->completion, - buffer->input_buffer, - buffer->input_buffer_pos, - 1); - gui_input_complete (buffer); - gui_input_text_changed_modifier_and_signal (buffer, - 1, /* save undo */ - 0); /* stop completion */ + if (gui_completion_search (buffer->completion, + buffer->input_buffer, + buffer->input_buffer_pos, + 1)) + { + gui_input_complete (buffer); + gui_input_text_changed_modifier_and_signal ( + buffer, + 1, /* save undo */ + 0); /* stop completion */ + } } } @@ -554,14 +557,17 @@ gui_input_complete_previous (struct t_gui_buffer *buffer) && (buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) { gui_buffer_undo_snap (buffer); - gui_completion_search (buffer->completion, - buffer->input_buffer, - buffer->input_buffer_pos, - -1); - gui_input_complete (buffer); - gui_input_text_changed_modifier_and_signal (buffer, - 1, /* save undo */ - 0); /* stop completion */ + if (gui_completion_search (buffer->completion, + buffer->input_buffer, + buffer->input_buffer_pos, + -1)) + { + gui_input_complete (buffer); + gui_input_text_changed_modifier_and_signal ( + buffer, + 1, /* save undo */ + 0); /* stop completion */ + } } } |