annotate src/w16select.c @ 22592:17e17690ab4e

(sc-cite-region-limit): Use `other' widget type.
author Andreas Schwab <schwab@suse.de>
date Wed, 24 Jun 1998 09:18:11 +0000
parents 64adf1f4d54d
children 3537e1563a66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21709
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
1 /* 16-bit Windows Selection processing for emacs on MS-Windows
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2 Copyright (C) 1996, 1997 Free Software Foundation.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
3
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
5
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 any later version.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21 /* These functions work by using WinOldAp interface. WinOldAp
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22 (WINOLDAP.MOD) is a Microsoft Windows extension supporting
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 "old" (character-mode) application access to Dynamic Data Exchange,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24 menus, and the Windows clipboard. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
26 /* Written by Dale P. Smith <dpsm@en.com> */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27 /* Adapted to DJGPP v1 by Eli Zaretskii <eliz@is.elta.co.il> */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29 #ifdef MSDOS
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 #include <config.h>
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32 #include <string.h>
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 #include <dpmi.h>
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 #include <go32.h>
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 #include <sys/farptr.h>
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 #include "lisp.h"
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 #include "dispextern.h" /* frame.h seems to want this */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 #include "frame.h" /* Need this to get the X window of selected_frame */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
39 #include "blockinput.h"
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 /* If ever some function outside this file will need to call any
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 clipboard-related function, the following prototypes and constants
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 should be put on a header file. Right now, nobody else uses them. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 #define CF_TEXT 0x01
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 #define CF_BITMAP 0x02
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 #define CF_METAFILE 0x03
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 #define CF_SYLK 0x04
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 #define CF_DIF 0x05
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 #define CF_TIFF 0x06
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51 #define CF_OEMTEXT 0x07
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
52 #define CF_DIBBITMAP 0x08
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53 #define CF_WINWRITE 0x80
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54 #define CF_DSPTEXT 0x81
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
55 #define CF_DSPBITMAP 0x82
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
57 unsigned identify_winoldap_version (void);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
58 unsigned open_clipboard (void);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 unsigned empty_clipboard (void);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 unsigned set_clipboard_data (unsigned, void *, unsigned);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 unsigned get_clipboard_data_size (unsigned);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62 unsigned get_clipboard_data (unsigned, void *, unsigned);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 unsigned close_clipboard (void);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
64 unsigned clipboard_compact (unsigned);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 Lisp_Object QCLIPBOARD, QPRIMARY;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 /* The segment address and the size of the buffer in low
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 memory used to move data between us and WinOldAp module. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
70
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71 static struct {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 unsigned long size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 unsigned short rm_segment;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74 } clipboard_xfer_buf_info;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76 /* Emulation of `__dpmi_int' and friends for DJGPP v1.x */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78 #if __DJGPP__ < 2
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 typedef _go32_dpmi_registers __dpmi_regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 #define __tb _go32_info_block.linear_address_of_transfer_buffer
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 #define _dos_ds _go32_info_block.selector_for_linear_memory
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84 static int
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 __dpmi_int (intno, regs)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 int intno;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 __dpmi_regs *regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 regs->x.ss = regs->x.sp = regs->x.flags = 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 return _go32_dpmi_simulate_int (intno, regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 #endif /* __DJGPP__ < 2 */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95 /* C functions to access the Windows 3.1x clipboard from DOS apps.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 The information was obtained from the Microsoft Knowledge Base,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98 article Q67675 and can be found at:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99 http://www.microsoft.com/kb/developr/win_dk/q67675.htm */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 /* See also Ralf Brown's Interrupt List.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 I also seem to remember reading about this in Dr. Dobbs Journal a
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 while ago, but if you knew my memory... :-)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106 Dale P. Smith <dpsm@en.com> */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 /* Return the WinOldAp support version, or 0x1700 if not supported. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 identify_winoldap_version ()
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
114 /* Calls Int 2Fh/AX=1700h
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115 Return Values AX == 1700H: Clipboard functions not available
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 <> 1700H: AL = Major version number
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 AH = Minor version number */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 regs.x.ax = 0x1700;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 return regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 /* Open the clipboard, return non-zero if successfull. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 open_clipboard ()
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 /* Is WINOLDAP supported? */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 /* Kludge alert!! If WinOldAp is not supported, we return a 0,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 which is the same as ``Clipboard already open''. Currently,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 this is taken as an error by all the functions that use
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 `open_clipboard', but if somebody someday will use that ``open''
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 clipboard, they will have interesting time debugging it... */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 if (identify_winoldap_version () == 0x1700)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 /* Calls Int 2Fh/AX=1701h
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 Return Values AX == 0: Clipboard already open
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 <> 0: Clipboard opened */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 regs.x.ax = 0x1701;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 return regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 /* Empty clipboard, return non-zero if successfull. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 empty_clipboard ()
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 /* Calls Int 2Fh/AX=1702h
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 Return Values AX == 0: Error occurred
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 <> 0: OK, Clipboard emptied */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 regs.x.ax = 0x1702;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 return regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 /* Ensure we have a buffer in low memory with enough memory for data
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 of size WANT_SIZE. Return the linear address of the buffer. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 static unsigned long
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 alloc_xfer_buf (want_size)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 unsigned want_size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 /* If the usual DJGPP transfer buffer is large enough, use that. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 if (want_size <= _go32_info_block.size_of_transfer_buffer)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 return __tb & 0xfffff;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171
21709
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
172 /* Don't even try to allocate more than 1MB of memory: DOS cannot
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
173 possibly handle that (it will overflow the BX register below). */
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
174 if (want_size > 0xfffff)
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
175 return 0;
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
176
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 /* Need size rounded up to the nearest paragraph, and in
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 paragraph units (1 paragraph = 16 bytes). */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 clipboard_xfer_buf_info.size = (want_size + 15) >> 4;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 /* The NT DPMI host crashes us if we free DOS memory via the
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 DPMI service. Work around by calling DOS allocate/free block. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 regs.h.ah = 0x48;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 regs.x.bx = clipboard_xfer_buf_info.size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 __dpmi_int (0x21, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 if (regs.x.flags & 1)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 clipboard_xfer_buf_info.size = 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 clipboard_xfer_buf_info.rm_segment = regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 return (((int)clipboard_xfer_buf_info.rm_segment) << 4) & 0xfffff;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 /* Free our clipboard buffer. We always free it after use, because
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
197 keeping it leaves less free conventional memory for subprocesses.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198 The clipboard buffer tends to be large in size, because for small
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
199 clipboard data sizes we use the DJGPP transfer buffer. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200 static void
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 free_xfer_buf ()
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 /* If the size is 0, we used DJGPP transfer buffer, so don't free. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 if (clipboard_xfer_buf_info.size)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
208 /* The NT DPMI host crashes us if we free DOS memory via
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209 the DPMI service. Work around by calling DOS free block. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210 regs.h.ah = 0x49;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 regs.x.es = clipboard_xfer_buf_info.rm_segment;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 __dpmi_int (0x21, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 clipboard_xfer_buf_info.size = 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 /* Copy data into the clipboard, return non-zero if successfull. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 set_clipboard_data (Format, Data, Size)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 unsigned Format;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 void *Data;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 unsigned Size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
224 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 unsigned truelen;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 unsigned long xbuf_addr, buf_offset;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 unsigned char *dp = Data, *dstart = dp;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 if (Format != CF_TEXT)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 /* need to know final size after '\r' chars are inserted (the
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 standard CF_TEXT clipboard format uses CRLF line endings,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 while Emacs uses just LF internally). */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
235 truelen = Size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236 /* avoid using strchr because it recomputes the length everytime */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 while ((dp = memchr (dp, '\n', Size - (dp - dstart))) != 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
238 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
239 truelen++;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 dp++;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
242
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
243 if (clipboard_compact (truelen) < truelen)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 if ((xbuf_addr = alloc_xfer_buf (truelen)) == 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 /* Move the buffer into the low memory, convert LF into CR-LF pairs. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 dp = Data;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251 buf_offset = xbuf_addr;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
252 _farsetsel (_dos_ds);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253 while (Size--)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
254 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255 if (*dp == '\n')
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
256 _farnspokeb (buf_offset++, '\r');
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
257 _farnspokeb (buf_offset++, *dp++);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
258 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
259
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
260 /* Calls Int 2Fh/AX=1703h with:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
261 DX = WinOldAp-Supported Clipboard format
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262 ES:BX = Pointer to data
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263 SI:CX = Size of data in bytes
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264 Return Values AX == 0: Error occurred
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 <> 0: OK. Data copied into the Clipboard. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 regs.x.ax = 0x1703;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 regs.x.dx = Format;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 regs.x.si = truelen >> 16;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269 regs.x.cx = truelen & 0xffff;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 regs.x.es = xbuf_addr >> 4;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271 regs.x.bx = xbuf_addr & 15;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 free_xfer_buf ();
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
275
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276 return regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 /* Return the size of the clipboard data of format FORMAT. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 get_clipboard_data_size (Format)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 unsigned Format;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
286 /* Calls Int 2Fh/AX=1704h with:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287 DX = WinOldAp-Supported Clipboard format
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288 Return Values DX:AX == Size of the data in bytes, including any
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 headers.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290 == 0 If data in this format is not in
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 the clipboard. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 regs.x.ax = 0x1704;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 regs.x.dx = Format;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 return ( (((unsigned)regs.x.dx) << 16) | regs.x.ax);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 /* Get clipboard data, return its length.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 Warning: this doesn't check whether DATA has enough space to hold
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 SIZE bytes. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 get_clipboard_data (Format, Data, Size)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 unsigned Format;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 void *Data;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 unsigned Size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 unsigned datalen = 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
309 unsigned long xbuf_addr;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
310 unsigned char *dp = Data;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 if (Format != CF_TEXT)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
313 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
314
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
315 if (Size == 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
316 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
317
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
318 if ((xbuf_addr = alloc_xfer_buf (Size)) == 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319 return 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
321 /* Calls Int 2Fh/AX=1705h with:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 DX = WinOldAp-Supported Clipboard format
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 ES:BX = Pointer to data buffer to hold data
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
324 Return Values AX == 0: Error occurred (or data in this format is not
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
325 in the clipboard)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
326 <> 0: OK */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
327 regs.x.ax = 0x1705;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
328 regs.x.dx = Format;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
329 regs.x.es = xbuf_addr >> 4;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
330 regs.x.bx = xbuf_addr & 15;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
331 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 if (regs.x.ax != 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
334 /* Copy data from low memory, remove CR characters if before LF. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335 _farsetsel (_dos_ds);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
336 while (Size--)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
337 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
338 register unsigned char c = _farnspeekb (xbuf_addr++);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
339
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
340 if ((*dp++ = c) == '\r' && _farnspeekb (xbuf_addr) == '\n')
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
341 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 dp--;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 *dp++ = '\n';
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 xbuf_addr++;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 /* Windows reportedly rounds up the size of clipboard data
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 (passed in SIZE) to a multiple of 32. We therefore bail
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 out when we see the first null character. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
349 else if (c == '\0')
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351 datalen = dp - (unsigned char *)Data - 1;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
352 break;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 free_xfer_buf ();
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
358
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 return datalen;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362 /* Close clipboard, return non-zero if successfull. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 close_clipboard ()
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
368 /* Calls Int 2Fh/AX=1708h
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
369 Return Values AX == 0: Error occurred
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370 <> 0: OK */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371 regs.x.ax = 0x1708;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
372 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373 return regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
375
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
376 /* Compact clipboard data so that at least SIZE bytes is available. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377 unsigned
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 clipboard_compact (Size)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 unsigned Size;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 __dpmi_regs regs;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
382
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
383 /* Calls Int 2Fh/AX=1709H with:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
384 SI:CX = Desired memory size in bytes.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385 Return Values DX:AX == Number of bytes of largest block of free memory.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
386 == 0 if error or no memory */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387 regs.x.ax = 0x1709;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
388 regs.x.si = Size >> 16;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 regs.x.cx = Size & 0xffff;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
390 __dpmi_int(0x2f, &regs);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
391 return ((unsigned)regs.x.dx << 16) | regs.x.ax;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
392 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
393
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
394 static char no_mem_msg[] =
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 "(Not enough DOS memory to put saved text into clipboard.)";
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396
21709
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
397 DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_data, 1, 2, 0,
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
398 "This sets the clipboard data to the given text.")
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399 (string, frame)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
400 Lisp_Object string, frame;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402 int ok = 1, ok1 = 1;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403 int nbytes;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 unsigned char *src;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
405
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 CHECK_STRING (string, 0);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 if (NILP (frame))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409 frame = Fselected_frame ();
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
410
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 CHECK_LIVE_FRAME (frame, 0);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412 if ( !FRAME_MSDOS_P (XFRAME (frame)))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
413 goto done;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415 BLOCK_INPUT;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
416
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
417 nbytes = XSTRING (string)->size + 1;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418 src = XSTRING (string)->data;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
420 if (!open_clipboard ())
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
421 goto error;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
422
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
423 ok = empty_clipboard () && (ok1 = set_clipboard_data (CF_TEXT, src, nbytes));
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
425 close_clipboard ();
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426
21707
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
427 if (ok) goto unblock;
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
429 error:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
431 ok = 0;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432
21707
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
433 unblock:
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
434 UNBLOCK_INPUT;
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
435
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436 /* Notify user if the text is too large to fit into DOS memory.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
437 (This will happen somewhere after 600K bytes (470K in DJGPP v1.x),
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
438 depending on user system configuration.) If we just silently
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
439 fail the function, people might wonder why their text sometimes
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
440 doesn't make it to the clipboard. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 if (ok1 == 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442 {
21417
7a310ef91b2d (Fwin16_set_clipboard_data): Call message2 with 3
Karl Heuer <kwzh@gnu.org>
parents: 17960
diff changeset
443 message2 (no_mem_msg, sizeof (no_mem_msg) - 1, 0);
17960
5c31b98be973 (Fwin16_set_clipboard_data): Pass new arg to sit_for.
Richard M. Stallman <rms@gnu.org>
parents: 17451
diff changeset
444 sit_for (2, 0, 0, 1, 1);
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
445 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
446
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
447 done:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
448
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
449 return (ok ? string : Qnil);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
450 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
451
21709
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
452 DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_data, 0, 1, 0,
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
453 "This gets the clipboard data in text format.")
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
454 (frame)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
455 Lisp_Object frame;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
456 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
457 unsigned data_size, truelen;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
458 unsigned char *htext;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
459 Lisp_Object ret = Qnil;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
460
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
461 if (!NILP (frame))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
462 CHECK_LIVE_FRAME (frame, 0);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
463
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
464 if (NILP (frame))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
465 frame = Fselected_frame ();
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
466
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
467 CHECK_LIVE_FRAME (frame, 0);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
468 if ( !FRAME_MSDOS_P (XFRAME (frame)))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
469 goto done;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
470
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
471 BLOCK_INPUT;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
473 if (!open_clipboard ())
21707
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
474 goto unblock;
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
475
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
476 if ((data_size = get_clipboard_data_size (CF_TEXT)) == 0 ||
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
477 (htext = (unsigned char *)xmalloc (data_size)) == 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
478 goto closeclip;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
479
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
480 /* need to know final size after '\r' chars are removed because
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
481 we can't change the string size manually, and doing an extra
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
482 copy is silly */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 if ((truelen = get_clipboard_data (CF_TEXT, htext, data_size)) == 0)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484 goto closeclip;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
485
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 ret = make_string (htext, truelen);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
487 xfree (htext);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
488
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489 closeclip:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
490 close_clipboard ();
21707
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
491
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
492 unblock:
7b76832ac019 (Fwin16_set_clipboard_data): Call UNBLOCK_INPUT before calling sit_for.
Eli Zaretskii <eliz@gnu.org>
parents: 21417
diff changeset
493 UNBLOCK_INPUT;
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
494
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
495 done:
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
497 return (ret);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
500 /* Support checking for a clipboard selection. */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
501
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
502 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 0, 1, 0,
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504 "Whether there is an owner for the given X Selection.\n\
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505 The arg should be the name of the selection in question, typically one of\n\
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
507 \(Those are literal upper-case symbol names, since that's what X expects.)\n\
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 For convenience, the symbol nil is the same as `PRIMARY',\n\
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
509 and t is the same as `SECONDARY'.")
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
510 (selection)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
511 Lisp_Object selection;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
512 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
513 CHECK_SYMBOL (selection, 0);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 /* Return nil for SECONDARY selection. For PRIMARY (or nil)
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
516 selection, check if there is some text on the kill-ring;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
517 for CLIPBOARD, check if the clipboard currently has valid
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
518 text format contents.
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
519
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
520 The test for killed text on the kill-ring emulates the Emacs
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
521 behavior on X, where killed text is also put into X selection
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
522 by the X interface code. (On MSDOS, killed text is only put
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
523 into the clipboard if we run under Windows, so we cannot check
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
524 the clipboard alone.) */
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
525 if ((EQ (selection, Qnil) || EQ (selection, QPRIMARY))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
526 && ! NILP (XSYMBOL (Fintern_soft (build_string ("kill-ring"),
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
527 Qnil))->value))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528 return Qt;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 if (EQ (selection, QCLIPBOARD))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
532 Lisp_Object val = Qnil;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
533
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
534 if (open_clipboard ())
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
535 {
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
536 if (get_clipboard_data_size (CF_TEXT))
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
537 val = Qt;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
538 close_clipboard ();
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
539 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
540 return val;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
541 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
542 return Qnil;
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
543 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
544
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
545 void
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
546 syms_of_win16select ()
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
547 {
21709
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
548 defsubr (&Sw16_set_clipboard_data);
64adf1f4d54d (alloc_xfer_buf): If want_size is more than 1MB,
Eli Zaretskii <eliz@gnu.org>
parents: 21707
diff changeset
549 defsubr (&Sw16_get_clipboard_data);
17451
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
550 defsubr (&Sx_selection_exists_p);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
551
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
552 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
553 QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD);
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
554 }
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
555
0902196df62a Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
556 #endif /* MSDOS */