# HG changeset patch # User Mikael Berthe # Date 1177088784 -7200 # Node ID be06bbe7e44902826e864d23d5c1cb3a48f374b7 # Parent a0722fce1786a6f1f6e007949828a9f02df2c298 Add readline_hist_beginning_search_bwd/fwd functions These function match the actual behaviour of Up/Down in mcabber. /iline hist_prev|hist_next now have a more traditional behaviour diff -r a0722fce1786 -r be06bbe7e449 mcabber/doc/help/en/hlp_iline.txt --- a/mcabber/doc/help/en/hlp_iline.txt Fri Apr 20 18:22:54 2007 +0200 +++ b/mcabber/doc/help/en/hlp_iline.txt Fri Apr 20 19:06:24 2007 +0200 @@ -2,6 +2,7 @@ /ILINE fchar|bchar|char_fdel|char_bdel|char_swap /ILINE fword|bword|word_bdel|word_fdel /ILINE word_upcase|word_downcase|word_capit + /ILINE hist_beginning_search_bwd|hist_beginning_search_fwd /ILINE hist_prev|hist_next /ILINE iline_start|iline_end|iline_fdel|iline_bdel /ILINE iline_accept|iline_accept_down_hist @@ -34,6 +35,10 @@ Convert the word from cursor position to its end to down case /iline word_capit Capitalize the word from cursor position to its end +/iline hist_beginning_search_bwd + Search backward in the history for a line beginning with the current line up to the cursor (this leaves the cursor in its original position) +/iline hist_beginning_search_fwd + Search forward in the history for a line beginning with the current line up to the cursor (this leaves the cursor in its original position) /iline hist_prev Previous line of input line history /iline hist_next diff -r a0722fce1786 -r be06bbe7e449 mcabber/doc/help/fr/hlp_iline.txt --- a/mcabber/doc/help/fr/hlp_iline.txt Fri Apr 20 18:22:54 2007 +0200 +++ b/mcabber/doc/help/fr/hlp_iline.txt Fri Apr 20 19:06:24 2007 +0200 @@ -2,6 +2,7 @@ /ILINE fchar|bchar|char_fdel|char_bdel|char_swap /ILINE fword|bword|word_bdel|word_fdel /ILINE word_upcase|word_downcase|word_capit + /ILINE hist_beginning_search_bwd|hist_beginning_search_fwd /ILINE hist_prev|hist_next /ILINE iline_start|iline_end|iline_fdel|iline_bdel /ILINE iline_accept|iline_accept_down_hist @@ -34,6 +35,10 @@ Convertir la fin du mot en minuscules depuis le curseur /iline word_capit Mettre une lettre capitale sous le curseur (ou au prochain mot) et aller à la fin du mot +/iline hist_beginning_search_bwd + Chercher la ligne précédente de l'historique ligne de commande commençant comme la ligne actuelle jusqu'au curseur (le curseur est laissé à la même position) +/iline hist_beginning_search_fwd + Chercher la ligne suivante de l'historique ligne de commande commençant comme la ligne actuelle jusqu'au curseur (le curseur est laissé à la même position) /iline hist_prev Charger la ligne précédente de l'historique ligne de commande /iline hist_next diff -r a0722fce1786 -r be06bbe7e449 mcabber/doc/help/ru/hlp_iline.txt --- a/mcabber/doc/help/ru/hlp_iline.txt Fri Apr 20 18:22:54 2007 +0200 +++ b/mcabber/doc/help/ru/hlp_iline.txt Fri Apr 20 19:06:24 2007 +0200 @@ -2,6 +2,7 @@ /ILINE fchar|bchar|char_fdel|char_bdel|char_swap /ILINE fword|bword|word_bdel|word_fdel /ILINE word_upcase|word_downcase|word_capit + /ILINE hist_beginning_search_bwd|hist_beginning_search_fwd /ILINE hist_prev|hist_next /ILINE iline_start|iline_end|iline_fdel|iline_bdel /ILINE iline_accept|iline_accept_down_hist @@ -34,6 +35,8 @@ Перевести слово в нижний регистр с позиции курсора /iline word_capit Сделать букву на позиции курсора заглавной, остальные до конца слова - строчными +/iline hist_beginning_search_bwd +/iline hist_beginning_search_fwd /iline hist_prev Предыдущая строка истории строки ввода /iline hist_next diff -r a0722fce1786 -r be06bbe7e449 mcabber/src/commands.c --- a/mcabber/src/commands.c Fri Apr 20 18:22:54 2007 +0200 +++ b/mcabber/src/commands.c Fri Apr 20 19:06:24 2007 +0200 @@ -2762,6 +2762,10 @@ readline_backward_kill_char(); } else if (!strcasecmp(arg, "char_swap")) { readline_transpose_chars(); + } else if (!strcasecmp(arg, "hist_beginning_search_bwd")) { + readline_hist_beginning_search_bwd(); + } else if (!strcasecmp(arg, "hist_beginning_search_fwd")) { + readline_hist_beginning_search_fwd(); } else if (!strcasecmp(arg, "hist_prev")) { readline_hist_prev(); } else if (!strcasecmp(arg, "hist_next")) { diff -r a0722fce1786 -r be06bbe7e449 mcabber/src/screen.c --- a/mcabber/src/screen.c Fri Apr 20 18:22:54 2007 +0200 +++ b/mcabber/src/screen.c Fri Apr 20 19:06:24 2007 +0200 @@ -344,9 +344,11 @@ settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline fchar"); settings_set(SETTINGS_TYPE_BINDING, "7", "iline compl_cancel"); // Ctrl-g g_string_printf(sbuf, "%d", KEY_UP); - settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline hist_prev"); + settings_set(SETTINGS_TYPE_BINDING, sbuf->str, + "iline hist_beginning_search_bwd"); g_string_printf(sbuf, "%d", KEY_DOWN); - settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "iline hist_next"); + settings_set(SETTINGS_TYPE_BINDING, sbuf->str, + "iline hist_beginning_search_fwd"); g_string_printf(sbuf, "%d", KEY_PPAGE); settings_set(SETTINGS_TYPE_BINDING, sbuf->str, "roster up"); g_string_printf(sbuf, "%d", KEY_NPAGE); @@ -2568,18 +2570,42 @@ update_panels(); } -void readline_hist_prev(void) +void readline_hist_beginning_search_bwd(void) { const char *l = scr_cmdhisto_prev(inputLine, ptr_inputline-inputLine); if (l) strcpy(inputLine, l); } -void readline_hist_next(void) +void readline_hist_beginning_search_fwd(void) { const char *l = scr_cmdhisto_next(inputLine, ptr_inputline-inputLine); if (l) strcpy(inputLine, l); } +void readline_hist_prev(void) +{ + const char *l = scr_cmdhisto_prev(inputLine, 0); + if (l) { + strcpy(inputLine, l); + // Set the pointer at the EOL. + // We have to move it to BOL first, because we could be too far already. + readline_iline_start(); + readline_iline_end(); + } +} + +void readline_hist_next(void) +{ + const char *l = scr_cmdhisto_next(inputLine, 0); + if (l) { + strcpy(inputLine, l); + // Set the pointer at the EOL. + // We have to move it to BOL first, because we could be too far already. + readline_iline_start(); + readline_iline_end(); + } +} + void readline_backward_kill_char(void) { char *src, *c; diff -r a0722fce1786 -r be06bbe7e449 mcabber/src/screen.h --- a/mcabber/src/screen.h Fri Apr 20 18:22:54 2007 +0200 +++ b/mcabber/src/screen.h Fri Apr 20 19:06:24 2007 +0200 @@ -149,6 +149,8 @@ void readline_do_completion(void); void readline_refresh_screen(void); void readline_disable_chat_mode(void); +void readline_hist_beginning_search_bwd(void); +void readline_hist_beginning_search_fwd(void); void readline_hist_prev(void); void readline_hist_next(void); void readline_backward_kill_char(void);