diff options
author | ache <ache@FreeBSD.org> | 2001-04-11 02:33:07 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-04-11 02:33:07 +0000 |
commit | e5103242d94d5211fa44bad651caaa7a61519867 (patch) | |
tree | 2a3a3b5b7ce03cb28810b3212cb44a3a1698ca44 /contrib/libreadline/isearch.c | |
parent | b85a0e54aedf144ea0dff369289bd3fb6f694f5f (diff) | |
download | FreeBSD-src-e5103242d94d5211fa44bad651caaa7a61519867.zip FreeBSD-src-e5103242d94d5211fa44bad651caaa7a61519867.tar.gz |
v4.2 initial import
Diffstat (limited to 'contrib/libreadline/isearch.c')
-rw-r--r-- | contrib/libreadline/isearch.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/contrib/libreadline/isearch.c b/contrib/libreadline/isearch.c index 952c10d..f8d7695 100644 --- a/contrib/libreadline/isearch.c +++ b/contrib/libreadline/isearch.c @@ -55,7 +55,7 @@ unsigned char *_rl_isearch_terminators = (unsigned char *)NULL; /* Variables imported from other files in the readline library. */ -extern HIST_ENTRY *saved_line_for_history; +extern HIST_ENTRY *_rl_saved_line_for_history; /* Forward declarations */ static int rl_search_history __P((int, int)); @@ -64,6 +64,8 @@ static int rl_search_history __P((int, int)); identical lines many times in a row. */ static char *prev_line_found; +static unsigned char *default_isearch_terminators = "\033\012"; + /* Search backwards through the history looking for a string which is typed interactively. Start with the current line. */ int @@ -176,6 +178,7 @@ rl_search_history (direction, invoking_key) been set, we use that value, otherwise we use ESC and C-J. */ unsigned char *isearch_terminators; + RL_SETSTATE(RL_STATE_ISEARCH); orig_point = rl_point; last_found_line = orig_line = where_history (); reverse = direction < 0; @@ -183,10 +186,10 @@ rl_search_history (direction, invoking_key) allocated_line = (char *)NULL; isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators - : (unsigned char *)"\033\012"; + : default_isearch_terminators; /* Create an arrary of pointers to the lines that we want to search. */ - maybe_replace_line (); + rl_maybe_replace_line (); i = 0; if (hlist) for (i = 0; hlist[i]; i++); @@ -197,8 +200,8 @@ rl_search_history (direction, invoking_key) for (i = 0; i < hlen; i++) lines[i] = hlist[i]->line; - if (saved_line_for_history) - lines[i] = saved_line_for_history->line; + if (_rl_saved_line_for_history) + lines[i] = _rl_saved_line_for_history->line; else { /* Keep track of this so we can free it. */ @@ -232,10 +235,12 @@ rl_search_history (direction, invoking_key) found = failed = 0; for (;;) { - Function *f = (Function *)NULL; + rl_command_func_t *f = (rl_command_func_t *)NULL; /* Read a key and decide how to proceed. */ + RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); if (_rl_keymap[c].type == ISFUNC) { @@ -273,6 +278,8 @@ rl_search_history (direction, invoking_key) if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G')) { + /* This sets rl_pending_input to c; it will be picked up the next + time rl_read_key is called. */ rl_execute_next (c); break; } @@ -287,7 +294,7 @@ rl_search_history (direction, invoking_key) else if (line_index != sline_len) ++line_index; else - ding (); + rl_ding (); break; /* switch directions */ @@ -305,13 +312,14 @@ rl_search_history (direction, invoking_key) if (allocated_line) free (allocated_line); free (lines); + RL_UNSETSTATE(RL_STATE_ISEARCH); return 0; #if 0 /* delete character from search string. */ case -3: if (search_string_index == 0) - ding (); + rl_ding (); else { search_string[--search_string_index] = '\0'; @@ -384,7 +392,7 @@ rl_search_history (direction, invoking_key) if (failed) { /* We cannot find the search string. Ding the bell. */ - ding (); + rl_ding (); i = last_found_line; continue; /* XXX - was break */ } @@ -438,5 +446,7 @@ rl_search_history (direction, invoking_key) free (allocated_line); free (lines); + RL_UNSETSTATE(RL_STATE_ISEARCH); + return 0; } |