1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-26 23:32:10 -05:00

Split off copy and paste functionality from term_mouse.c so it can be used from

menu items without faking up a term_mouse call.

[originally from svn r109]
This commit is contained in:
Ben Harris 1999-03-15 22:27:04 +00:00
parent f5741e4364
commit b3a06b30ae

View File

@ -325,7 +325,7 @@ static void update_sbar(void) {
/* /*
* Check whether the region bounded by the two pointers intersects * Check whether the region bounded by the two pointers intersects
* the scroll region, and de-select the on-screen selection if so. * the selection, and de-select the on-screen selection if so.
*/ */
static void check_selection (unsigned long *from, unsigned long *to) { static void check_selection (unsigned long *from, unsigned long *to) {
if (from < selend && selstart < to) if (from < selend && selstart < to)
@ -1425,12 +1425,22 @@ void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
selend = selpoint + 1; selend = selpoint + 1;
} }
sel_spread(); sel_spread();
} else if ((b == MB_SELECT || b == MB_EXTEND) && a == MA_RELEASE) { } else if ((b == MB_SELECT || b == MB_EXTEND) && a == MA_RELEASE)
if (selstate == DRAGGING) { if (selstate == DRAGGING) {
/* term_copy();
selstate = SELECTED;
} else
selstate = NO_SELECTION;
else if (b == MB_PASTE && (a==MA_CLICK || a==MA_2CLK || a==MA_3CLK))
term_paste();
term_update();
}
/*
* We've completed a selection. We now transfer the * We've completed a selection. We now transfer the
* data to the clipboard. * data to the clipboard.
*/ */
void term_copy() {
unsigned char *p = selspace; unsigned char *p = selspace;
unsigned long *q = selstart; unsigned long *q = selstart;
@ -1455,10 +1465,9 @@ void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
q = lineend + 1; /* start of next line */ q = lineend + 1; /* start of next line */
} }
write_clip (selspace, p - selspace); write_clip (selspace, p - selspace);
selstate = SELECTED; }
} else
selstate = NO_SELECTION; void term_paste() {
} else if (b == MB_PASTE && (a==MA_CLICK || a==MA_2CLK || a==MA_3CLK)) {
char *data; char *data;
int len; int len;
@ -1481,9 +1490,6 @@ void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
} }
} }
get_clip(NULL, NULL); get_clip(NULL, NULL);
}
term_update();
} }
static void deselect (void) { static void deselect (void) {