Mercurial > emacs
annotate src/w32select.c @ 29615:2a0aee2ed953
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Tue, 13 Jun 2000 13:16:43 +0000 |
parents | f2308eae15d7 |
children | f390b90e3495 |
rev | line source |
---|---|
16884
36babc489b0c
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
1 /* Selection processing for Emacs on the Microsoft W32 API. |
13434 | 2 Copyright (C) 1993, 1994 Free Software Foundation. |
3 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
4 This file is part of GNU Emacs. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
5 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
9 any later version. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
10 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
14 GNU General Public License for more details. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
15 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
13434 | 20 |
21 /* Written by Kevin Gallo */ | |
22 | |
23 #include <config.h> | |
24 #include "lisp.h" | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
25 #include "w32term.h" /* for all of the w32 includes */ |
13434 | 26 #include "dispextern.h" /* frame.h seems to want this */ |
27 #include "frame.h" /* Need this to get the X window of selected_frame */ | |
28 #include "blockinput.h" | |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
29 #include "buffer.h" |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
30 #include "charset.h" |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
31 #include "coding.h" |
13434 | 32 |
15235 | 33 Lisp_Object QCLIPBOARD; |
34 | |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
35 /* Coding system for communicating with other Windows programs via the |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
36 clipboard. */ |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
37 static Lisp_Object Vselection_coding_system; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
38 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
39 /* Coding system for the next communicating with other X clients. */ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
40 static Lisp_Object Vnext_selection_coding_system; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
41 |
13434 | 42 #if 0 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
43 DEFUN ("w32-open-clipboard", Fw32_open_clipboard, Sw32_open_clipboard, 0, 1, 0, |
13434 | 44 "This opens the clipboard with the given frame pointer.") |
45 (frame) | |
46 Lisp_Object frame; | |
47 { | |
48 BOOL ok = FALSE; | |
49 | |
50 if (!NILP (frame)) | |
51 CHECK_LIVE_FRAME (frame, 0); | |
52 | |
53 BLOCK_INPUT; | |
54 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
55 ok = OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL); |
13434 | 56 |
57 UNBLOCK_INPUT; | |
58 | |
59 return (ok ? frame : Qnil); | |
60 } | |
61 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
62 DEFUN ("w32-empty-clipboard", Fw32_empty_clipboard, Sw32_empty_clipboard, 0, 0, 0, |
13434 | 63 "This empties the clipboard and assigns ownership to the window which opened the clipboard.") |
64 () | |
65 { | |
66 BOOL ok = FALSE; | |
67 | |
68 BLOCK_INPUT; | |
69 | |
70 ok = EmptyClipboard (); | |
71 | |
72 UNBLOCK_INPUT; | |
73 | |
74 return (ok ? Qt : Qnil); | |
75 } | |
76 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
77 DEFUN ("w32-close-clipboard", Fw32_close_clipboard, Sw32_close_clipboard, 0, 0, 0, |
13434 | 78 "This closes the clipboard.") |
79 () | |
80 { | |
81 BOOL ok = FALSE; | |
82 | |
83 BLOCK_INPUT; | |
84 | |
85 ok = CloseClipboard (); | |
86 | |
87 UNBLOCK_INPUT; | |
88 | |
89 return (ok ? Qt : Qnil); | |
90 } | |
91 | |
92 #endif | |
93 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
94 DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, Sw32_set_clipboard_data, 1, 2, 0, |
13434 | 95 "This sets the clipboard data to the given text.") |
96 (string, frame) | |
97 Lisp_Object string, frame; | |
98 { | |
99 BOOL ok = TRUE; | |
100 HANDLE htext; | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
101 int nbytes; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
102 int truelen, nlines = 0; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
103 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
104 unsigned char *dst; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
105 |
13434 | 106 CHECK_STRING (string, 0); |
107 | |
108 if (!NILP (frame)) | |
109 CHECK_LIVE_FRAME (frame, 0); | |
110 | |
111 BLOCK_INPUT; | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
112 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
113 nbytes = STRING_BYTES (XSTRING (string)) + 1; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
114 src = XSTRING (string)->data; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
115 dst = src; |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
116 |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
117 /* We need to know how many lines there are, since we need CRLF line |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
118 termination for compatibility with other Windows Programs. |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
119 avoid using strchr because it recomputes the length every time */ |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
120 while ((dst = memchr (dst, '\n', nbytes - (dst - src))) != NULL) |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
121 { |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
122 nlines++; |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
123 dst++; |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
124 } |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
125 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
126 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
127 /* Since we are now handling multilingual text, we must consider |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
128 encoding text for the clipboard. */ |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
129 int charset_info = find_charset_in_text (src, XSTRING (string)->size, |
29332
f2308eae15d7
(Fw32_set_clipboard_data): Change QNil to Qnil.
Jason Rumney <jasonr@gnu.org>
parents:
29022
diff
changeset
|
130 nbytes, NULL, Qnil); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
131 |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
132 if (charset_info == 0) |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
133 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
134 /* No multibyte character in OBJ. We need not encode it. */ |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
135 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
136 /* Need to know final size after CR chars are inserted (the |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
137 standard CF_TEXT clipboard format uses CRLF line endings, |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
138 while Emacs uses just LF internally). */ |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
139 |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
140 truelen = nbytes + nlines; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
141 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
142 if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, truelen)) == NULL) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
143 goto error; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
144 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
145 if ((dst = (unsigned char *) GlobalLock (htext)) == NULL) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
146 goto error; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
147 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
148 /* convert to CRLF line endings expected by clipboard */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
149 while (1) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
150 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
151 unsigned char *next; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
152 /* copy next line or remaining bytes including '\0' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
153 next = _memccpy (dst, src, '\n', nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
154 if (next) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
155 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
156 /* copied one line ending with '\n' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
157 int copied = next - dst; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
158 nbytes -= copied; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
159 src += copied; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
160 /* insert '\r' before '\n' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
161 next[-1] = '\r'; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
162 next[0] = '\n'; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
163 dst = next + 1; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
164 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
165 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
166 /* copied remaining partial line -> now finished */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
167 break; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
168 } |
13434 | 169 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
170 GlobalUnlock (htext); |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
171 |
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
172 Vlast_coding_system_used = Qraw_text; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
173 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
174 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
175 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
176 /* We must encode contents of OBJ to compound text format. |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
177 The format is compatible with what the target `STRING' |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
178 expects if OBJ contains only ASCII and Latin-1 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
179 characters. */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
180 int bufsize; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
181 struct coding_system coding; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
182 HANDLE htext2; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
183 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
184 if (NILP (Vnext_selection_coding_system)) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
185 Vnext_selection_coding_system = Vselection_coding_system; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
186 setup_coding_system |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
187 (Fcheck_coding_system (Vnext_selection_coding_system), &coding); |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
188 coding.src_multibyte = 1; |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
189 coding.dst_multibyte = 0; |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
190 Vnext_selection_coding_system = Qnil; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
191 coding.mode |= CODING_MODE_LAST_BLOCK; |
24673
ea7d8435d078
(Fw32_set_clipboard_data): Undo last change to add
Andrew Innes <andrewi@gnu.org>
parents:
24518
diff
changeset
|
192 bufsize = encoding_buffer_size (&coding, nbytes); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
193 if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize)) == NULL) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
194 goto error; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
195 if ((dst = (unsigned char *) GlobalLock (htext)) == NULL) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
196 goto error; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
197 encode_coding (&coding, src, dst, nbytes, bufsize); |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
198 Vlast_coding_system_used = coding.symbol; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
199 GlobalUnlock (htext); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
200 /* Shrink data block to actual size. */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
201 htext2 = GlobalReAlloc (htext, coding.produced, GMEM_MOVEABLE | GMEM_DDESHARE); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
202 if (htext2 != NULL) htext = htext2; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
203 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
204 } |
13434 | 205 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
206 if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL)) |
13434 | 207 goto error; |
208 | |
209 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); | |
210 | |
211 CloseClipboard (); | |
212 | |
213 if (ok) goto done; | |
214 | |
215 error: | |
216 | |
217 ok = FALSE; | |
218 if (htext) GlobalFree (htext); | |
219 | |
220 done: | |
221 UNBLOCK_INPUT; | |
222 | |
223 return (ok ? string : Qnil); | |
224 } | |
225 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
226 DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, Sw32_get_clipboard_data, 0, 1, 0, |
13434 | 227 "This gets the clipboard data in text format.") |
228 (frame) | |
229 Lisp_Object frame; | |
230 { | |
231 HANDLE htext; | |
232 Lisp_Object ret = Qnil; | |
233 | |
234 if (!NILP (frame)) | |
235 CHECK_LIVE_FRAME (frame, 0); | |
236 | |
237 BLOCK_INPUT; | |
238 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
239 if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL)) |
13434 | 240 goto done; |
241 | |
242 if ((htext = GetClipboardData (CF_TEXT)) == NULL) | |
243 goto closeclip; | |
244 | |
245 { | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
246 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
247 unsigned char *dst; |
13434 | 248 int nbytes; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
249 int truelen; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
250 int require_decoding = 0; |
13434 | 251 |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
252 if ((src = (unsigned char *) GlobalLock (htext)) == NULL) |
13434 | 253 goto closeclip; |
254 | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
255 nbytes = strlen (src); |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
256 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
257 if ( |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
258 #if 1 |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
259 1 |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
260 #else |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
261 ! NILP (buffer_defaults.enable_multibyte_characters) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
262 #endif |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
263 ) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
264 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
265 /* If the clipboard data contains any non-ascii code, we |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
266 need to decode it. */ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
267 int i; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
268 |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
269 for (i = 0; i < nbytes; i++) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
270 { |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
271 if (src[i] >= 0x80) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
272 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
273 require_decoding = 1; |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
274 break; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
275 } |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
276 } |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
277 } |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
278 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
279 if (require_decoding) |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
280 { |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
281 int bufsize; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
282 unsigned char *buf; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
283 struct coding_system coding; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
284 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
285 if (NILP (Vnext_selection_coding_system)) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
286 Vnext_selection_coding_system = Vselection_coding_system; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
287 setup_coding_system |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
288 (Fcheck_coding_system (Vnext_selection_coding_system), &coding); |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
289 coding.src_multibyte = 0; |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
290 coding.dst_multibyte = 1; |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
291 Vnext_selection_coding_system = Qnil; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
292 coding.mode |= CODING_MODE_LAST_BLOCK; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
293 bufsize = decoding_buffer_size (&coding, nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
294 buf = (unsigned char *) xmalloc (bufsize); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
295 decode_coding (&coding, src, buf, nbytes, bufsize); |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
296 Vlast_coding_system_used = coding.symbol; |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
297 ret = make_string_from_bytes ((char *) buf, |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
298 coding.produced_char, coding.produced); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
299 xfree (buf); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
300 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
301 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
302 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
303 /* Need to know final size after CR chars are removed because we |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
304 can't change the string size manually, and doing an extra |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
305 copy is silly. Note that we only remove CR when it appears |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
306 as part of CRLF. */ |
13434 | 307 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
308 truelen = nbytes; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
309 dst = src; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
310 /* avoid using strchr because it recomputes the length everytime */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
311 while ((dst = memchr (dst, '\r', nbytes - (dst - src))) != NULL) |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
312 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
313 if (dst[1] == '\n') /* safe because of trailing '\0' */ |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
314 truelen--; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
315 dst++; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
316 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
317 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
318 ret = make_uninit_string (truelen); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
319 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
320 /* Convert CRLF line endings (the standard CF_TEXT clipboard |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
321 format) to LF endings as used internally by Emacs. */ |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
322 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
323 dst = XSTRING (ret)->data; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
324 while (1) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
325 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
326 unsigned char *next; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
327 /* copy next line or remaining bytes excluding '\0' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
328 next = _memccpy (dst, src, '\r', nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
329 if (next) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
330 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
331 /* copied one line ending with '\r' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
332 int copied = next - dst; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
333 nbytes -= copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
334 dst += copied; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
335 src += copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
336 if (*src == '\n') |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
337 dst--; /* overwrite '\r' with '\n' */ |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
338 } |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
339 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
340 /* copied remaining partial line -> now finished */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
341 break; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
342 } |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
343 |
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
344 Vlast_coding_system_used = Qraw_text; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
345 } |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
346 |
13434 | 347 GlobalUnlock (htext); |
348 } | |
349 | |
350 closeclip: | |
351 CloseClipboard (); | |
352 | |
353 done: | |
354 UNBLOCK_INPUT; | |
355 | |
356 return (ret); | |
357 } | |
358 | |
15235 | 359 /* Support checking for a clipboard selection. */ |
360 | |
361 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p, | |
362 0, 1, 0, | |
363 "Whether there is an owner for the given X Selection.\n\ | |
364 The arg should be the name of the selection in question, typically one of\n\ | |
365 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\ | |
366 \(Those are literal upper-case symbol names, since that's what X expects.)\n\ | |
367 For convenience, the symbol nil is the same as `PRIMARY',\n\ | |
368 and t is the same as `SECONDARY'.") | |
369 (selection) | |
370 Lisp_Object selection; | |
371 { | |
372 CHECK_SYMBOL (selection, 0); | |
373 | |
374 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check | |
375 if the clipboard currently has valid text format contents. */ | |
376 | |
377 if (EQ (selection, QCLIPBOARD)) | |
378 { | |
379 Lisp_Object val = Qnil; | |
380 | |
381 if (OpenClipboard (NULL)) | |
382 { | |
383 int format = 0; | |
384 while (format = EnumClipboardFormats (format)) | |
385 if (format == CF_TEXT) | |
386 { | |
387 val = Qt; | |
388 break; | |
389 } | |
390 CloseClipboard (); | |
391 } | |
392 return val; | |
393 } | |
394 return Qnil; | |
395 } | |
396 | |
13434 | 397 void |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
398 syms_of_w32select () |
13434 | 399 { |
400 #if 0 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
401 defsubr (&Sw32_open_clipboard); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
402 defsubr (&Sw32_empty_clipboard); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
403 defsubr (&Sw32_close_clipboard); |
13434 | 404 #endif |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
405 defsubr (&Sw32_set_clipboard_data); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
406 defsubr (&Sw32_get_clipboard_data); |
15235 | 407 defsubr (&Sx_selection_exists_p); |
408 | |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
409 DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system, |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
410 "Coding system for communicating with other X clients.\n\ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
411 When sending or receiving text via cut_buffer, selection, and clipboard,\n\ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
412 the text is encoded or decoded by this coding system.\n\ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
413 A default value is `compound-text'"); |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
414 Vselection_coding_system=intern ("iso-latin-1-dos"); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
415 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
416 DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system, |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
417 "Coding system for the next communication with other X clients.\n\ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
418 Usually, `selection-coding-system' is used for communicating with\n\ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
419 other X clients. But, if this variable is set, it is used for the\n\ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
420 next communication only. After the communication, this variable is\n\ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
421 set to nil."); |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
422 Vnext_selection_coding_system = Qnil; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
423 |
15235 | 424 QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); |
13434 | 425 } |