41 |
/* Coding system for the next communicating with other Windows programs. */ |
/* Coding system for the next communicating with other Windows programs. */ |
42 |
static Lisp_Object Vnext_selection_coding_system; |
static Lisp_Object Vnext_selection_coding_system; |
43 |
|
|
44 |
/* The last text we put into the clipboard. This is used to prevent |
/* Sequence number, used where possible to detect when we are pasting |
45 |
passing back our own text from the clipboard, instead of using the |
our own text. */ |
46 |
kill ring. The former is undesirable because the clipboard data |
static DWORD last_clipboard_sequence_number; |
47 |
|
extern ClipboardSequence_Proc clipboard_sequence_fn; |
48 |
|
|
49 |
|
/* The last text we put into the clipboard. This is used when the OS |
50 |
|
does not support sequence numbers (NT4, 95). It is undesirable to |
51 |
|
use data put on the clipboard by Emacs because the clipboard data |
52 |
could be MULEtilated by inappropriately chosen |
could be MULEtilated by inappropriately chosen |
53 |
(next-)selection-coding-system. For this reason, we must store the |
(next-)selection-coding-system. For this reason, we must store the |
54 |
text *after* it was encoded/Unix-to-DOS-converted. */ |
text *after* it was encoded/Unix-to-DOS-converted. */ |
222 |
encode_coding (&coding, src, dst, nbytes, bufsize); |
encode_coding (&coding, src, dst, nbytes, bufsize); |
223 |
Vlast_coding_system_used = coding.symbol; |
Vlast_coding_system_used = coding.symbol; |
224 |
|
|
225 |
/* Stash away the data we are about to put into the clipboard, so we |
/* If clipboard sequence numbers are not supported, keep a copy for |
226 |
could later check inside Fw32_get_clipboard_data whether |
later comparison. */ |
227 |
the clipboard still holds our data. */ |
if (!clipboard_sequence_fn) |
228 |
if (clipboard_storage_size < coding.produced) |
{ |
229 |
{ |
/* Stash away the data we are about to put into the |
230 |
clipboard_storage_size = coding.produced + 100; |
clipboard, so we could later check inside |
231 |
last_clipboard_text = (char *) xrealloc (last_clipboard_text, |
Fw32_get_clipboard_data whether the clipboard still |
232 |
clipboard_storage_size); |
holds our data. */ |
233 |
} |
if (clipboard_storage_size < coding.produced) |
234 |
if (last_clipboard_text) |
{ |
235 |
memcpy (last_clipboard_text, dst, coding.produced); |
clipboard_storage_size = coding.produced + 100; |
236 |
|
last_clipboard_text = (char *) xrealloc (last_clipboard_text, |
237 |
|
clipboard_storage_size); |
238 |
|
} |
239 |
|
if (last_clipboard_text) |
240 |
|
memcpy (last_clipboard_text, dst, coding.produced); |
241 |
|
} |
242 |
|
|
243 |
GlobalUnlock (htext); |
GlobalUnlock (htext); |
244 |
|
|
254 |
|
|
255 |
ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); |
ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); |
256 |
|
|
257 |
|
if (clipboard_sequence_fn) |
258 |
|
last_clipboard_sequence_number = clipboard_sequence_fn (); |
259 |
|
|
260 |
CloseClipboard (); |
CloseClipboard (); |
261 |
|
|
262 |
if (ok) goto done; |
if (ok) goto done; |
268 |
if (last_clipboard_text) |
if (last_clipboard_text) |
269 |
*last_clipboard_text = '\0'; |
*last_clipboard_text = '\0'; |
270 |
|
|
271 |
|
last_clipboard_sequence_number = 0; |
272 |
|
|
273 |
done: |
done: |
274 |
UNBLOCK_INPUT; |
UNBLOCK_INPUT; |
275 |
|
|
313 |
data in the clipboard. This is so we don't pass our own text |
data in the clipboard. This is so we don't pass our own text |
314 |
from the clipboard (which might be troublesome if the killed |
from the clipboard (which might be troublesome if the killed |
315 |
text includes null characters). */ |
text includes null characters). */ |
316 |
if (last_clipboard_text |
if ((clipboard_sequence_fn |
317 |
&& clipboard_storage_size >= nbytes |
&& clipboard_sequence_fn () == last_clipboard_sequence_number) |
318 |
&& memcmp(last_clipboard_text, src, nbytes) == 0) |
|| (last_clipboard_text |
319 |
|
&& clipboard_storage_size >= nbytes |
320 |
|
&& memcmp(last_clipboard_text, src, nbytes) == 0)) |
321 |
goto closeclip; |
goto closeclip; |
322 |
|
|
323 |
{ |
{ |