| diff --git a/lib/readline/bind.c b/lib/readline/bind.c |
| |
| |
| @@ -1428,6 +1428,7 @@ static const struct { |
| { "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 }, |
| { "disable-completion", &rl_inhibit_completion, 0 }, |
| { "echo-control-characters", &_rl_echo_control_chars, 0 }, |
| + { "enable-bracketed-paste", &_rl_enable_bracketed_paste, 0 }, |
| { "enable-keypad", &_rl_enable_keypad, 0 }, |
| { "enable-meta-key", &_rl_enable_meta, 0 }, |
| { "expand-tilde", &rl_complete_with_tilde_expansion, 0 }, |
| diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c |
| |
| |
| @@ -68,6 +68,7 @@ static const FUNMAP default_funmap[] = { |
| { "backward-word", rl_backward_word }, |
| { "beginning-of-history", rl_beginning_of_history }, |
| { "beginning-of-line", rl_beg_of_line }, |
| + { "bracketed-paste-begin", rl_bracketed_paste_begin }, |
| { "call-last-kbd-macro", rl_call_last_kbd_macro }, |
| { "capitalize-word", rl_capitalize_word }, |
| { "character-search", rl_char_search }, |
| diff --git a/lib/readline/kill.c b/lib/readline/kill.c |
| |
| |
| @@ -656,6 +656,55 @@ rl_yank_last_arg (count, key) |
| return retval; |
| } |
| |
| +/* Having read the special escape sequence denoting the beginning of a |
| + `bracketed paste' sequence, read the rest of the pasted input until the |
| + closing sequence and insert the pasted text as a single unit without |
| + interpretation. */ |
| +int |
| +rl_bracketed_paste_begin (int count, int key) |
| +{ |
| + int retval, c; |
| + size_t len, cap; |
| + char *buf; |
| + |
| + retval = 1; |
| + len = 0; |
| + buf = xmalloc (cap = 64); |
| + |
| + RL_SETSTATE (RL_STATE_MOREINPUT); |
| + while ((c = rl_read_key ()) >= 0) |
| + { |
| + if (RL_ISSTATE (RL_STATE_MACRODEF)) |
| + _rl_add_macro_char (c); |
| + |
| + if (c == '\r') /* XXX */ |
| + c = '\n'; |
| + |
| + if (len == cap) |
| + buf = xrealloc (buf, cap *= 2); |
| + |
| + buf[len++] = c; |
| + if (len >= BRACK_PASTE_SLEN && c == BRACK_PASTE_LAST && |
| + STREQN (buf + len - BRACK_PASTE_SLEN, BRACK_PASTE_SUFF, BRACK_PASTE_SLEN)) |
| + { |
| + len -= BRACK_PASTE_SLEN; |
| + break; |
| + } |
| + } |
| + RL_UNSETSTATE (RL_STATE_MOREINPUT); |
| + |
| + if (c >= 0) |
| + { |
| + if (len == cap) |
| + buf = xrealloc (buf, cap + 1); |
| + buf[len] = '\0'; |
| + retval = rl_insert_text (buf); |
| + } |
| + |
| + xfree (buf); |
| + return (retval); |
| +} |
| + |
| /* A special paste command for users of Cygnus's cygwin32. */ |
| #if defined (__CYGWIN__) |
| #include <windows.h> |
| diff --git a/lib/readline/readline.c b/lib/readline/readline.c |
| |
| |
| @@ -95,6 +95,8 @@ static void readline_initialize_everything PARAMS((void)); |
| static void bind_arrow_keys_internal PARAMS((Keymap)); |
| static void bind_arrow_keys PARAMS((void)); |
| |
| +static void bind_bracketed_paste_prefix PARAMS((void)); |
| + |
| static void readline_default_bindings PARAMS((void)); |
| static void reset_default_bindings PARAMS((void)); |
| |
| @@ -285,6 +287,11 @@ int _rl_revert_all_at_newline = 0; |
| characters corresponding to keyboard-generated signals. */ |
| int _rl_echo_control_chars = 1; |
| |
| +/* 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; |
| + |
| /* |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |