annotate src/w32select.c @ 13544:34c4ee840e09

(nt): Rename install, readme, and todo to INSTALL, README, and TODO.
author Geoff Voelker <voelker@cs.washington.edu>
date Tue, 14 Nov 1995 19:41:16 +0000
parents 53ba95a88cf2
children ee40177f6c68
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1 /* Win32 Selection processing for emacs
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4 This file is part of GNU Emacs.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
9 any later version.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
10
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
14 GNU General Public License for more details.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
15
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
19
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
20 /* Written by Kevin Gallo */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
21
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
22 #include <config.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
23 #include "lisp.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
24 #include "w32term.h" /* for all of the win32 includes */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
25 #include "dispextern.h" /* frame.h seems to want this */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
26 #include "frame.h" /* Need this to get the X window of selected_frame */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
27 #include "blockinput.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
28
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
29 #if 0
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
30 DEFUN ("win32-open-clipboard", Fwin32_open_clipboard, Swin32_open_clipboard, 0, 1, 0,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
31 "This opens the clipboard with the given frame pointer.")
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
32 (frame)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
33 Lisp_Object frame;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
34 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
35 BOOL ok = FALSE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
36
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
37 if (!NILP (frame))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
38 CHECK_LIVE_FRAME (frame, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
39
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
40 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
41
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
42 ok = OpenClipboard ((!NILP (frame) && FRAME_WIN32_P (XFRAME (frame))) ? FRAME_WIN32_WINDOW (XFRAME (frame)) : NULL);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
43
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
44 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
45
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
46 return (ok ? frame : Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
47 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
48
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
49 DEFUN ("win32-empty-clipboard", Fwin32_empty_clipboard, Swin32_empty_clipboard, 0, 0, 0,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
50 "This empties the clipboard and assigns ownership to the window which opened the clipboard.")
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
51 ()
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
52 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
53 BOOL ok = FALSE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
54
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
55 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
56
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
57 ok = EmptyClipboard ();
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
58
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
59 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
60
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
61 return (ok ? Qt : Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
62 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
63
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
64 DEFUN ("win32-close-clipboard", Fwin32_close_clipboard, Swin32_close_clipboard, 0, 0, 0,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
65 "This closes the clipboard.")
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
66 ()
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
67 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
68 BOOL ok = FALSE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
69
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
70 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
71
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
72 ok = CloseClipboard ();
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
73
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
74 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
75
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
76 return (ok ? Qt : Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
77 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
78
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
79 #endif
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
80
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
81 DEFUN ("win32-set-clipboard-data", Fwin32_set_clipboard_data, Swin32_set_clipboard_data, 1, 2, 0,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
82 "This sets the clipboard data to the given text.")
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
83 (string, frame)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
84 Lisp_Object string, frame;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
85 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
86 BOOL ok = TRUE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
87 HANDLE htext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
88
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
89 CHECK_STRING (string, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
90
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
91 if (!NILP (frame))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
92 CHECK_LIVE_FRAME (frame, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
93
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
94 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
95
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
96 /* Allocate twice the amount so we can convert lf to cr-lf */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
97
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
98 if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, (2 * XSTRING (string)->size) + 1)) == NULL)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
99 goto error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
100
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
101 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
102 unsigned char *lptext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
103
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
104 if ((lptext = (unsigned char *)GlobalLock (htext)) == NULL)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
105 goto error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
106
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
107 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
108 int i = XSTRING (string)->size;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
109 int newsize = XSTRING (string)->size;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
110 register char *p1 = XSTRING (string)->data;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
111 register char *p2 = lptext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
112
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
113 while (i--)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
114 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
115 if (*p1 == '\n')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
116 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
117 newsize++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
118 *p2++ = '\r';
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
119 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
120
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
121 *p2++ = *p1++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
122 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
123
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
124 *p2 = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
125 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
126
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
127 GlobalUnlock (htext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
128 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
129
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
130 if (!OpenClipboard ((!NILP (frame) && FRAME_WIN32_P (XFRAME (frame))) ? FRAME_WIN32_WINDOW (XFRAME (frame)) : NULL))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
131 goto error;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
132
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
133 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
134
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
135 CloseClipboard ();
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
136
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
137 if (ok) goto done;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
138
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
139 error:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
140
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
141 ok = FALSE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
142 if (htext) GlobalFree (htext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
143
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
144 done:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
145 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
146
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
147 return (ok ? string : Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
148 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
149
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
150 DEFUN ("win32-get-clipboard-data", Fwin32_get_clipboard_data, Swin32_get_clipboard_data, 0, 1, 0,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
151 "This gets the clipboard data in text format.")
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
152 (frame)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
153 Lisp_Object frame;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
154 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
155 HANDLE htext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
156 Lisp_Object ret = Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
157
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
158 if (!NILP (frame))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
159 CHECK_LIVE_FRAME (frame, 0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
160
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
161 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
162
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
163 if (!OpenClipboard ((!NILP (frame) && FRAME_WIN32_P (XFRAME (frame))) ? FRAME_WIN32_WINDOW (XFRAME (frame)) : NULL))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
164 goto done;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
165
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
166 if ((htext = GetClipboardData (CF_TEXT)) == NULL)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
167 goto closeclip;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
168
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
169
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
170 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
171 unsigned char *lptext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
172 int nbytes;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
173
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
174 if ((lptext = (unsigned char *)GlobalLock (htext)) == NULL)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
175 goto closeclip;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
176
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
177 nbytes = strlen (lptext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
178
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
179 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
180 char *buf = (char *) xmalloc (nbytes);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
181 register char *p1 = lptext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
182 register char *p2 = buf;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
183 int i = nbytes;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
184
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
185 if (buf == NULL) goto closeclip;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
186
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
187 while (i--)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
188 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
189 if (p1[0] == '\r' && i && p1[1] == '\n')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
190 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
191 p1++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
192 i--;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
193 nbytes--;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
194 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
195
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
196 *p2++ = *p1++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
197 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
198
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
199 ret = make_string (buf, nbytes);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
200
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
201 xfree (buf);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
202 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
203
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
204 GlobalUnlock (htext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
205 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
206
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
207 closeclip:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
208 CloseClipboard ();
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
209
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
210 done:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
211 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
212
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
213 return (ret);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
214 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
215
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
216 void
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
217 syms_of_win32select ()
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
218 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
219 #if 0
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
220 defsubr (&Swin32_open_clipboard);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
221 defsubr (&Swin32_empty_clipboard);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
222 defsubr (&Swin32_close_clipboard);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
223 #endif
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
224 defsubr (&Swin32_set_clipboard_data);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
225 defsubr (&Swin32_get_clipboard_data);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
226 }