Mercurial > ~mikael > mcabber > hg
diff mcabber/mcabber/screen.c @ 2143:2f294c2b6778
Add a backward completion (Oleg)
When we skip some needed item with tab, we can back with shift+tab.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 06 Jul 2014 14:51:17 +0200 |
parents | 54548cf8f646 |
children | 1b3add57c912 |
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c Sun Jul 06 14:51:14 2014 +0200 +++ b/mcabber/mcabber/screen.c Sun Jul 06 14:51:17 2014 +0200 @@ -84,7 +84,7 @@ static void scr_cancel_current_completion(void); static void scr_end_current_completion(void); static void scr_insert_text(const char*); -static void scr_handle_tab(void); +static void scr_handle_tab(gboolean fwd); #if defined XEP0022 || defined XEP0085 static gboolean scr_chatstates_timeout(); @@ -3673,13 +3673,13 @@ check_offset(-1); } -void readline_do_completion(void) +void readline_do_completion(gboolean fwd) { int i, n; if (multimode != 2) { // Not in verbatim multi-line mode - scr_handle_tab(); + scr_handle_tab(fwd); } else { // Verbatim multi-line mode: expand tab char tabstr[9]; @@ -3888,7 +3888,8 @@ // scr_handle_tab() // Function called when tab is pressed. // Initiate or continue a completion... -static void scr_handle_tab(void) +// If fwd is false, a backward-completion is requested. +static void scr_handle_tab(gboolean fwd) { int nrow; const char *row; @@ -3973,7 +3974,7 @@ g_slist_free(list); } // Now complete - cchar = complete(); + cchar = complete(fwd); if (cchar) scr_insert_text(cchar); completion_started = TRUE; @@ -3981,7 +3982,7 @@ } else { // Completion already initialized scr_cancel_current_completion(); // Now complete again - cchar = complete(); + cchar = complete(fwd); if (cchar) scr_insert_text(cchar); } @@ -4362,7 +4363,10 @@ case ERR: break; case 9: // Tab - readline_do_completion(); + readline_do_completion(TRUE); // Forward-completion + break; + case 353: // Shift-Tab + readline_do_completion(FALSE); // Backward-completion break; case 13: // Enter case 343: // Enter on Maemo @@ -4423,7 +4427,7 @@ } } - if (completion_started && key != 9 && key != KEY_RESIZE) + if (completion_started && key != 9 && key != 353 && key != KEY_RESIZE) scr_end_current_completion(); refresh_inputline();