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);
}
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;
}
int *lbreaks;
int lbsize;
#if defined (HANDLE_MULTIBYTE)
- int *wrapped_line;
int wbsize;
+ int *wrapped_line;
#endif
};
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 *));
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;
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
/* 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) &&
#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 */
int point;
int end;
int mark;
- char *buffer;
int buflen;
+ char *buffer;
UNDO_LIST *ul;
char *prompt;
int edmode;
char *kseq;
int kseqlen;
+
+ int pendingin;
FILE *inf;
FILE *outf;
- int pendingin;
char *macro;
/* signal state */
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;
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 *
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
#endif
if (c <= 0)
- return -1;
+ {
+ RL_UNSETSTATE (RL_STATE_CHARSEARCH);
+ return -1;
+ }
#if !defined (HANDLE_MULTIBYTE)
_rl_vi_last_search_char = c;
_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));
{
_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