mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Stop front ends remembering the data of their last paste.
Previously, both the Unix and Windows front ends would respond to a paste action by retrieving data from the system clipboard, converting it appropriately, _storing_ it in a persistent dynamic data block inside the front end, and then calling term_do_paste(term), which in turn would call back to the front end via get_clip() to retrieve the current contents of that stored data block. But, as far as I can tell, this was a completely pointless mechanism, because after a data block was written into this storage area, it would be immediately used for exactly one paste, and then never accessed again until the next paste action caused it to be freed and replaced with a new chunk of pasted data. So why on earth was it stored persistently at all, and why that callback mechanism from frontend to terminal back to frontend to retrieve it for the actual paste action? I have no idea. This change removes the entire system and replaces it with the completely obvious alternative: the character-set-converted version of paste data is allocated in a _local_ variable in the frontend paste functions, passed directly to term_do_paste which now takes (buffer,length) parameters, and freed immediately afterwards. get_clip() is gone.
This commit is contained in:
@ -105,7 +105,7 @@ static int is_full_screen(void);
|
||||
static void make_full_screen(void);
|
||||
static void clear_full_screen(void);
|
||||
static void flip_full_screen(void);
|
||||
static int process_clipdata(HGLOBAL clipdata, int unicode);
|
||||
static void process_clipdata(HGLOBAL clipdata, int unicode);
|
||||
|
||||
/* Window layout information */
|
||||
static void reset_window(int);
|
||||
@ -135,9 +135,6 @@ static const struct telnet_special *specials = NULL;
|
||||
static HMENU specials_menu = NULL;
|
||||
static int n_specials = 0;
|
||||
|
||||
static wchar_t *clipboard_contents;
|
||||
static size_t clipboard_length;
|
||||
|
||||
#define TIMING_TIMER_ID 1234
|
||||
static long timing_next_time;
|
||||
|
||||
@ -3176,8 +3173,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
}
|
||||
return 0;
|
||||
case WM_GOT_CLIPDATA:
|
||||
if (process_clipdata((HGLOBAL)lParam, wParam))
|
||||
term_do_paste(term);
|
||||
process_clipdata((HGLOBAL)lParam, wParam);
|
||||
return 0;
|
||||
default:
|
||||
if (message == wm_mousewheel || message == WM_MOUSEWHEEL) {
|
||||
@ -5340,11 +5336,10 @@ static DWORD WINAPI clipboard_read_threadfunc(void *param)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_clipdata(HGLOBAL clipdata, int unicode)
|
||||
static void process_clipdata(HGLOBAL clipdata, int unicode)
|
||||
{
|
||||
sfree(clipboard_contents);
|
||||
clipboard_contents = NULL;
|
||||
clipboard_length = 0;
|
||||
wchar_t *clipboard_contents = NULL;
|
||||
size_t clipboard_length = 0;
|
||||
|
||||
if (unicode) {
|
||||
wchar_t *p = GlobalLock(clipdata);
|
||||
@ -5357,7 +5352,7 @@ static int process_clipdata(HGLOBAL clipdata, int unicode)
|
||||
clipboard_contents = snewn(clipboard_length + 1, wchar_t);
|
||||
memcpy(clipboard_contents, p, clipboard_length * sizeof(wchar_t));
|
||||
clipboard_contents[clipboard_length] = L'\0';
|
||||
return TRUE;
|
||||
term_do_paste(term, clipboard_contents, clipboard_length);
|
||||
}
|
||||
} else {
|
||||
char *s = GlobalLock(clipdata);
|
||||
@ -5370,11 +5365,11 @@ static int process_clipdata(HGLOBAL clipdata, int unicode)
|
||||
clipboard_contents, i);
|
||||
clipboard_length = i - 1;
|
||||
clipboard_contents[clipboard_length] = L'\0';
|
||||
return TRUE;
|
||||
term_do_paste(term, clipboard_contents, clipboard_length);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
sfree(clipboard_contents);
|
||||
}
|
||||
|
||||
void request_paste(void *frontend)
|
||||
@ -5400,14 +5395,6 @@ void request_paste(void *frontend)
|
||||
hwnd, 0, &in_threadid);
|
||||
}
|
||||
|
||||
void get_clip(void *frontend, wchar_t **p, int *len)
|
||||
{
|
||||
if (p) {
|
||||
*p = clipboard_contents;
|
||||
*len = clipboard_length;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Move `lines' lines from position `from' to position `to' in the
|
||||
|
Reference in New Issue
Block a user