summaryrefslogtreecommitdiff
path: root/readline/isearch.c
diff options
context:
space:
mode:
authorJason Molenda <jsm@bugshack.cygnus.com>1999-08-02 23:48:37 +0000
committerJason Molenda <jsm@bugshack.cygnus.com>1999-08-02 23:48:37 +0000
commit6da787a878c938e680f13808dee254beacefbd43 (patch)
tree7c7b4d4f6655b210e33ca51f656f4552c9326ed3 /readline/isearch.c
parent1392c9fbbf6fe8811e5374356b7fdf3b389068ab (diff)
downloadgdb-6da787a878c938e680f13808dee254beacefbd43.tar.gz
import gdb-1999-08-02 snapshot
Diffstat (limited to 'readline/isearch.c')
-rw-r--r--readline/isearch.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/readline/isearch.c b/readline/isearch.c
index 7decf9595b0..67279e18924 100644
--- a/readline/isearch.c
+++ b/readline/isearch.c
@@ -48,6 +48,9 @@
#include "readline.h"
#include "history.h"
+/* Variables exported to other files in the readline library. */
+unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
+
/* Variables imported from other files in the readline library. */
extern Keymap _rl_keymap;
extern HIST_ENTRY *saved_line_for_history;
@@ -55,9 +58,6 @@ extern int rl_line_buffer_len;
extern int rl_point, rl_end;
extern char *rl_line_buffer;
-extern void _rl_save_prompt ();
-extern void _rl_restore_prompt ();
-
extern int rl_execute_next ();
extern void rl_extend_line_buffer ();
@@ -178,12 +178,20 @@ rl_search_history (direction, invoking_key)
/* Non-zero if we are doing a reverse search. */
int reverse;
+ /* The list of characters which terminate the search, but are not
+ subsequently executed. If the variable isearch-terminators has
+ been set, we use that value, otherwise we use ESC and C-J. */
+ unsigned char *isearch_terminators;
+
orig_point = rl_point;
last_found_line = orig_line = where_history ();
reverse = direction < 0;
hlist = history_list ();
allocated_line = (char *)NULL;
+ isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
+ : (unsigned char *)"\033\012";
+
/* Create an arrary of pointers to the lines that we want to search. */
maybe_replace_line ();
i = 0;
@@ -211,7 +219,7 @@ rl_search_history (direction, invoking_key)
/* The line where we start the search. */
i = orig_line;
- _rl_save_prompt ();
+ rl_save_prompt ();
/* Initialize search parameters. */
search_string = xmalloc (search_string_size = 128);
@@ -246,10 +254,18 @@ rl_search_history (direction, invoking_key)
c = !reverse ? -1 : -2;
}
+#if 0
/* Let NEWLINE (^J) terminate the search for people who don't like
using ESC. ^M can still be used to terminate the search and
immediately execute the command. */
if (c == ESC || c == NEWLINE)
+#else
+ /* The characters in isearch_terminators (set from the user-settable
+ variable isearch-terminators) are used to terminate the search but
+ not subsequently execute the character as a command. The default
+ value is "\033\012" (ESC and C-J). */
+ if (strchr (isearch_terminators, c))
+#endif
{
/* ESC still terminates the search, but if there is pending
input or if input arrives within 0.1 seconds (on systems
@@ -291,7 +307,7 @@ rl_search_history (direction, invoking_key)
strcpy (rl_line_buffer, lines[orig_line]);
rl_point = orig_point;
rl_end = strlen (rl_line_buffer);
- _rl_restore_prompt();
+ rl_restore_prompt();
rl_clear_message ();
if (allocated_line)
free (allocated_line);
@@ -409,15 +425,15 @@ rl_search_history (direction, invoking_key)
/* First put back the original state. */
strcpy (rl_line_buffer, lines[orig_line]);
- _rl_restore_prompt ();
+ rl_restore_prompt ();
/* Free the search string. */
free (search_string);
if (last_found_line < orig_line)
- rl_get_previous_history (orig_line - last_found_line);
+ rl_get_previous_history (orig_line - last_found_line, 0);
else
- rl_get_next_history (last_found_line - orig_line);
+ rl_get_next_history (last_found_line - orig_line, 0);
/* If the string was not found, put point at the end of the line. */
if (line_index < 0)