]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - lib/readline/bind.c
bash-4.3-beta overlay
[thirdparty/bash.git] / lib / readline / bind.c
index 787104613e2eaaa7d3de1ad34fad42d725f820d7..8acf4ac4ca0468e1ed2e53d8e7287e84f22730e1 100644 (file)
@@ -1,6 +1,6 @@
 /* bind.c -- key binding and startup file support for the readline library. */
 
-/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -571,6 +571,40 @@ rl_translate_keyseq (seq, array, len)
   return (0);
 }
 
+static int
+_rl_isescape (c)
+     int c;
+{
+  switch (c)
+    {
+    case '\007':
+    case '\b':
+    case '\f':
+    case '\n':
+    case '\r':
+    case TAB:
+    case 0x0b:  return (1);
+    default: return (0);
+    }
+}
+
+static int
+_rl_escchar (c)
+     int c;
+{
+  switch (c)
+    {
+    case '\007':  return ('a');
+    case '\b':  return ('b');
+    case '\f':  return ('f');
+    case '\n':  return ('n');
+    case '\r':  return ('r');
+    case TAB:  return ('t');
+    case 0x0b:  return ('v');
+    default: return (c);
+    }
+}
+
 char *
 rl_untranslate_keyseq (seq)
      int seq;
@@ -622,9 +656,10 @@ rl_untranslate_keyseq (seq)
   return kseq;
 }
 
-static char *
-_rl_untranslate_macro_value (seq)
+char *
+_rl_untranslate_macro_value (seq, use_escapes)
      char *seq;
+     int use_escapes;
 {
   char *ret, *r, *s;
   int c;
@@ -648,9 +683,14 @@ _rl_untranslate_macro_value (seq)
       else if (CTRL_CHAR (c))
        {
          *r++ = '\\';
-         *r++ = 'C';
-         *r++ = '-';
-         c = _rl_to_lower (UNCTRL (c));
+         if (use_escapes && _rl_isescape (c))
+           c = _rl_escchar (c);
+         else
+           {
+             *r++ = 'C';
+             *r++ = '-';
+             c = _rl_to_lower (UNCTRL (c));
+           }
        }
       else if (c == RUBOUT)
        {
@@ -1290,6 +1330,7 @@ remove_trailing:
            {
              i = _rl_skip_to_delim (value, 1, *value);
              value[i] = '\0';
+             value++;  /* skip past the quote */
            }
          else
            goto remove_trailing;
@@ -1437,6 +1478,9 @@ static const struct {
   { "bind-tty-special-chars",  &_rl_bind_stty_chars,           0 },
   { "blink-matching-paren",    &rl_blink_matching_paren,       V_SPECIAL },
   { "byte-oriented",           &rl_byte_oriented,              0 },
+#if defined (COLOR_SUPPORT)
+  { "colored-stats",           &_rl_colored_stats,             0 },
+#endif
   { "completion-ignore-case",  &_rl_completion_case_fold,      0 },
   { "completion-map-case",     &_rl_completion_case_map,       0 },
   { "convert-meta",            &_rl_convert_meta_chars_to_ascii, 0 },
@@ -1461,6 +1505,7 @@ static const struct {
   { "revert-all-at-newline",   &_rl_revert_all_at_newline,     0 },
   { "show-all-if-ambiguous",   &_rl_complete_show_all,         0 },
   { "show-all-if-unmodified",  &_rl_complete_show_unmodified,  0 },
+  { "show-mode-in-prompt",     &_rl_show_mode_in_prompt,       0 },
   { "skip-completed-text",     &_rl_skip_completed_text,       0 },
 #if defined (VISIBLE_STATS)
   { "visible-stats",           &rl_visible_stats,              0 },
@@ -1500,6 +1545,8 @@ hack_special_boolean_var (i)
       else
        _rl_bell_preference = AUDIBLE_BELL;
     }
+  else if (_rl_stricmp (name, "show-mode-in-prompt") == 0)
+    _rl_reset_prompt ();
 }
 
 typedef int _rl_sv_func_t PARAMS((const char *));
@@ -1525,6 +1572,7 @@ static int sv_editmode PARAMS((const char *));
 static int sv_histsize PARAMS((const char *));
 static int sv_isrchterm PARAMS((const char *));
 static int sv_keymap PARAMS((const char *));
+static int sv_seqtimeout PARAMS((const char *));
 
 static const struct {
   const char * const name;
@@ -1540,6 +1588,7 @@ static const struct {
   { "history-size",    V_INT,          sv_histsize },
   { "isearch-terminators", V_STRING,   sv_isrchterm },
   { "keymap",          V_STRING,       sv_keymap },
+  { "keyseq-timeout",  V_INT,          sv_seqtimeout },
   { (char *)NULL,      0, (_rl_sv_func_t *)0 }
 };
 
@@ -1697,13 +1746,17 @@ static int
 sv_histsize (value)
      const char *value;
 {
-  int nval = 500;
+  int nval;
 
+  nval = 500;
   if (value && *value)
     {
       nval = atoi (value);
       if (nval < 0)
-       return 1;
+       {
+         unstifle_history ();
+         return 0;
+       }
     }
   stifle_history (nval);
   return 0;
@@ -1724,6 +1777,23 @@ sv_keymap (value)
   return 1;
 }
 
+static int
+sv_seqtimeout (value)
+     const char *value;
+{
+  int nval;
+
+  nval = 0;
+  if (value && *value)
+    {
+      nval = atoi (value);
+      if (nval < 0)
+       nval = 0;
+    }
+  _rl_keyseq_timeout = nval;
+  return 0;
+}
+
 static int
 sv_bell_style (value)
      const char *value;
@@ -2215,7 +2285,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
        {
        case ISMACR:
          keyname = _rl_get_keyname (key);
-         out = _rl_untranslate_macro_value ((char *)map[key].function);
+         out = _rl_untranslate_macro_value ((char *)map[key].function, 0);
 
          if (print_readably)
            fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
@@ -2327,7 +2397,7 @@ _rl_get_string_variable_value (name)
     {
       if (_rl_isearch_terminators == 0)
        return 0;
-      ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
+      ret = _rl_untranslate_macro_value (_rl_isearch_terminators, 0);
       if (ret)
        {
          strncpy (numbuf, ret, sizeof (numbuf) - 1);
@@ -2345,6 +2415,11 @@ _rl_get_string_variable_value (name)
        ret = rl_get_keymap_name_from_edit_mode ();
       return (ret ? ret : "none");
     }
+  else if (_rl_stricmp (name, "keyseq-timeout") == 0)
+    {
+      sprintf (numbuf, "%d", _rl_keyseq_timeout);    
+      return (numbuf);
+    }
   else
     return (0);
 }