1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Reinstate the Shift-Ins paste behaviour, which was accidentally

broken by the mouse button redesignation that came with xterm mouse
reporting.

[originally from svn r1130]
This commit is contained in:
Simon Tatham 2001-05-17 10:06:54 +00:00
parent aca29ffb7b
commit 079b6bc6f6
3 changed files with 51 additions and 46 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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) {