mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 06:38:37 -05:00
Patch from Matsui Nag to implement xterm's "bracketed paste mode", in
which text pasted into the terminal is preceded and followed by special function-key-like escape sequences ESC[200~ and ESC[201~ so that the application can identify it and treat it specially (e.g. disabling auto-indent-same-as-previous-line in text editors). Enabled and disabled by ESC[?2004h and ESC[?2004l, and of course off by default. [originally from svn r9412]
This commit is contained in:
parent
053d2ba6d1
commit
21b04f5e00
17
terminal.c
17
terminal.c
@ -1225,6 +1225,7 @@ static void power_on(Terminal *term, int clear)
|
|||||||
term_print_finish(term);
|
term_print_finish(term);
|
||||||
term->xterm_mouse = 0;
|
term->xterm_mouse = 0;
|
||||||
set_raw_mouse_mode(term->frontend, FALSE);
|
set_raw_mouse_mode(term->frontend, FALSE);
|
||||||
|
term->bracketed_paste = FALSE;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
@ -2503,6 +2504,9 @@ static void toggle_mode(Terminal *term, int mode, int query, int state)
|
|||||||
save_cursor(term, state);
|
save_cursor(term, state);
|
||||||
term->disptop = 0;
|
term->disptop = 0;
|
||||||
break;
|
break;
|
||||||
|
case 2004: /* xterm bracketed paste */
|
||||||
|
term->bracketed_paste = state ? TRUE : FALSE;
|
||||||
|
break;
|
||||||
} else
|
} else
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 4: /* IRM: set insert mode */
|
case 4: /* IRM: set insert mode */
|
||||||
@ -5696,7 +5700,12 @@ void term_do_paste(Terminal *term)
|
|||||||
if (term->paste_buffer)
|
if (term->paste_buffer)
|
||||||
sfree(term->paste_buffer);
|
sfree(term->paste_buffer);
|
||||||
term->paste_pos = term->paste_hold = term->paste_len = 0;
|
term->paste_pos = term->paste_hold = term->paste_len = 0;
|
||||||
term->paste_buffer = snewn(len, wchar_t);
|
term->paste_buffer = snewn(len + 12, wchar_t);
|
||||||
|
|
||||||
|
if (term->bracketed_paste) {
|
||||||
|
memcpy(term->paste_buffer, L"\033[200~", 6 * sizeof(wchar_t));
|
||||||
|
term->paste_len += 6;
|
||||||
|
}
|
||||||
|
|
||||||
p = q = data;
|
p = q = data;
|
||||||
while (p < data + len) {
|
while (p < data + len) {
|
||||||
@ -5720,6 +5729,12 @@ void term_do_paste(Terminal *term)
|
|||||||
q = p;
|
q = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (term->bracketed_paste) {
|
||||||
|
memcpy(term->paste_buffer + term->paste_len,
|
||||||
|
L"\033[201~", 6 * sizeof(wchar_t));
|
||||||
|
term->paste_len += 6;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assume a small paste will be OK in one go. */
|
/* Assume a small paste will be OK in one go. */
|
||||||
if (term->paste_len < 256) {
|
if (term->paste_len < 256) {
|
||||||
if (term->ldisc)
|
if (term->ldisc)
|
||||||
|
@ -154,6 +154,8 @@ struct terminal_tag {
|
|||||||
int xterm_mouse; /* send mouse messages to host */
|
int xterm_mouse; /* send mouse messages to host */
|
||||||
int mouse_is_down; /* used while tracking mouse buttons */
|
int mouse_is_down; /* used while tracking mouse buttons */
|
||||||
|
|
||||||
|
int bracketed_paste;
|
||||||
|
|
||||||
int cset_attr[2];
|
int cset_attr[2];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user