From 4764b102ff274f4a8695ced2ff2ebb39bf8d7bc2 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 9 Sep 2015 22:35:11 +0200 Subject: [PATCH] Enable the bracketed paste mode on demand --- src/fe-text/gui-readline.c | 3 +++ src/fe-text/term-terminfo.c | 8 ++++++++ src/fe-text/term.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index c4c0064e..91dec4ea 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -969,6 +969,9 @@ static void setup_changed(void) paste_verify_line_count = settings_get_int("paste_verify_line_count"); paste_join_multiline = settings_get_bool("paste_join_multiline"); paste_use_bracketed_mode = settings_get_bool("paste_use_bracketed_mode"); + + /* Enable the bracketed paste mode on demand */ + term_set_bracketed_paste_mode(paste_use_bracketed_mode); } void gui_readline_init(void) diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index ded79c28..9376bda8 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -689,3 +689,11 @@ void term_gets(GArray *buffer, int *line_count) } } } + +void term_set_bracketed_paste_mode(int enable) +{ + if (enable) + tputs("\e[?2004h", 0, term_putchar); + else + tputs("\e[?2004l", 0, term_putchar); +} diff --git a/src/fe-text/term.h b/src/fe-text/term.h index cdcc787a..692ce9c5 100644 --- a/src/fe-text/term.h +++ b/src/fe-text/term.h @@ -94,6 +94,8 @@ void term_refresh(TERM_WINDOW *window); void term_stop(void); +void term_set_bracketed_paste_mode(int enable); + /* keyboard input handling */ void term_set_input_type(int type); void term_gets(GArray *buffer, int *line_count);