]> code.delx.au - gnu-emacs/blob - src/w16select.c
Ibuffer change marks
[gnu-emacs] / src / w16select.c
1 /* 16-bit Windows Selection processing for emacs on MS-Windows
2
3 Copyright (C) 1996-1997, 2001-2016 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or (at
10 your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* These functions work by using WinOldAp interface. WinOldAp
21 (WINOLDAP.MOD) is a Microsoft Windows extension supporting
22 "old" (character-mode) application access to Dynamic Data Exchange,
23 menus, and the Windows clipboard. */
24
25 /* Written by Dale P. Smith <dpsm@en.com> */
26 /* Adapted to DJGPP by Eli Zaretskii <eliz@gnu.org> */
27
28 #ifdef MSDOS
29
30 #include <config.h>
31 #include <dpmi.h>
32 #include <go32.h>
33 #include <sys/farptr.h>
34 #include "lisp.h"
35 #include "dispextern.h" /* frame.h seems to want this */
36 #include "frame.h" /* Need this to get the X window of selected_frame */
37 #include "blockinput.h"
38 #include "character.h"
39 #include "buffer.h"
40 #include "coding.h"
41 #include "composite.h"
42
43 /* If ever some function outside this file will need to call any
44 clipboard-related function, the following prototypes and constants
45 should be put on a header file. Right now, nobody else uses them. */
46
47 #define CF_TEXT 0x01
48 #define CF_BITMAP 0x02
49 #define CF_METAFILE 0x03
50 #define CF_SYLK 0x04
51 #define CF_DIF 0x05
52 #define CF_TIFF 0x06
53 #define CF_OEMTEXT 0x07
54 #define CF_DIBBITMAP 0x08
55 #define CF_WINWRITE 0x80
56 #define CF_DSPTEXT 0x81
57 #define CF_DSPBITMAP 0x82
58
59 unsigned identify_winoldap_version (void);
60 unsigned open_clipboard (void);
61 unsigned empty_clipboard (void);
62 unsigned set_clipboard_data (unsigned, void *, unsigned, int);
63 unsigned get_clipboard_data_size (unsigned);
64 unsigned get_clipboard_data (unsigned, void *, unsigned, int);
65 unsigned close_clipboard (void);
66 unsigned clipboard_compact (unsigned);
67
68 /* The segment address and the size of the buffer in low
69 memory used to move data between us and WinOldAp module. */
70 static struct {
71 unsigned long size;
72 unsigned short rm_segment;
73 } clipboard_xfer_buf_info;
74
75 /* The last text we put into the clipboard. This is used to prevent
76 passing back our own text from the clipboard, instead of using the
77 kill ring. The former is undesirable because the clipboard data
78 could be MULEtilated by inappropriately chosen
79 (next-)selection-coding-system. For this reason, we must store the
80 text *after* it was encoded/Unix-to-DOS-converted. */
81 static unsigned char *last_clipboard_text;
82
83 /* The size of allocated storage for storing the clipboard data. */
84 static size_t clipboard_storage_size;
85 \f
86 /* C functions to access the Windows 3.1x clipboard from DOS apps.
87
88 The information was obtained from the Microsoft Knowledge Base,
89 article Q67675 and can be found at:
90 http://www.microsoft.com/kb/developr/win_dk/q67675.htm */
91
92 /* See also Ralf Brown's Interrupt List.
93
94 I also seem to remember reading about this in Dr. Dobbs Journal a
95 while ago, but if you knew my memory... :-)
96
97 Dale P. Smith <dpsm@en.com> */
98
99 /* Return the WinOldAp support version, or 0x1700 if not supported. */
100 unsigned
101 identify_winoldap_version (void)
102 {
103 __dpmi_regs regs;
104
105 /* Calls Int 2Fh/AX=1700h
106 Return Values AX == 1700H: Clipboard functions not available
107 <> 1700H: AL = Major version number
108 AH = Minor version number */
109 regs.x.ax = 0x1700;
110 __dpmi_int (0x2f, &regs);
111 return regs.x.ax;
112 }
113
114 /* Open the clipboard, return non-zero if successful. */
115 unsigned
116 open_clipboard (void)
117 {
118 __dpmi_regs regs;
119
120 /* Is WINOLDAP supported? */
121 /* Kludge alert!! If WinOldAp is not supported, we return a 0,
122 which is the same as ``Clipboard already open''. Currently,
123 this is taken as an error by all the functions that use
124 `open_clipboard', but if somebody someday will use that ``open''
125 clipboard, they will have interesting time debugging it... */
126 if (identify_winoldap_version () == 0x1700)
127 return 0;
128
129 /* Calls Int 2Fh/AX=1701h
130 Return Values AX == 0: Clipboard already open
131 <> 0: Clipboard opened */
132 regs.x.ax = 0x1701;
133 __dpmi_int (0x2f, &regs);
134 return regs.x.ax;
135 }
136
137 /* Empty clipboard, return non-zero if successful. */
138 unsigned
139 empty_clipboard (void)
140 {
141 __dpmi_regs regs;
142
143 /* Calls Int 2Fh/AX=1702h
144 Return Values AX == 0: Error occurred
145 <> 0: OK, Clipboard emptied */
146 regs.x.ax = 0x1702;
147 __dpmi_int (0x2f, &regs);
148 return regs.x.ax;
149 }
150
151 /* Ensure we have a buffer in low memory with enough memory for data
152 of size WANT_SIZE. Return the linear address of the buffer. */
153 static unsigned long
154 alloc_xfer_buf (unsigned want_size)
155 {
156 __dpmi_regs regs;
157
158 /* If the usual DJGPP transfer buffer is large enough, use that. */
159 if (want_size <= _go32_info_block.size_of_transfer_buffer)
160 return __tb & 0xfffff;
161
162 /* Don't even try to allocate more than 1MB of memory: DOS cannot
163 possibly handle that (it will overflow the BX register below). */
164 if (want_size > 0xfffff)
165 return 0;
166
167 /* Need size rounded up to the nearest paragraph, and in
168 paragraph units (1 paragraph = 16 bytes). */
169 clipboard_xfer_buf_info.size = (want_size + 15) >> 4;
170
171 /* The NT DPMI host crashes us if we free DOS memory via the
172 DPMI service. Work around by calling DOS allocate/free block. */
173 regs.h.ah = 0x48;
174 regs.x.bx = clipboard_xfer_buf_info.size;
175 __dpmi_int (0x21, &regs);
176 if (regs.x.flags & 1)
177 {
178 clipboard_xfer_buf_info.size = 0;
179 return 0;
180 }
181
182 clipboard_xfer_buf_info.rm_segment = regs.x.ax;
183 return (((int)clipboard_xfer_buf_info.rm_segment) << 4) & 0xfffff;
184 }
185
186 /* Free our clipboard buffer. We always free it after use, because
187 keeping it leaves less free conventional memory for subprocesses.
188 The clipboard buffer tends to be large in size, because for small
189 clipboard data sizes we use the DJGPP transfer buffer. */
190 static void
191 free_xfer_buf (void)
192 {
193 /* If the size is 0, we used DJGPP transfer buffer, so don't free. */
194 if (clipboard_xfer_buf_info.size)
195 {
196 __dpmi_regs regs;
197
198 /* The NT DPMI host crashes us if we free DOS memory via
199 the DPMI service. Work around by calling DOS free block. */
200 regs.h.ah = 0x49;
201 regs.x.es = clipboard_xfer_buf_info.rm_segment;
202 __dpmi_int (0x21, &regs);
203 clipboard_xfer_buf_info.size = 0;
204 }
205 }
206
207 /* Copy data into the clipboard, return zero if successful. */
208 unsigned
209 set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
210 {
211 __dpmi_regs regs;
212 unsigned truelen;
213 unsigned long xbuf_addr, buf_offset;
214 unsigned char *dp = Data, *dstart = dp;
215
216 if (Format != CF_OEMTEXT)
217 return 3;
218
219 /* need to know final size after '\r' chars are inserted (the
220 standard CF_OEMTEXT clipboard format uses CRLF line endings,
221 while Emacs uses just LF internally). */
222 truelen = Size + 1; /* +1 for the terminating null */
223
224 if (!Raw)
225 {
226 /* avoid using strchr because it recomputes the length everytime */
227 while ((dp = memchr (dp, '\n', Size - (dp - dstart))) != 0)
228 {
229 truelen++;
230 dp++;
231 }
232 }
233
234 if (clipboard_compact (truelen) < truelen)
235 return 1;
236
237 if ((xbuf_addr = alloc_xfer_buf (truelen)) == 0)
238 return 1;
239
240 /* Move the buffer into the low memory, convert LF into CR-LF if needed. */
241 if (Raw)
242 {
243 dosmemput (Data, Size, xbuf_addr);
244
245 /* Terminate with a null, otherwise Windows does strange things
246 when the text size is an integral multiple of 32 bytes. */
247 _farpokeb (_dos_ds, xbuf_addr + Size, '\0');
248 }
249 else
250 {
251 dp = Data;
252 buf_offset = xbuf_addr;
253 _farsetsel (_dos_ds);
254 while (Size--)
255 {
256 /* Don't allow them to put binary data into the clipboard, since
257 it will cause yanked data to be truncated at the first null. */
258 if (*dp == '\0')
259 return 2;
260 if (*dp == '\n')
261 _farnspokeb (buf_offset++, '\r');
262 _farnspokeb (buf_offset++, *dp++);
263 }
264
265 /* Terminate with a null, otherwise Windows does strange things
266 when the text size is an integral multiple of 32 bytes. */
267 _farnspokeb (buf_offset, '\0');
268 }
269
270 /* Stash away the data we are about to put into the clipboard, so we
271 could later check inside get_clipboard_data whether the clipboard
272 still holds our data. */
273 if (clipboard_storage_size < truelen)
274 {
275 clipboard_storage_size = truelen + 100;
276 last_clipboard_text =
277 (char *) xrealloc (last_clipboard_text, clipboard_storage_size);
278 }
279 if (last_clipboard_text)
280 dosmemget (xbuf_addr, truelen, last_clipboard_text);
281
282 /* Calls Int 2Fh/AX=1703h with:
283 DX = WinOldAp-Supported Clipboard format
284 ES:BX = Pointer to data
285 SI:CX = Size of data in bytes
286 Return Values AX == 0: Error occurred
287 <> 0: OK. Data copied into the Clipboard. */
288 regs.x.ax = 0x1703;
289 regs.x.dx = Format;
290 regs.x.si = truelen >> 16;
291 regs.x.cx = truelen & 0xffff;
292 regs.x.es = xbuf_addr >> 4;
293 regs.x.bx = xbuf_addr & 15;
294 __dpmi_int (0x2f, &regs);
295
296 free_xfer_buf ();
297
298 /* If the above failed, invalidate the local copy of the clipboard. */
299 if (regs.x.ax == 0)
300 *last_clipboard_text = '\0';
301
302 /* Zero means success, otherwise (1, 2, or 3) it's an error. */
303 return regs.x.ax > 0 ? 0 : 3;
304 }
305
306 /* Return the size of the clipboard data of format FORMAT. */
307 unsigned
308 get_clipboard_data_size (unsigned Format)
309 {
310 __dpmi_regs regs;
311
312 /* Calls Int 2Fh/AX=1704h with:
313 DX = WinOldAp-Supported Clipboard format
314 Return Values DX:AX == Size of the data in bytes, including any
315 headers.
316 == 0 If data in this format is not in
317 the clipboard. */
318 regs.x.ax = 0x1704;
319 regs.x.dx = Format;
320 __dpmi_int (0x2f, &regs);
321 return ( (((unsigned)regs.x.dx) << 16) | regs.x.ax);
322 }
323
324 /* Get clipboard data, return its length.
325 Warning: this doesn't check whether DATA has enough space to hold
326 SIZE bytes. */
327 unsigned
328 get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
329 {
330 __dpmi_regs regs;
331 unsigned long xbuf_addr;
332 unsigned char *dp = Data;
333
334 if (Format != CF_OEMTEXT)
335 return 0;
336
337 if (Size == 0)
338 return 0;
339
340 if ((xbuf_addr = alloc_xfer_buf (Size)) == 0)
341 return 0;
342
343 /* Calls Int 2Fh/AX=1705h with:
344 DX = WinOldAp-Supported Clipboard format
345 ES:BX = Pointer to data buffer to hold data
346 Return Values AX == 0: Error occurred (or data in this format is not
347 in the clipboard)
348 <> 0: OK */
349 regs.x.ax = 0x1705;
350 regs.x.dx = Format;
351 regs.x.es = xbuf_addr >> 4;
352 regs.x.bx = xbuf_addr & 15;
353 __dpmi_int (0x2f, &regs);
354 if (regs.x.ax != 0)
355 {
356 unsigned char null_char = '\0';
357 unsigned long xbuf_beg = xbuf_addr;
358
359 /* If last_clipboard_text is NULL, we don't want to slow down
360 the next loop by an additional test. */
361 register unsigned char *lcdp =
362 last_clipboard_text == NULL ? &null_char : last_clipboard_text;
363
364 /* Copy data from low memory, remove CR
365 characters before LF if needed. */
366 _farsetsel (_dos_ds);
367 while (Size--)
368 {
369 register unsigned char c = _farnspeekb (xbuf_addr++);
370
371 if (*lcdp == c)
372 lcdp++;
373
374 if ((*dp++ = c) == '\r' && !Raw && _farnspeekb (xbuf_addr) == '\n')
375 {
376 dp--;
377 *dp++ = '\n';
378 xbuf_addr++;
379 if (*lcdp == '\n')
380 lcdp++;
381 }
382 /* Windows reportedly rounds up the size of clipboard data
383 (passed in SIZE) to a multiple of 32, and removes trailing
384 spaces from each line without updating SIZE. We therefore
385 bail out when we see the first null character. */
386 else if (c == '\0')
387 break;
388 }
389
390 /* If the text in clipboard is identical to what we put there
391 last time set_clipboard_data was called, pretend there's no
392 data in the clipboard. This is so we don't pass our own text
393 from the clipboard (which might be troublesome if the killed
394 text includes null characters). */
395 if (last_clipboard_text &&
396 xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text))
397 dp = (unsigned char *)Data + 1;
398 }
399
400 free_xfer_buf ();
401
402 return (unsigned) (dp - (unsigned char *)Data - 1);
403 }
404
405 /* Close clipboard, return non-zero if successful. */
406 unsigned
407 close_clipboard (void)
408 {
409 __dpmi_regs regs;
410
411 /* Calls Int 2Fh/AX=1708h
412 Return Values AX == 0: Error occurred
413 <> 0: OK */
414 regs.x.ax = 0x1708;
415 __dpmi_int (0x2f, &regs);
416 return regs.x.ax;
417 }
418
419 /* Compact clipboard data so that at least SIZE bytes is available. */
420 unsigned
421 clipboard_compact (unsigned Size)
422 {
423 __dpmi_regs regs;
424
425 /* Calls Int 2Fh/AX=1709H with:
426 SI:CX = Desired memory size in bytes.
427 Return Values DX:AX == Number of bytes of largest block of free memory.
428 == 0 if error or no memory */
429 regs.x.ax = 0x1709;
430 regs.x.si = Size >> 16;
431 regs.x.cx = Size & 0xffff;
432 __dpmi_int (0x2f, &regs);
433 return ((unsigned)regs.x.dx << 16) | regs.x.ax;
434 }
435 \f
436 static char no_mem_msg[] =
437 "(Not enough DOS memory to put saved text into clipboard.)";
438 static char binary_msg[] =
439 "(Binary characters in saved text; clipboard data not set.)";
440 static char system_error_msg[] =
441 "(Clipboard interface failure; clipboard data not set.)";
442
443 DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_data, 1, 2, 0,
444 doc: /* This sets the clipboard data to the given text. */)
445 (Lisp_Object string, Lisp_Object frame)
446 {
447 unsigned ok = 1, put_status = 0;
448 int nbytes, no_crlf_conversion;
449 unsigned char *src, *dst = NULL;
450
451 CHECK_STRING (string);
452
453 if (!FRAME_MSDOS_P (decode_live_frame (frame)))
454 goto done;
455
456 block_input ();
457
458 if (!open_clipboard ())
459 goto error;
460
461 nbytes = SBYTES (string);
462 src = SDATA (string);
463
464 /* Do we need to encode this text? */
465 for (dst = src; dst < src + nbytes; dst++)
466 {
467 if (*dst == '\0' || *dst >= 0x80)
468 break;
469 }
470 if (dst >= src + nbytes)
471 {
472 /* No multibyte characters in text. We need not encode it, but we
473 will have to convert it to DOS CR-LF style. */
474 no_crlf_conversion = 0;
475 Vlast_coding_system_used = Qraw_text;
476 dst = NULL; /* so we don't try to free a random pointer */
477 }
478 else
479 {
480 /* We must encode contents of STRING according to what
481 clipboard-coding-system specifies. */
482 struct coding_system coding;
483 Lisp_Object coding_system =
484 NILP (Vnext_selection_coding_system) ?
485 Vselection_coding_system : Vnext_selection_coding_system;
486
487 setup_coding_system (Fcheck_coding_system (coding_system), &coding);
488 coding.dst_bytes = nbytes * 4;
489 coding.destination = xmalloc (coding.dst_bytes);
490 Vnext_selection_coding_system = Qnil;
491 coding.mode |= CODING_MODE_LAST_BLOCK;
492 dst = coding.destination;
493 encode_coding_object (&coding, string, 0, 0,
494 SCHARS (string), nbytes, Qnil);
495 no_crlf_conversion = 1;
496 nbytes = coding.produced;
497 Vlast_coding_system_used = CODING_ID_NAME (coding.id);
498 src = dst;
499 }
500
501 ok = empty_clipboard ()
502 && ((put_status
503 = set_clipboard_data (CF_OEMTEXT, src, nbytes, no_crlf_conversion))
504 == 0);
505
506 if (!no_crlf_conversion)
507 close_clipboard ();
508
509 if (ok) goto unblock;
510
511 error:
512
513 ok = 0;
514
515 unblock:
516 xfree (dst);
517 unblock_input ();
518
519 /* Notify user if the text is too large to fit into DOS memory.
520 (This will happen somewhere after 600K bytes (470K in DJGPP v1.x),
521 depending on user system configuration.) If we just silently
522 fail the function, people might wonder why their text sometimes
523 doesn't make it to the clipboard. */
524 if (put_status)
525 {
526 switch (put_status)
527 {
528 case 1:
529 message3 (make_unibyte_string (no_mem_msg, sizeof (no_mem_msg) - 1));
530 break;
531 case 2:
532 message3 (make_unibyte_string (binary_msg, sizeof (binary_msg) - 1));
533 break;
534 case 3:
535 message3 (make_unibyte_string (system_error_msg, sizeof (system_error_msg) - 1));
536 break;
537 }
538 sit_for (make_number (2), 0, 2);
539 }
540
541 done:
542
543 return (ok && put_status == 0 ? string : Qnil);
544 }
545
546 DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_data, 0, 1, 0,
547 doc: /* This gets the clipboard data in text format. */)
548 (Lisp_Object frame)
549 {
550 unsigned data_size, truelen;
551 unsigned char *htext = NULL;
552 Lisp_Object ret = Qnil;
553 int require_decoding = 0;
554
555 if (!FRAME_MSDOS_P (decode_live_frame (frame)))
556 goto done;
557
558 block_input ();
559
560 if (!open_clipboard ())
561 goto unblock;
562
563 if ((data_size = get_clipboard_data_size (CF_OEMTEXT)) == 0 ||
564 (htext = xmalloc (data_size)) == 0)
565 goto closeclip;
566
567 /* need to know final size after '\r' chars are removed because
568 we can't change the string size manually, and doing an extra
569 copy is silly */
570 if ((truelen = get_clipboard_data (CF_OEMTEXT, htext, data_size, 0)) == 0)
571 goto closeclip;
572
573 /* Do we need to decode it? */
574 {
575 /* If the clipboard data contains any 8-bit Latin-1 code, we
576 need to decode it. */
577 int i;
578
579 for (i = 0; i < truelen; i++)
580 {
581 if (htext[i] >= 0x80)
582 {
583 require_decoding = 1;
584 break;
585 }
586 }
587 }
588 if (require_decoding)
589 {
590 struct coding_system coding;
591 Lisp_Object coding_system = Vnext_selection_coding_system;
592
593 truelen = get_clipboard_data (CF_OEMTEXT, htext, data_size, 1);
594 if (NILP (coding_system))
595 coding_system = Vselection_coding_system;
596 setup_coding_system (Fcheck_coding_system (coding_system), &coding);
597 coding.source = htext;
598 coding.mode |= CODING_MODE_LAST_BLOCK;
599 /* We explicitly disable composition handling because selection
600 data should not contain any composition sequence. */
601 coding.common_flags &= ~CODING_ANNOTATION_MASK;
602 decode_coding_object (&coding, Qnil, 0, 0, truelen, truelen, Qt);
603 ret = coding.dst_object;
604 Vlast_coding_system_used = CODING_ID_NAME (coding.id);
605 }
606 else
607 {
608 ret = make_unibyte_string ((char *) htext, truelen);
609 Vlast_coding_system_used = Qraw_text;
610 }
611
612 xfree (htext);
613 Vnext_selection_coding_system = Qnil;
614
615 closeclip:
616 close_clipboard ();
617
618 unblock:
619 unblock_input ();
620
621 done:
622
623 return (ret);
624 }
625
626 /* Support checking for a clipboard selection. */
627
628 DEFUN ("w16-selection-exists-p", Fw16_selection_exists_p, Sw16_selection_exists_p,
629 0, 2, 0,
630 doc: /* Whether there is an owner for the given X selection.
631 SELECTION should be the name of the selection in question, typically
632 one of the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'. (X expects
633 these literal upper-case names.) The symbol nil is the same as
634 `PRIMARY', and t is the same as `SECONDARY'.
635
636 TERMINAL should be a terminal object or a frame specifying the X
637 server to query. If omitted or nil, that stands for the selected
638 frame's display, or the first available X display. */)
639 (Lisp_Object selection, Lisp_Object terminal)
640 {
641 CHECK_SYMBOL (selection);
642
643 /* Return nil for SECONDARY selection. For PRIMARY (or nil)
644 selection, check if there is some text on the kill-ring;
645 for CLIPBOARD, check if the clipboard currently has valid
646 text format contents.
647
648 The test for killed text on the kill-ring emulates the Emacs
649 behavior on X, where killed text is also put into X selection
650 by the X interface code. (On MSDOS, killed text is only put
651 into the clipboard if we run under Windows, so we cannot check
652 the clipboard alone.) */
653 if ((EQ (selection, Qnil) || EQ (selection, QPRIMARY))
654 && ! NILP (Fsymbol_value (Fintern_soft (build_string ("kill-ring"),
655 Qnil))))
656 return Qt;
657
658 if (EQ (selection, QCLIPBOARD))
659 {
660 Lisp_Object val = Qnil;
661
662 if (open_clipboard ())
663 {
664 if (get_clipboard_data_size (CF_OEMTEXT))
665 val = Qt;
666 close_clipboard ();
667 }
668 return val;
669 }
670 return Qnil;
671 }
672
673 void
674 syms_of_win16select (void)
675 {
676 defsubr (&Sw16_set_clipboard_data);
677 defsubr (&Sw16_get_clipboard_data);
678 defsubr (&Sw16_selection_exists_p);
679
680 DEFVAR_LISP ("selection-coding-system", Vselection_coding_system,
681 doc: /* Coding system for communicating with other programs.
682
683 For MS-Windows and MS-DOS:
684 When sending or receiving text via selection and clipboard, the text
685 is encoded or decoded by this coding system. The default value is
686 the current system default encoding on 9x/Me, `utf-16le-dos'
687 \(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
688
689 For X Windows:
690 When sending text via selection and clipboard, if the target
691 data-type matches with the type of this coding system, it is used
692 for encoding the text. Otherwise (including the case that this
693 variable is nil), a proper coding system is used as below:
694
695 data-type coding system
696 --------- -------------
697 UTF8_STRING utf-8
698 COMPOUND_TEXT compound-text-with-extensions
699 STRING iso-latin-1
700 C_STRING no-conversion
701
702 When receiving text, if this coding system is non-nil, it is used
703 for decoding regardless of the data-type. If this is nil, a
704 proper coding system is used according to the data-type as above.
705
706 See also the documentation of the variable `x-select-request-type' how
707 to control which data-type to request for receiving text.
708
709 The default value is nil. */);
710 Vselection_coding_system = intern ("iso-latin-1-dos");
711
712 DEFVAR_LISP ("next-selection-coding-system", Vnext_selection_coding_system,
713 doc: /* Coding system for the next communication with other programs.
714 Usually, `selection-coding-system' is used for communicating with
715 other programs (X Windows clients or MS Windows programs). But, if this
716 variable is set, it is used for the next communication only.
717 After the communication, this variable is set to nil. */);
718 Vnext_selection_coding_system = Qnil;
719
720 DEFSYM (QCLIPBOARD, "CLIPBOARD");
721 }
722
723 #endif /* MSDOS */