From 568dd02f4cd326537f5b71db44a06242a9311280 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 17 May 2001 10:06:54 +0000 Subject: [PATCH] Reinstate the Shift-Ins paste behaviour, which was accidentally broken by the mouse button redesignation that came with xterm mouse reporting. git-svn-id: svn://svn.tartarus.org/sgt/putty@1130 cda61777-01e9-0310-a592-d414129be87e --- putty.h | 1 + terminal.c | 93 +++++++++++++++++++++++++++++++++----------------------------- window.c | 3 +- 3 files changed, 51 insertions(+), 46 deletions(-) diff --git a/putty.h b/putty.h index eaffec23..6170303f 100644 --- a/putty.h +++ b/putty.h @@ -426,6 +426,7 @@ void term_deselect(void); void term_update(void); void term_invalidate(void); void term_blink(int set_cursor); +void term_do_paste(void); void term_paste(void); void term_nopaste(void); int term_ldisc(int option); diff --git a/terminal.c b/terminal.c index 7fb20292..d84f57ee 100644 --- a/terminal.c +++ b/terminal.c @@ -2969,6 +2969,54 @@ static void sel_spread(void) incpos(selend); } +void term_do_paste(void) +{ + wchar_t *data; + int len; + + get_clip(&data, &len); + if (data) { + wchar_t *p, *q; + + if (paste_buffer) + sfree(paste_buffer); + paste_pos = paste_hold = paste_len = 0; + paste_buffer = smalloc(len * sizeof(wchar_t)); + + p = q = data; + while (p < data + len) { + while (p < data + len && + !(p <= data + len - sel_nl_sz && + !memcmp(p, sel_nl, sizeof(sel_nl)))) + p++; + + { + int i; + for (i = 0; i < p - q; i++) { + paste_buffer[paste_len++] = q[i]; + } + } + + if (p <= data + len - sel_nl_sz && + !memcmp(p, sel_nl, sizeof(sel_nl))) { + paste_buffer[paste_len++] = '\r'; + p += sel_nl_sz; + } + q = p; + } + + /* Assume a small paste will be OK in one go. */ + if (paste_len < 256) { + luni_send(paste_buffer, paste_len); + if (paste_buffer) + sfree(paste_buffer); + paste_buffer = 0; + paste_pos = paste_hold = paste_len = 0; + } + } + get_clip(NULL, NULL); +} + void term_mouse(Mouse_Button b, Mouse_Action a, int x, int y, int shift, int ctrl) { @@ -3101,50 +3149,7 @@ void term_mouse(Mouse_Button b, Mouse_Action a, int x, int y, selstate = NO_SELECTION; } else if (b == MBT_PASTE && (a == MA_CLICK || a == MA_2CLK || a == MA_3CLK)) { - wchar_t *data; - int len; - - get_clip(&data, &len); - if (data) { - wchar_t *p, *q; - - if (paste_buffer) - sfree(paste_buffer); - paste_pos = paste_hold = paste_len = 0; - paste_buffer = smalloc(len * sizeof(wchar_t)); - - p = q = data; - while (p < data + len) { - while (p < data + len && - !(p <= data + len - sel_nl_sz && - !memcmp(p, sel_nl, sizeof(sel_nl)))) - p++; - - { - int i; - for (i = 0; i < p - q; i++) { - paste_buffer[paste_len++] = q[i]; - } - } - - if (p <= data + len - sel_nl_sz && - !memcmp(p, sel_nl, sizeof(sel_nl))) { - paste_buffer[paste_len++] = '\r'; - p += sel_nl_sz; - } - q = p; - } - - /* Assume a small paste will be OK in one go. */ - if (paste_len < 256) { - luni_send(paste_buffer, paste_len); - if (paste_buffer) - sfree(paste_buffer); - paste_buffer = 0; - paste_pos = paste_hold = paste_len = 0; - } - } - get_clip(NULL, NULL); + term_do_paste(); } term_update(); diff --git a/window.c b/window.c index 11aeb697..b82ccfb8 100644 --- a/window.c +++ b/window.c @@ -2461,8 +2461,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, return 0; } if (wParam == VK_INSERT && shift_state == 1) { - term_mouse(MBT_PASTE, MA_CLICK, 0, 0, 0, 0); - term_mouse(MBT_PASTE, MA_RELEASE, 0, 0, 0, 0); + term_do_paste(); return 0; } if (left_alt && wParam == VK_F4 && cfg.alt_f4) { -- 2.11.0