]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
commit readline-20150731 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 3 Aug 2015 20:49:12 +0000 (16:49 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 3 Aug 2015 20:49:12 +0000 (16:49 -0400)
callback.c
display.c
history.h
readline.c
readline.h
rlprivate.h
vi_mode.c

index 0fc3f90bcd5f7ca2c65bb72b32bf54e12181e3b7..ec48b76de91322049b3b3bb4c5bc145c949b9b41 100644 (file)
@@ -161,6 +161,36 @@ rl_callback_read_char ()
          CALLBACK_READ_RETURN ();
        }
 #if defined (VI_MODE)
+      /* States that can occur while in state VIMOTION have to be checked
+        before RL_STATE_VIMOTION */
+      else if (RL_ISSTATE (RL_STATE_CHARSEARCH))
+       {
+         int k;
+
+         k = _rl_callback_data->i2;
+
+         eof = (*_rl_callback_func) (_rl_callback_data);
+         /* If the function `deregisters' itself, make sure the data is
+            cleaned up. */
+         if (_rl_callback_func == 0)   /* XXX - just sanity check */
+           {
+             if (_rl_callback_data)
+               {
+                 _rl_callback_data_dispose (_rl_callback_data);
+                 _rl_callback_data = 0;
+               }
+           }
+
+         /* Messy case where vi motion command can be char search */
+         if (RL_ISSTATE (RL_STATE_VIMOTION))
+           {
+             _rl_vi_domove_motion_cleanup (k, _rl_vimvcxt);
+             _rl_internal_char_cleanup ();
+             CALLBACK_READ_RETURN ();        
+           }
+
+         _rl_internal_char_cleanup ();
+       }
       else if (RL_ISSTATE (RL_STATE_VIMOTION))
        {
          eof = _rl_vi_domove_callback (_rl_vimvcxt);
@@ -311,6 +341,8 @@ rl_callback_sigcleanup ()
     }
   else if (RL_ISSTATE (RL_STATE_MULTIKEY))
     RL_UNSETSTATE (RL_STATE_MULTIKEY);
+  if (RL_ISSTATE (RL_STATE_CHARSEARCH))
+    RL_UNSETSTATE (RL_STATE_CHARSEARCH);
 
   _rl_callback_func = 0;
 }
index c6b14fb56051301787044ab4cf51245281285d67..4353d6e0543611a46c20afbea22f9913ee91d26c 100644 (file)
--- a/display.c
+++ b/display.c
@@ -83,8 +83,8 @@ struct line_state
     int *lbreaks;
     int lbsize;
 #if defined (HANDLE_MULTIBYTE)
-    int *wrapped_line;
     int wbsize;
+    int *wrapped_line;
 #endif
   };
 
index 779a573c956005b97440d50596a2887ddf6d0b4a..b79e51f4c20f8bdae45dc0a4b7cd0dee0a93fdd6 100644 (file)
--- a/history.h
+++ b/history.h
@@ -91,6 +91,13 @@ extern void add_history_time PARAMS((const char *));
    elements are numbered from 0. */
 extern HIST_ENTRY *remove_history PARAMS((int));
 
+/* Allocate a history entry consisting of STRING and TIMESTAMP and return
+   a pointer to it. */
+extern HIST_ENTRY *alloc_history_entry PARAMS((char *, char *));
+
+/* Copy the history entry H, but not the (opaque) data pointer */
+extern HIST_ENTRY *copy_history_entry PARAMS((HIST_ENTRY *));
+
 /* Free the history entry H and return any application-specific data
    associated with it. */
 extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
@@ -241,6 +248,7 @@ extern char **history_tokenize PARAMS((const char *));
 extern int history_base;
 extern int history_length;
 extern int history_max_entries;
+extern int history_offset;
 
 extern int history_lines_read_from_file;
 extern int history_lines_written_to_file;
index 0a54dc3cf67424809e043a9c1fea119afedec040..ce72501d4b43f79e4ab9cee4978cfd8edb218935 100644 (file)
@@ -916,8 +916,10 @@ _rl_dispatch_subseq (key, map, got_subseq)
             default) or a timeout determined by the value of `keyseq-timeout' */
          /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
             takes microseconds, so multiply by 1000 */
-         if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap
-             && _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
+         if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap &&
+             (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
+              _rl_pushed_input_available () == 0 &&
+             _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
            return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
 #endif
 
@@ -954,7 +956,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
          /* Tentative inter-character timeout for potential multi-key
             sequences?  If no input within timeout, abort sequence and
             act as if we got non-matching input. */
-         /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
+         /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued[B
             takes microseconds, so multiply by 1000 */
          if (_rl_keyseq_timeout > 0 &&
                (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
index e1773fa7e9d0cfaad0a7f1e41fb2f960c7bcd1be..8d71f9a7d0b27c818b0044d852fc0c2f68c8cb76 100644 (file)
@@ -870,7 +870,8 @@ extern int rl_inhibit_completion;
 #define RL_STATE_VIMOTION      0x0100000       /* reading vi motion arg */
 #define RL_STATE_MULTIKEY      0x0200000       /* reading multiple-key command */
 #define RL_STATE_VICMDONCE     0x0400000       /* entered vi command mode at least once */
-#define RL_STATE_REDISPLAYING  0x0800000       /* updating terminal display */
+#define RL_STATE_CHARSEARCH    0x0800000       /* vi mode char search */
+#define RL_STATE_REDISPLAYING  0x1000000       /* updating terminal display */
 
 #define RL_STATE_DONE          0x1000000       /* done; accepted line */
 
@@ -883,8 +884,8 @@ struct readline_state {
   int point;
   int end;
   int mark;
-  char *buffer;
   int buflen;
+  char *buffer;
   UNDO_LIST *ul;
   char *prompt;
 
@@ -899,9 +900,10 @@ struct readline_state {
   int edmode;
   char *kseq;
   int kseqlen;
+
+  int pendingin;
   FILE *inf;
   FILE *outf;
-  int pendingin;
   char *macro;
 
   /* signal state */
index 9b859f995cb7a8d08f2a69c4c5c4f07e7d1f1081..8064f9ffb702e76cec3d39b5b452abadd986de63 100644 (file)
@@ -125,10 +125,11 @@ typedef struct __rl_keyseq_context
   int flags;
   int subseq_arg;
   int subseq_retval;           /* XXX */
-  Keymap dmap;
+  int okey;
 
+  Keymap dmap;
   Keymap oldmap;
-  int okey;
+
   struct __rl_keyseq_context *ocxt;
   int childval;
 } _rl_keyseq_cxt;
@@ -427,6 +428,7 @@ extern int _rl_vi_textmod_command PARAMS((int));
 extern int _rl_vi_motion_command PARAMS((int));
 extern void _rl_vi_done_inserting PARAMS((void));
 extern int _rl_vi_domove_callback PARAMS((_rl_vimotion_cxt *));
+extern int _rl_vi_domove_motion_cleanup PARAMS((int, _rl_vimotion_cxt *));
 
 /*************************************************************************
  * Undocumented private variables                                       *
index cae80cac8c407191b3382b4e8065987bfa581b3a..dcde2fbd01fda10a4e666d790221ec2a3fa5a348 100644 (file)
--- a/vi_mode.c
+++ b/vi_mode.c
@@ -1096,28 +1096,55 @@ static int
 rl_domove_motion_callback (m)
      _rl_vimotion_cxt *m;
 {
-  int c, save, r;
-  int old_end;
+  int c;
 
   _rl_vi_last_motion = c = m->motion;
 
   /* Append a blank character temporarily so that the motion routines
-     work right at the end of the line. */
-  old_end = rl_end;
+     work right at the end of the line.  Original value of rl_end is saved
+     as m->end. */
   rl_line_buffer[rl_end++] = ' ';
   rl_line_buffer[rl_end] = '\0';
 
   _rl_dispatch (c, _rl_keymap);
 
-  /* Remove the blank that we added. */
-  rl_end = old_end;
+#if defined (READLINE_CALLBACKS)
+  if (RL_ISSTATE (RL_STATE_CALLBACK))
+    {
+      /* Messy case where char search can be vi motion command; see rest of
+        details in callback.c.  vi_char_search and callback_char_search just
+        set and unset the CHARSEARCH state.  This is where any vi motion
+        command that needs to set its own state should be handled, with any
+        corresponding code to manage that state in callback.c */
+      if (RL_ISSTATE (RL_STATE_CHARSEARCH))
+       return 0;
+      else
+       return (_rl_vi_domove_motion_cleanup (c, m));
+    }
+#endif
+
+  return (_rl_vi_domove_motion_cleanup (c, m));
+}
+
+int
+_rl_vi_domove_motion_cleanup (c, m)
+     int c;
+     _rl_vimotion_cxt *m;
+{
+  int r;
+
+  /* Remove the blank that we added in rl_domove_motion_callback. */
+  rl_end = m->end;
   rl_line_buffer[rl_end] = '\0';
   if (rl_point > rl_end)
     rl_point = rl_end;
 
   /* No change in position means the command failed. */
   if (rl_mark == rl_point)
-    return (-1);
+    {
+      RL_UNSETSTATE (RL_STATE_VIMOTION);
+      return (-1);
+    }
 
   /* rl_vi_f[wW]ord () leaves the cursor on the first character of the next
      word.  If we are not at the end of the line, and we are on a
@@ -1625,7 +1652,10 @@ _rl_vi_callback_char_search (data)
 #endif
 
   if (c <= 0)
-    return -1;
+    {
+      RL_UNSETSTATE (RL_STATE_CHARSEARCH);
+      return -1;
+    }
 
 #if !defined (HANDLE_MULTIBYTE)
   _rl_vi_last_search_char = c;
@@ -1633,6 +1663,7 @@ _rl_vi_callback_char_search (data)
 
   _rl_callback_func = 0;
   _rl_want_redisplay = 1;
+  RL_UNSETSTATE (RL_STATE_CHARSEARCH);
 
 #if defined (HANDLE_MULTIBYTE)
   return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_mbchar, _rl_vi_last_search_mblen));
@@ -1697,7 +1728,9 @@ rl_vi_char_search (count, key)
        {
          _rl_callback_data = _rl_callback_data_alloc (count);
          _rl_callback_data->i1 = _rl_cs_dir;
+         _rl_callback_data->i2 = key;
          _rl_callback_func = _rl_vi_callback_char_search;
+         RL_SETSTATE (RL_STATE_CHARSEARCH);
          return (0);
        }
 #endif