Mercurial > emacs
annotate src/w32select.c @ 33426:62b21497a99f
(flyspell-mode-on): Only output welcome message if interactive.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 12 Nov 2000 13:23:23 +0000 |
parents | f390b90e3495 |
children | e7765cb122c3 |
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 */ |
31117
f390b90e3495
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
29332
diff
changeset
|
27 #include "keyboard.h" |
13434 | 28 #include "frame.h" /* Need this to get the X window of selected_frame */ |
29 #include "blockinput.h" | |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
30 #include "buffer.h" |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
31 #include "charset.h" |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
32 #include "coding.h" |
13434 | 33 |
15235 | 34 Lisp_Object QCLIPBOARD; |
35 | |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
36 /* 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
|
37 clipboard. */ |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
38 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
|
39 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
40 /* 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
|
41 static Lisp_Object Vnext_selection_coding_system; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
42 |
13434 | 43 #if 0 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
44 DEFUN ("w32-open-clipboard", Fw32_open_clipboard, Sw32_open_clipboard, 0, 1, 0, |
13434 | 45 "This opens the clipboard with the given frame pointer.") |
46 (frame) | |
47 Lisp_Object frame; | |
48 { | |
49 BOOL ok = FALSE; | |
50 | |
51 if (!NILP (frame)) | |
52 CHECK_LIVE_FRAME (frame, 0); | |
53 | |
54 BLOCK_INPUT; | |
55 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
56 ok = OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL); |
13434 | 57 |
58 UNBLOCK_INPUT; | |
59 | |
60 return (ok ? frame : Qnil); | |
61 } | |
62 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
63 DEFUN ("w32-empty-clipboard", Fw32_empty_clipboard, Sw32_empty_clipboard, 0, 0, 0, |
13434 | 64 "This empties the clipboard and assigns ownership to the window which opened the clipboard.") |
65 () | |
66 { | |
67 BOOL ok = FALSE; | |
68 | |
69 BLOCK_INPUT; | |
70 | |
71 ok = EmptyClipboard (); | |
72 | |
73 UNBLOCK_INPUT; | |
74 | |
75 return (ok ? Qt : Qnil); | |
76 } | |
77 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
78 DEFUN ("w32-close-clipboard", Fw32_close_clipboard, Sw32_close_clipboard, 0, 0, 0, |
13434 | 79 "This closes the clipboard.") |
80 () | |
81 { | |
82 BOOL ok = FALSE; | |
83 | |
84 BLOCK_INPUT; | |
85 | |
86 ok = CloseClipboard (); | |
87 | |
88 UNBLOCK_INPUT; | |
89 | |
90 return (ok ? Qt : Qnil); | |
91 } | |
92 | |
93 #endif | |
94 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
95 DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data, Sw32_set_clipboard_data, 1, 2, 0, |
13434 | 96 "This sets the clipboard data to the given text.") |
97 (string, frame) | |
98 Lisp_Object string, frame; | |
99 { | |
100 BOOL ok = TRUE; | |
101 HANDLE htext; | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
102 int nbytes; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
103 int truelen, nlines = 0; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
104 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
105 unsigned char *dst; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
106 |
13434 | 107 CHECK_STRING (string, 0); |
108 | |
109 if (!NILP (frame)) | |
110 CHECK_LIVE_FRAME (frame, 0); | |
111 | |
112 BLOCK_INPUT; | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
113 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
114 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
|
115 src = XSTRING (string)->data; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
116 dst = src; |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
117 |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
118 /* 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
|
119 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
|
120 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
|
121 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
|
122 { |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
123 nlines++; |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
124 dst++; |
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
125 } |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
126 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
127 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
128 /* 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
|
129 encoding text for the clipboard. */ |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
130 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
|
131 nbytes, NULL, Qnil); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
132 |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
133 if (charset_info == 0) |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
134 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
135 /* 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
|
136 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
137 /* 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
|
138 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
|
139 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
|
140 |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
141 truelen = nbytes + nlines; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
142 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
143 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
|
144 goto error; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
145 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
146 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
|
147 goto error; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
148 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
149 /* 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
|
150 while (1) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
151 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
152 unsigned char *next; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
153 /* 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
|
154 next = _memccpy (dst, src, '\n', nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
155 if (next) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
156 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
157 /* copied one line ending with '\n' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
158 int copied = next - dst; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
159 nbytes -= copied; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
160 src += copied; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
161 /* insert '\r' before '\n' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
162 next[-1] = '\r'; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
163 next[0] = '\n'; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
164 dst = next + 1; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
165 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
166 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
167 /* copied remaining partial line -> now finished */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
168 break; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
169 } |
13434 | 170 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
171 GlobalUnlock (htext); |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
172 |
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
173 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
|
174 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
175 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
176 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
177 /* 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
|
178 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
|
179 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
|
180 characters. */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
181 int bufsize; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
182 struct coding_system coding; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
183 HANDLE htext2; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
184 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
185 if (NILP (Vnext_selection_coding_system)) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
186 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
|
187 setup_coding_system |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
188 (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
|
189 coding.src_multibyte = 1; |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
190 coding.dst_multibyte = 0; |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
191 Vnext_selection_coding_system = Qnil; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
192 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
|
193 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
|
194 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
|
195 goto error; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
196 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
|
197 goto error; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
198 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
|
199 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
|
200 GlobalUnlock (htext); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
201 /* Shrink data block to actual size. */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
202 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
|
203 if (htext2 != NULL) htext = htext2; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
204 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
205 } |
13434 | 206 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
207 if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL)) |
13434 | 208 goto error; |
209 | |
210 ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext); | |
211 | |
212 CloseClipboard (); | |
213 | |
214 if (ok) goto done; | |
215 | |
216 error: | |
217 | |
218 ok = FALSE; | |
219 if (htext) GlobalFree (htext); | |
220 | |
221 done: | |
222 UNBLOCK_INPUT; | |
223 | |
224 return (ok ? string : Qnil); | |
225 } | |
226 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
227 DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data, Sw32_get_clipboard_data, 0, 1, 0, |
13434 | 228 "This gets the clipboard data in text format.") |
229 (frame) | |
230 Lisp_Object frame; | |
231 { | |
232 HANDLE htext; | |
233 Lisp_Object ret = Qnil; | |
234 | |
235 if (!NILP (frame)) | |
236 CHECK_LIVE_FRAME (frame, 0); | |
237 | |
238 BLOCK_INPUT; | |
239 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
240 if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL)) |
13434 | 241 goto done; |
242 | |
243 if ((htext = GetClipboardData (CF_TEXT)) == NULL) | |
244 goto closeclip; | |
245 | |
246 { | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
247 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
248 unsigned char *dst; |
13434 | 249 int nbytes; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
250 int truelen; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
251 int require_decoding = 0; |
13434 | 252 |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
253 if ((src = (unsigned char *) GlobalLock (htext)) == NULL) |
13434 | 254 goto closeclip; |
255 | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
256 nbytes = strlen (src); |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
257 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
258 if ( |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
259 #if 1 |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
260 1 |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
261 #else |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
262 ! NILP (buffer_defaults.enable_multibyte_characters) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
263 #endif |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
264 ) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
265 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
266 /* 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
|
267 need to decode it. */ |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
268 int i; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
269 |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
270 for (i = 0; i < nbytes; i++) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
271 { |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
272 if (src[i] >= 0x80) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
273 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
274 require_decoding = 1; |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
275 break; |
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 } |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
279 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
280 if (require_decoding) |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
281 { |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
282 int bufsize; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
283 unsigned char *buf; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
284 struct coding_system coding; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
285 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
286 if (NILP (Vnext_selection_coding_system)) |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
287 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
|
288 setup_coding_system |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
289 (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
|
290 coding.src_multibyte = 0; |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
291 coding.dst_multibyte = 1; |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
292 Vnext_selection_coding_system = Qnil; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
293 coding.mode |= CODING_MODE_LAST_BLOCK; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
294 bufsize = decoding_buffer_size (&coding, nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
295 buf = (unsigned char *) xmalloc (bufsize); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
296 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
|
297 Vlast_coding_system_used = coding.symbol; |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
298 ret = make_string_from_bytes ((char *) buf, |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
299 coding.produced_char, coding.produced); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
300 xfree (buf); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
301 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
302 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
303 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
304 /* 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
|
305 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
|
306 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
|
307 as part of CRLF. */ |
13434 | 308 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
309 truelen = nbytes; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
310 dst = src; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
311 /* 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
|
312 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
|
313 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
314 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
|
315 truelen--; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
316 dst++; |
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 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
319 ret = make_uninit_string (truelen); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
320 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
321 /* 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
|
322 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
|
323 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
324 dst = XSTRING (ret)->data; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
325 while (1) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
326 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
327 unsigned char *next; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
328 /* 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
|
329 next = _memccpy (dst, src, '\r', nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
330 if (next) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
331 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
332 /* copied one line ending with '\r' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
333 int copied = next - dst; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
334 nbytes -= copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
335 dst += copied; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
336 src += copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
337 if (*src == '\n') |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
338 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
|
339 } |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
340 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
341 /* copied remaining partial line -> now finished */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
342 break; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
343 } |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
344 |
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
345 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
|
346 } |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
347 |
13434 | 348 GlobalUnlock (htext); |
349 } | |
350 | |
351 closeclip: | |
352 CloseClipboard (); | |
353 | |
354 done: | |
355 UNBLOCK_INPUT; | |
356 | |
357 return (ret); | |
358 } | |
359 | |
15235 | 360 /* Support checking for a clipboard selection. */ |
361 | |
362 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p, | |
363 0, 1, 0, | |
364 "Whether there is an owner for the given X Selection.\n\ | |
365 The arg should be the name of the selection in question, typically one of\n\ | |
366 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\ | |
367 \(Those are literal upper-case symbol names, since that's what X expects.)\n\ | |
368 For convenience, the symbol nil is the same as `PRIMARY',\n\ | |
369 and t is the same as `SECONDARY'.") | |
370 (selection) | |
371 Lisp_Object selection; | |
372 { | |
373 CHECK_SYMBOL (selection, 0); | |
374 | |
375 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check | |
376 if the clipboard currently has valid text format contents. */ | |
377 | |
378 if (EQ (selection, QCLIPBOARD)) | |
379 { | |
380 Lisp_Object val = Qnil; | |
381 | |
382 if (OpenClipboard (NULL)) | |
383 { | |
384 int format = 0; | |
385 while (format = EnumClipboardFormats (format)) | |
386 if (format == CF_TEXT) | |
387 { | |
388 val = Qt; | |
389 break; | |
390 } | |
391 CloseClipboard (); | |
392 } | |
393 return val; | |
394 } | |
395 return Qnil; | |
396 } | |
397 | |
13434 | 398 void |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
399 syms_of_w32select () |
13434 | 400 { |
401 #if 0 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
402 defsubr (&Sw32_open_clipboard); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
403 defsubr (&Sw32_empty_clipboard); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
404 defsubr (&Sw32_close_clipboard); |
13434 | 405 #endif |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
406 defsubr (&Sw32_set_clipboard_data); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
407 defsubr (&Sw32_get_clipboard_data); |
15235 | 408 defsubr (&Sx_selection_exists_p); |
409 | |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
410 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
|
411 "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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
417 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
|
418 "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
|
419 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
|
420 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
|
421 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
|
422 set to nil."); |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
423 Vnext_selection_coding_system = Qnil; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
424 |
15235 | 425 QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); |
13434 | 426 } |