changeset 1190:be06bbe7e449

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
author Mikael Berthe <mikael@lilotux.net>
date Fri, 20 Apr 2007 19:06:24 +0200
parents a0722fce1786
children b2ed413d8f3d
files mcabber/doc/help/en/hlp_iline.txt mcabber/doc/help/fr/hlp_iline.txt mcabber/doc/help/ru/hlp_iline.txt mcabber/src/commands.c mcabber/src/screen.c mcabber/src/screen.h
diffstat 6 files changed, 49 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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
--- 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
--- 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")) {
--- 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;
--- 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);