summaryrefslogtreecommitdiff
path: root/readline/readline/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'readline/readline/readline.c')
-rw-r--r--readline/readline/readline.c98
1 files changed, 91 insertions, 7 deletions
diff --git a/readline/readline/readline.c b/readline/readline/readline.c
index 678f989c51a..e61d188bbe9 100644
--- a/readline/readline/readline.c
+++ b/readline/readline/readline.c
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
-/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2020 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.
@@ -73,11 +73,11 @@ extern int errno;
#include "xmalloc.h"
#ifndef RL_LIBRARY_VERSION
-# define RL_LIBRARY_VERSION "5.1"
+# define RL_LIBRARY_VERSION "8.0"
#endif
#ifndef RL_READLINE_VERSION
-# define RL_READLINE_VERSION 0x0501
+# define RL_READLINE_VERSION 0x0800
#endif
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
@@ -199,6 +199,10 @@ int rl_key_sequence_length = 0;
before readline_internal_setup () prints the first prompt. */
rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
+/* Any readline function can set this and have it run just before the user's
+ rl_startup_hook. */
+rl_hook_func_t *_rl_internal_startup_hook = (rl_hook_func_t *)NULL;
+
/* If non-zero, this is the address of a function to call just before
readline_internal_setup () returns and readline_internal starts
reading input characters. */
@@ -258,6 +262,9 @@ int rl_executing_key;
char *rl_executing_keyseq = 0;
int _rl_executing_keyseq_size = 0;
+struct _rl_cmd _rl_pending_command;
+struct _rl_cmd *_rl_command_to_execute = (struct _rl_cmd *)NULL;
+
/* Timeout (specified in milliseconds) when reading characters making up an
ambiguous multiple-key sequence */
int _rl_keyseq_timeout = 500;
@@ -314,7 +321,8 @@ int _rl_show_mode_in_prompt = 0;
/* Non-zero means to attempt to put the terminal in `bracketed paste mode',
where it will prefix pasted text with an escape sequence and send
another to mark the end of the paste. */
-int _rl_enable_bracketed_paste = 0;
+int _rl_enable_bracketed_paste = BRACKETED_PASTE_DEFAULT;
+int _rl_enable_active_region = BRACKETED_PASTE_DEFAULT;
/* **************************************************************** */
/* */
@@ -417,6 +425,11 @@ readline_internal_setup (void)
if (rl_startup_hook)
(*rl_startup_hook) ();
+ if (_rl_internal_startup_hook)
+ (*_rl_internal_startup_hook) ();
+
+ rl_deactivate_mark ();
+
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */
@@ -632,12 +645,34 @@ readline_internal_charloop (void)
r = _rl_dispatch ((unsigned char)c, _rl_keymap);
RL_CHECK_SIGNALS ();
+ if (_rl_command_to_execute)
+ {
+ (*rl_redisplay_function) ();
+
+ rl_executing_keymap = _rl_command_to_execute->map;
+ rl_executing_key = _rl_command_to_execute->key;
+
+ rl_dispatching = 1;
+ RL_SETSTATE(RL_STATE_DISPATCHING);
+ r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
+ _rl_command_to_execute = 0;
+ RL_UNSETSTATE(RL_STATE_DISPATCHING);
+ rl_dispatching = 0;
+
+ RL_CHECK_SIGNALS ();
+ }
+
/* If there was no change in _rl_last_command_was_kill, then no kill
has taken place. Note that if input is pending we are reading
a prefix command, so nothing has changed yet. */
if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
_rl_last_command_was_kill = 0;
+ if (_rl_keep_mark_active)
+ _rl_keep_mark_active = 0;
+ else if (rl_mark_active_p ())
+ rl_deactivate_mark ();
+
_rl_internal_char_cleanup ();
#if defined (READLINE_CALLBACKS)
@@ -856,7 +891,11 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
/* If we have input pending, then the last command was a prefix
command. Don't change the state of rl_last_func. Otherwise,
remember the last command executed in this variable. */
+#if defined (VI_MODE)
+ if (rl_pending_input == 0 && map[key].function != rl_digit_argument && map[key].function != rl_vi_arg_digit)
+#else
if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
+#endif
rl_last_func = map[key].function;
RL_CHECK_SIGNALS ();
@@ -870,6 +909,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
+ if (rl_key_sequence_length > 0)
+ rl_executing_keyseq[--rl_key_sequence_length] = '\0';
return -2;
}
else if (got_subseq)
@@ -882,6 +923,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
+ if (rl_key_sequence_length > 0)
+ rl_executing_keyseq[--rl_key_sequence_length] = '\0';
return -1;
}
else
@@ -974,7 +1017,11 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
_rl_pushed_input_available () == 0 &&
_rl_dispatching_keymap[ANYOTHERKEY].function &&
_rl_input_queued (_rl_keyseq_timeout*1000) == 0)
- return (_rl_subseq_result (-2, map, key, got_subseq));
+ {
+ if (rl_key_sequence_length > 0)
+ rl_executing_keyseq[--rl_key_sequence_length] = '\0';
+ return (_rl_subseq_result (-2, map, key, got_subseq));
+ }
newkey = _rl_subseq_getchar (key);
if (newkey < 0)
@@ -1065,6 +1112,8 @@ _rl_subseq_result (int r, Keymap map, int key, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
+ if (rl_key_sequence_length > 0)
+ rl_executing_keyseq[--rl_key_sequence_length] = '\0';
_rl_dispatching_keymap = map;
return -2;
}
@@ -1075,6 +1124,8 @@ _rl_subseq_result (int r, Keymap map, int key, int got_subseq)
_rl_prev_macro_key ();
else
_rl_unget_char (key);
+ if (rl_key_sequence_length > 0)
+ rl_executing_keyseq[--rl_key_sequence_length] = '\0';
_rl_dispatching_keymap = map;
return -1;
}
@@ -1241,7 +1292,7 @@ readline_initialize_everything (void)
rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
if (rl_executing_keyseq)
- rl_executing_keyseq[0] = '\0';
+ rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
}
/* If this system allows us to look at the values of the regular
@@ -1356,9 +1407,12 @@ bind_bracketed_paste_prefix (void)
_rl_keymap = emacs_standard_keymap;
rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
-
+
+#if defined (VI_MODE)
_rl_keymap = vi_insertion_keymap;
rl_bind_keyseq_if_unbound (BRACK_PASTE_PREF, rl_bracketed_paste_begin);
+ /* XXX - is there a reason to do this in the vi command keymap? */
+#endif
_rl_keymap = xkeymap;
}
@@ -1446,5 +1500,35 @@ rl_restore_state (struct readline_state *sp)
rl_attempted_completion_function = sp->attemptfunc;
rl_completer_word_break_characters = sp->wordbreakchars;
+ rl_deactivate_mark ();
+
return (0);
}
+
+/* Functions to manage the string that is the current key sequence. */
+
+void
+_rl_init_executing_keyseq (void)
+{
+ rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
+}
+
+void
+_rl_term_executing_keyseq (void)
+{
+ rl_executing_keyseq[rl_key_sequence_length] = '\0';
+}
+
+void
+_rl_end_executing_keyseq (void)
+{
+ if (rl_key_sequence_length > 0)
+ rl_executing_keyseq[--rl_key_sequence_length] = '\0';
+}
+
+void
+_rl_add_executing_keyseq (int key)
+{
+ RESIZE_KEYSEQ_BUFFER ();
+ rl_executing_keyseq[rl_key_sequence_length++] = key;
+}