annotate src/select-msw.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children de805c49cfc1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
1 /* mswindows selection processing for XEmacs
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
2 Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
3
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
4 This file is part of XEmacs.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
5
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
9 later version.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
10
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
14 for more details.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
15
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
20
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
21 /* Synched up with: Not synched with FSF. */
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
22
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
23 /* Authorship:
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
24
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
25 Written by Kevin Gallo for FSF Emacs.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 249
diff changeset
26 Rewritten for mswindows by Jonathan Harris, December 1997 for 21.0.
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
27 */
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
28
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
29
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
30 #include <config.h>
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
31 #include "lisp.h"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
32 #include "frame.h"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
33 #include "select.h"
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
34
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
35 #include "console-msw.h"
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
36
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
37
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
38 /* Do protocol to assert ourself as a selection owner. Under mswindows
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
39 this is easy, we just set the clipboard. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
40 static Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
41 mswindows_own_selection (Lisp_Object selection_name,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
42 Lisp_Object selection_value)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
43 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
44 Lisp_Object converted_value = get_local_selection (selection_name, QSTRING);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
45
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
46 if (!NILP (converted_value) &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
47 CONSP (converted_value) &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
48 EQ (XCAR (converted_value), QSTRING) &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
49 /* pure mswindows behaviour only says we can own the selection
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
50 if it is the clipboard */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
51 EQ (selection_name, QCLIPBOARD))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
52 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
53 int rawsize, size, i;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
54 unsigned char *src, *dst, *next;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
55 HGLOBAL h = NULL;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
56 struct frame *f = NULL;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
57 struct gcpro gcpro1, gcpro2;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
58 Lisp_Object string = XCDR (converted_value);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
59
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
60 GCPRO2 (converted_value, string);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
61
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
62 CHECK_STRING (string);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
63
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
64 /* Calculate size with LFs converted to CRLFs because
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
65 * CF_TEXT format uses CRLF delimited ASCIIZ */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
66 src = XSTRING_DATA (string);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
67 size = rawsize = XSTRING_LENGTH (string) + 1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
68 for (i=0; i<rawsize; i++)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
69 if (src[i] == '\n')
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
70 size++;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
71
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
72 f = selected_frame ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
73 if (!OpenClipboard (FRAME_MSWINDOWS_HANDLE (f)))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
74 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
75 UNGCPRO;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
76 return Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
77 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
78
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
79 /* This call to EmptyClipboard may post an event back to us if
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
80 we already own the clipboard (to tell us we lost it) and this
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
81 event may execute random lisp code. Hence we must protect
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
82 the string and get its address again after the call. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
83 if (!EmptyClipboard () ||
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
84 (h = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, size)) == NULL ||
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
85 (dst = (unsigned char *) GlobalLock (h)) == NULL)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
86 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
87 if (h != NULL) GlobalFree (h);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
88 CloseClipboard ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
89 UNGCPRO;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
90 return Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
91 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
92 src = XSTRING_DATA (string);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
93
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
94 /* Convert LFs to CRLFs */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
95 do
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
96 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
97 /* copy next line or remaining bytes including '\0' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
98 next = (char*) memccpy (dst, src, '\n', rawsize);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
99 if (next)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
100 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
101 /* copied one line ending with '\n' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
102 int copied = next - dst;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
103 rawsize -= copied;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
104 src += copied;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
105 /* insert '\r' before '\n' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
106 next[-1] = '\r';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
107 next[0] = '\n';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
108 dst = next+1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
109 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
110 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
111 while (next);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
112
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
113 GlobalUnlock (h);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
114
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
115 i = (SetClipboardData (CF_TEXT, h) != NULL);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
116
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
117 CloseClipboard ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
118
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
119 UNGCPRO;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
120 /* #### we are supposed to return a time! */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
121 /* return i ? Qt : Qnil; */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
122 return Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
123 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
124
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
125 return Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
126 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
127
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
128 static Lisp_Object
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
129 mswindows_get_foreign_selection (Lisp_Object selection_symbol,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
130 Lisp_Object target_type)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
131 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
132 if (EQ (selection_symbol, QCLIPBOARD))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
133 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
134 HANDLE h;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
135 unsigned char *src, *dst, *next;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
136 Lisp_Object ret = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
137
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
138 if (!OpenClipboard (NULL))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
139 return Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
140
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
141 if ((h = GetClipboardData (CF_TEXT)) != NULL &&
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
142 (src = (unsigned char *) GlobalLock (h)) != NULL)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
143 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
144 int i;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
145 int size, rawsize;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
146 size = rawsize = strlen (src);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
147
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
148 for (i=0; i<rawsize; i++)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
149 if (src[i] == '\r' && src[i+1] == '\n')
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
150 size--;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
151
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
152 /* Convert CRLFs to LFs */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
153 ret = make_uninit_string (size);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
154 dst = XSTRING_DATA (ret);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
155 do
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
156 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
157 /* copy next line or remaining bytes excluding '\0' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
158 next = (unsigned char *) memccpy (dst, src, '\r', rawsize);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
159 if (next)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
160 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
161 /* copied one line ending with '\r' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
162 int copied = next - dst;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
163 rawsize -= copied;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
164 src += copied;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
165 if (*src == '\n')
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
166 dst += copied - 1; /* overwrite '\r' */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
167 else
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
168 dst += copied;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
169 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
170 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
171 while (next);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
172
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
173 GlobalUnlock (h);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
174 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
175
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
176 CloseClipboard ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
177
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
178 return ret;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
179 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
180 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
181 return Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
182 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
183
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
184 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
185 mswindows_disown_selection (Lisp_Object selection, Lisp_Object timeval)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
186 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
187 if (EQ (selection, QCLIPBOARD))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
188 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
189 BOOL success = OpenClipboard (NULL);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
190 if (success)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
191 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
192 success = EmptyClipboard ();
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
193 /* Close it regardless of whether empty worked. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
194 if (!CloseClipboard ())
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
195 success = FALSE;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
196 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
197
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
198 /* #### return success ? Qt : Qnil; */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
199 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
200 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
201
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
202 static Lisp_Object
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
203 mswindows_selection_exists_p (Lisp_Object selection)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
204 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
205 if (EQ (selection, QCLIPBOARD))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
206 return IsClipboardFormatAvailable (CF_TEXT) ? Qt : Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
207 else
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
208 return Qnil;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 278
diff changeset
209 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 278
diff changeset
210
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
211
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
212 /************************************************************************/
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
213 /* initialization */
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
214 /************************************************************************/
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
215
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
216 void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
217 console_type_create_select_mswindows (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
218 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
219 CONSOLE_HAS_METHOD (mswindows, own_selection);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
220 CONSOLE_HAS_METHOD (mswindows, disown_selection);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
221 CONSOLE_HAS_METHOD (mswindows, selection_exists_p);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
222 CONSOLE_HAS_METHOD (mswindows, get_foreign_selection);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
223 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
224
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 288
diff changeset
225 void
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
226 syms_of_select_mswindows (void)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
227 {
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
228 }
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
229
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
230 void
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
231 vars_of_select_mswindows (void)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
232 {
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
233 }