annotate src/w32select.c @ 110637:494ea2fb03d7

Remove Emacs 21 stuff. mm-util.el (mm-codepage-iso-8859-list, mm-charset-eval-alist, mm-mime-charset): Comment fix. rfc2047.el (rfc2047-syntax-table): Comment fix. utf7.el (utf7-utf-16-coding-system): Comment fix. nnrss.el (nnrss-read-server-data, nnrss-read-group-data): Use `load' rather than `insert-file-contents' and `eval-region'. pgg.el (pgg-run-at-time-1): Define it for XEmacs only; fix if/else construction. time-date.el: No need to require cl for Emacs 21.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Wed, 29 Sep 2010 01:09:50 +0000
parents 228a5fa4eda0
children b8fde5ef9e14
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
75227
e90d04cd455a Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
2 Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
3 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
4
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
5 This file is part of GNU Emacs.
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
6
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91327
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
8 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91327
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91327
diff changeset
10 (at your option) any later version.
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
11
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
12 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
13 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
14 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
15 GNU General Public License for more details.
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
16
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
17 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91327
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
19
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
20 /* Written by Kevin Gallo, Benjamin Riefenstahl */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
21
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
22
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
23 /*
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
24 * Notes on usage of selection-coding-system and
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
25 * next-selection-coding-system on MS Windows:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
26 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
27 * The selection coding system variables apply only to the version of
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
28 * the clipboard data that is closest in type, i.e. when a 16-bit
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
29 * Unicode coding system is given, they apply to he Unicode clipboard
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
30 * (CF_UNICODETEXT), when a well-known console codepage is given, they
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
31 * apply to the console version of the clipboard data (CF_OEMTEXT),
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
32 * else they apply to the normal 8-bit text clipboard (CF_TEXT).
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
33 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
34 * When pasting (getting data from the OS), the clipboard format that
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
35 * matches the {next-}selection-coding-system is retrieved. If
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
36 * Unicode is requested, but not available, 8-bit text (CF_TEXT) is
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
37 * used. In all other cases the OS will transparently convert
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
38 * formats, so no other fallback is needed.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
39 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
40 * When copying or cutting (sending data to the OS), the data is
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
41 * announced and stored internally, but only actually rendered on
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
42 * request. The requester determines the format provided. The
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
43 * {next-}selection-coding-system is only used, when its corresponding
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
44 * clipboard type matches the type requested.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
45 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
46 * Scenarios to use the facilities for customizing the selection
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
47 * coding system are:
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
48 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
49 * ;; Generally use KOI8-R instead of the russian MS codepage for
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
50 * ;; the 8-bit clipboard.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
51 * (set-selection-coding-system 'koi8-r-dos)
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
52 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
53 * Or
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
54 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
55 * ;; Create a special clipboard copy function that uses codepage
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
56 * ;; 1253 (Greek) to copy Greek text to a specific non-Unicode
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
57 * ;; application.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
58 * (defun greek-copy (beg end)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
59 * (interactive "r")
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
60 * (set-next-selection-coding-system 'cp1253-dos)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
61 * (copy-region-as-kill beg end))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
62 * (global-set-key "\C-c\C-c" 'greek-copy)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
63 */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
64
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
65 /*
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
66 * Ideas for further directions:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
67 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
68 * The encoding and decoding routines could be moved to Lisp code
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
69 * similar to how xselect.c does it (using well-known routine names
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
70 * for the delayed rendering). If the definition of which clipboard
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
71 * types should be supported is also moved to Lisp, functionality
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
72 * could be expanded to CF_HTML, CF_RTF and maybe other types.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
73 */
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
74
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
75 #include <config.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100951
diff changeset
76 #include <setjmp.h>
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
77 #include "lisp.h"
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15235
diff changeset
78 #include "w32term.h" /* for all of the w32 includes */
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
79 #include "w32heap.h" /* os_subtype */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
80 #include "blockinput.h"
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
81 #include "keyboard.h" /* cmd_error_internal() */
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
82 #include "charset.h"
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
83 #include "coding.h"
90930
218b1814ca2e Include character.h
Jason Rumney <jasonr@gnu.org>
parents: 90922
diff changeset
84 #include "character.h"
45988
37913830a881 Include composite.h
Juanma Barranquero <lekktu@gmail.com>
parents: 45984
diff changeset
85 #include "composite.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
86
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
87
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
88 static HGLOBAL convert_to_handle_as_ascii (void);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
89 static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
90 static Lisp_Object render (Lisp_Object oformat);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
91 static Lisp_Object render_locale (void);
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
92 static Lisp_Object render_all (Lisp_Object ignore);
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
93 static void run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
94 static Lisp_Object lisp_error_handler (Lisp_Object error);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
95 static LRESULT CALLBACK owner_callback (HWND win, UINT msg,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
96 WPARAM wp, LPARAM lp);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
97 static HWND create_owner (void);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
98
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
99 static void setup_config (void);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
100 static BOOL WINAPI enum_locale_callback (/*const*/ char* loc_string);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
101 static UINT cp_from_locale (LCID lcid, UINT format);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
102 static Lisp_Object coding_from_cp (UINT codepage);
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
103 static Lisp_Object validate_coding_system (Lisp_Object coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
104 static void setup_windows_coding_system (Lisp_Object coding_system,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
105 struct coding_system * coding);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
106
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
107
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
108 /* A remnant from X11: Symbol for the CLIPBORD selection type. Other
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
109 selections are not used on Windows, so we don't need symbols for
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
110 PRIMARY and SECONDARY. */
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
111 Lisp_Object QCLIPBOARD;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
112
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
113 /* Coding system for communicating with other programs via the
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
114 clipboard. */
22914
4d4e775cf6f7 (Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents: 22745
diff changeset
115 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
116
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
117 /* Coding system for the next communication with other programs. */
23562
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
118 static Lisp_Object Vnext_selection_coding_system;
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
119
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
120 /* Internal pseudo-constants, initialized in globals_of_w32select()
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
121 based on current system parameters. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
122 static LCID DEFAULT_LCID;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
123 static UINT ANSICP, OEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
124 static Lisp_Object QUNICODE, QANSICP, QOEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
125
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
126 /* A hidden window just for the clipboard management. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
127 static HWND clipboard_owner;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
128 /* A flag to tell WM_DESTROYCLIPBOARD who is to blame this time (just
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
129 checking GetClipboardOwner() doesn't work, sadly). */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
130 static int modifying_clipboard = 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
131
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
132 /* Configured transfer parameters, based on the last inspection of
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
133 selection-coding-system. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
134 static Lisp_Object cfg_coding_system;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
135 static UINT cfg_codepage;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
136 static LCID cfg_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
137 static UINT cfg_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
138
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
139 /* The current state for delayed rendering. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
140 static Lisp_Object current_text;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
141 static Lisp_Object current_coding_system;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
142 static int current_requires_encoding, current_num_nls;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
143 static UINT current_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
144 static LCID current_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
145
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
146 #if TRACE
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
147 #define ONTRACE(stmt) stmt
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
148 #else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
149 #define ONTRACE(stmt) /*stmt*/
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
150 #endif
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
151
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
152
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
153 /* This function assumes that there is no multibyte character in
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
154 current_text, so we can short-cut encoding. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
155
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
156 static HGLOBAL
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
157 convert_to_handle_as_ascii (void)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
158 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
159 HGLOBAL htext = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
160 int nbytes;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
161 int truelen;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
162 unsigned char *src;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
163 unsigned char *dst;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
164
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
165 ONTRACE (fprintf (stderr, "convert_to_handle_as_ascii\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
166
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
167 nbytes = SBYTES (current_text) + 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
168 src = SDATA (current_text);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
169
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
170 /* We need to add to the size the number of LF chars where we have
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
171 to insert CR chars (the standard CF_TEXT clipboard format uses
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
172 CRLF line endings, while Emacs uses just LF internally). */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
173
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
174 truelen = nbytes + current_num_nls;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
175
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
176 if ((htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, truelen)) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
177 return NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
178
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
179 if ((dst = (unsigned char *) GlobalLock (htext)) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
180 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
181 GlobalFree (htext);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
182 return NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
183 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
184
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
185 /* convert to CRLF line endings expected by clipboard */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
186 while (1)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
187 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
188 unsigned char *next;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
189 /* copy next line or remaining bytes including '\0' */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
190 next = _memccpy (dst, src, '\n', nbytes);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
191 if (next)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
192 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
193 /* copied one line ending with '\n' */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
194 int copied = next - dst;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
195 nbytes -= copied;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
196 src += copied;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
197 /* insert '\r' before '\n' */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
198 next[-1] = '\r';
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
199 next[0] = '\n';
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
200 dst = next + 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
201 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
202 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
203 /* copied remaining partial line -> now finished */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
204 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
205 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
206
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
207 GlobalUnlock (htext);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
208
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
209 return htext;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
210 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
211
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
212 /* This function assumes that there are multibyte or NUL characters in
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
213 current_text, or that we need to construct Unicode. It runs the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
214 text through the encoding machinery. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
215
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
216 static HGLOBAL
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
217 convert_to_handle_as_coded (Lisp_Object coding_system)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
218 {
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
219 HGLOBAL htext;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
220 unsigned char *dst = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
221 struct coding_system coding;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
222
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
223 ONTRACE (fprintf (stderr, "convert_to_handle_as_coded: %s\n",
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
224 SDATA (SYMBOL_NAME (coding_system))));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
225
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
226 setup_windows_coding_system (coding_system, &coding);
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
227 coding.dst_bytes = SBYTES (current_text) * 2;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
228 coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
229 encode_coding_object (&coding, current_text, 0, 0,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
230 SCHARS (current_text), SBYTES (current_text), Qnil);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
231
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
232 htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, coding.produced +2);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
233
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
234 if (htext != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
235 dst = (unsigned char *) GlobalLock (htext);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
236
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
237 if (dst != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
238 {
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
239 memcpy (dst, coding.destination, coding.produced);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
240 /* Add the string terminator. Add two NULs in case we are
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
241 producing Unicode here. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
242 dst[coding.produced] = dst[coding.produced+1] = '\0';
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
243
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
244 GlobalUnlock (htext);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
245 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
246
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
247 xfree (coding.destination);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
248
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
249 return htext;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
250 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
251
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
252 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
253 render (Lisp_Object oformat)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
254 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
255 HGLOBAL htext = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
256 UINT format = XFASTINT (oformat);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
257
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
258 ONTRACE (fprintf (stderr, "render\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
259
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
260 if (NILP (current_text))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
261 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
262
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
263 if (current_requires_encoding || format == CF_UNICODETEXT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
264 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
265 if (format == current_clipboard_type)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
266 htext = convert_to_handle_as_coded (current_coding_system);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
267 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
268 switch (format)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
269 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
270 case CF_UNICODETEXT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
271 htext = convert_to_handle_as_coded (QUNICODE);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
272 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
273 case CF_TEXT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
274 case CF_OEMTEXT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
275 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
276 Lisp_Object cs;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
277 cs = coding_from_cp (cp_from_locale (current_lcid, format));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
278 htext = convert_to_handle_as_coded (cs);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
279 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
280 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
281 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
282 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
283 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
284 htext = convert_to_handle_as_ascii ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
285
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
286 ONTRACE (fprintf (stderr, "render: htext = 0x%08X\n", (unsigned) htext));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
287
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
288 if (htext == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
289 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
290
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
291 if (SetClipboardData (format, htext) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
292 {
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
293 GlobalFree (htext);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
294 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
295 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
296
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
297 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
298 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
299
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
300 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
301 render_locale (void)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
302 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
303 HANDLE hlocale = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
304 LCID * lcid_ptr;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
305
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
306 ONTRACE (fprintf (stderr, "render_locale\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
307
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
308 if (current_lcid == LOCALE_NEUTRAL || current_lcid == DEFAULT_LCID)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
309 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
310
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
311 hlocale = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, sizeof (current_lcid));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
312 if (hlocale == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
313 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
314
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
315 if ((lcid_ptr = (LCID *) GlobalLock (hlocale)) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
316 {
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
317 GlobalFree (hlocale);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
318 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
319 }
33697
e7765cb122c3 (Fw32_set_clipboard_data): Save a copy of what is put on the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 31117
diff changeset
320
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
321 *lcid_ptr = current_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
322 GlobalUnlock (hlocale);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
323
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
324 if (SetClipboardData (CF_LOCALE, hlocale) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
325 {
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
326 GlobalFree (hlocale);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
327 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
328 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
329
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
330 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
331 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
332
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
333 /* At the end of the program, we want to ensure that our clipboard
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
334 data survives us. This code will do that. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
335
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
336 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
337 render_all (Lisp_Object ignore)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
338 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
339 ONTRACE (fprintf (stderr, "render_all\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
340
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
341 /* According to the docs we should not call OpenClipboard() here,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
342 but testing on W2K and working code in other projects shows that
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
343 it is actually necessary. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
344
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
345 OpenClipboard (NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
346
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
347 /* There is no usefull means to report errors here, there are none
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
348 expected anyway, and even if there were errors, they wouldn't do
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
349 any harm. So we just go ahead and do what has to be done without
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
350 bothering with error handling. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
351
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
352 ++modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
353 EmptyClipboard ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
354 --modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
355
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
356 /* For text formats that we don't render here, the OS can use its
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
357 own translation rules instead, so we don't really need to offer
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
358 everything. To minimize memory consumption we cover three
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
359 possible situations based on our primary format as detected from
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
360 selection-coding-system (see setup_config()):
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
361
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
362 - Post CF_TEXT only. Let the OS convert to CF_OEMTEXT and the OS
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
363 (on NT) or the application (on 9x/Me) convert to
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
364 CF_UNICODETEXT.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
365
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
366 - Post CF_OEMTEXT only. Similar automatic conversions happen as
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
367 for CF_TEXT.
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
368
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
369 - Post CF_UNICODETEXT + CF_TEXT. 9x itself ignores
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
370 CF_UNICODETEXT, even though some applications can still handle
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
371 it.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
372
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
373 Note 1: We render the less capable CF_TEXT *before* the more
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
374 capable CF_UNICODETEXT, to prevent clobbering through automatic
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
375 conversions, just in case.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
376
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
377 Note 2: We could check os_subtype here and only render the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
378 additional CF_TEXT on 9x/Me. But OTOH with
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
379 current_clipboard_type == CF_UNICODETEXT we don't involve the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
380 automatic conversions anywhere else, so to get consistent
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
381 results, we probably don't want to rely on it here either. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
382
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
383 render_locale ();
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
384
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
385 if (current_clipboard_type == CF_UNICODETEXT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
386 render (make_number (CF_TEXT));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
387 render (make_number (current_clipboard_type));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
388
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
389 CloseClipboard ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
390
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
391 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
392 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
393
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
394 static void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
395 run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg)
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
396 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
397 /* FIXME: This works but it doesn't feel right. Too much fiddling
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
398 with global variables and calling strange looking functions. Is
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
399 this really the right way to run Lisp callbacks? */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
400
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
401 int owfi;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
402
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
403 BLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
404
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
405 /* Fsignal calls abort() if it sees that waiting_for_input is
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
406 set. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
407 owfi = waiting_for_input;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
408 waiting_for_input = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
409
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
410 internal_condition_case_1 (code, arg, Qt, lisp_error_handler);
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
411
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
412 waiting_for_input = owfi;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
413
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
414 UNBLOCK_INPUT;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
415 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
416
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
417 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
418 lisp_error_handler (Lisp_Object error)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
419 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
420 Vsignaling_function = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
421 cmd_error_internal (error, "Error in delayed clipboard rendering: ");
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
422 Vinhibit_quit = Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
423 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
424 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
425
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
426
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
427 static LRESULT CALLBACK
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
428 owner_callback (HWND win, UINT msg, WPARAM wp, LPARAM lp)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
429 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
430 switch (msg)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
431 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
432 case WM_RENDERFORMAT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
433 ONTRACE (fprintf (stderr, "WM_RENDERFORMAT\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
434 run_protected (render, make_number (wp));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
435 return 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
436
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
437 case WM_RENDERALLFORMATS:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
438 ONTRACE (fprintf (stderr, "WM_RENDERALLFORMATS\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
439 run_protected (render_all, Qnil);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
440 return 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
441
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
442 case WM_DESTROYCLIPBOARD:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
443 if (!modifying_clipboard)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
444 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
445 ONTRACE (fprintf (stderr, "WM_DESTROYCLIPBOARD (other)\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
446 current_text = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
447 current_coding_system = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
448 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
449 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
450 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
451 ONTRACE (fprintf (stderr, "WM_DESTROYCLIPBOARD (self)\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
452 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
453 return 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
454
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
455 case WM_DESTROY:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
456 if (win == clipboard_owner)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
457 clipboard_owner = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
458 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
459 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
460
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
461 return DefWindowProc (win, msg, wp, lp);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
462 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
463
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
464 static HWND
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
465 create_owner (void)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
466 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
467 static const char CLASSNAME[] = "Emacs Clipboard";
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
468 WNDCLASS wc;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
469
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
470 memset (&wc, 0, sizeof (wc));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
471 wc.lpszClassName = CLASSNAME;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
472 wc.lpfnWndProc = owner_callback;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
473 RegisterClass (&wc);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
474
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
475 return CreateWindow (CLASSNAME, CLASSNAME, 0, 0, 0, 0, 0, NULL, NULL,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
476 NULL, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
477 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
478
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
479 /* Called on exit by term_ntproc() in w32.c */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
480
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
481 void
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
482 term_w32select (void)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
483 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
484 /* This is needed to trigger WM_RENDERALLFORMATS. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
485 if (clipboard_owner != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
486 DestroyWindow (clipboard_owner);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
487 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
488
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
489 static void
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
490 setup_config (void)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
491 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
492 const char *coding_name;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
493 const char *cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
494 char *end;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
495 int slen;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
496 Lisp_Object coding_system;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
497 Lisp_Object dos_coding_system;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
498
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
499 CHECK_SYMBOL (Vselection_coding_system);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
500
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
501 coding_system = NILP (Vnext_selection_coding_system) ?
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
502 Vselection_coding_system : Vnext_selection_coding_system;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
503
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
504 dos_coding_system = validate_coding_system (coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
505 if (NILP (dos_coding_system))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
506 Fsignal (Qerror,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
507 list2 (build_string ("Coding system is invalid or doesn't have "
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
508 "an eol variant for dos line ends"),
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
509 coding_system));
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
510
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
511 /* Check if we have it cached */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
512 if (!NILP (cfg_coding_system)
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
513 && EQ (cfg_coding_system, dos_coding_system))
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
514 return;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
515 cfg_coding_system = dos_coding_system;
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
516
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
517 /* Set some sensible fallbacks */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
518 cfg_codepage = ANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
519 cfg_lcid = LOCALE_NEUTRAL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
520 cfg_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
521
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
522 /* Interpret the coding system symbol name */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
523 coding_name = SDATA (SYMBOL_NAME (cfg_coding_system));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
524
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
525 /* "(.*-)?utf-16.*" -> CF_UNICODETEXT */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
526 cp = strstr (coding_name, "utf-16");
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
527 if (cp != NULL && (cp == coding_name || cp[-1] == '-'))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
528 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
529 cfg_clipboard_type = CF_UNICODETEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
530 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
531 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
532
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
533 /* "cp[0-9]+.*" or "windows-[0-9]+.*" -> CF_TEXT or CF_OEMTEXT */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
534 slen = strlen (coding_name);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
535 if (slen >= 4 && coding_name[0] == 'c' && coding_name[1] == 'p')
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
536 cp = coding_name + 2;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
537 else if (slen >= 10 && memcmp (coding_name, "windows-", 8) == 0)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
538 cp = coding_name + 8;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
539 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
540 return;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
541
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
542 end = (char*)cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
543 cfg_codepage = strtol (cp, &end, 10);
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
544
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
545 /* Error return from strtol() or number of digits < 2 -> Restore the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
546 default and drop it. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
547 if (cfg_codepage == 0 || (end-cp) < 2 )
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
548 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
549 cfg_codepage = ANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
550 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
551 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
552
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
553 /* Is it the currently active system default? */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
554 if (cfg_codepage == ANSICP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
555 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
556 /* cfg_clipboard_type = CF_TEXT; */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
557 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
558 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
559 if (cfg_codepage == OEMCP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
560 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
561 cfg_clipboard_type = CF_OEMTEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
562 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
563 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
564
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
565 /* Else determine a suitable locale the hard way. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
566 EnumSystemLocales (enum_locale_callback, LCID_INSTALLED);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
567 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
568
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
569 static BOOL WINAPI
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
570 enum_locale_callback (/*const*/ char* loc_string)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
571 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
572 LCID lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
573 UINT codepage;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
574
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
575 lcid = strtoul (loc_string, NULL, 16);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
576
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
577 /* Is the wanted codepage the "ANSI" codepage for this locale? */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
578 codepage = cp_from_locale (lcid, CF_TEXT);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
579 if (codepage == cfg_codepage)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
580 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
581 cfg_lcid = lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
582 cfg_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
583 return FALSE; /* Stop enumeration */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
584 }
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
585
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
586 /* Is the wanted codepage the OEM codepage for this locale? */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
587 codepage = cp_from_locale (lcid, CF_OEMTEXT);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
588 if (codepage == cfg_codepage)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
589 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
590 cfg_lcid = lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
591 cfg_clipboard_type = CF_OEMTEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
592 return FALSE; /* Stop enumeration */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
593 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
594
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
595 return TRUE; /* Continue enumeration */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
596 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
597
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
598 static UINT
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
599 cp_from_locale (LCID lcid, UINT format)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
600 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
601 char buffer[20] = "";
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
602 UINT variant, cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
603
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
604 variant =
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
605 format == CF_TEXT ? LOCALE_IDEFAULTANSICODEPAGE : LOCALE_IDEFAULTCODEPAGE;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
606
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
607 GetLocaleInfo (lcid, variant, buffer, sizeof (buffer));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
608 cp = strtoul (buffer, NULL, 10);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
609
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
610 if (cp == CP_ACP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
611 return ANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
612 else if (cp == CP_OEMCP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
613 return OEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
614 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
615 return cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
616 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
617
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
618 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
619 coding_from_cp (UINT codepage)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
620 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
621 char buffer[30];
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
622 sprintf (buffer, "cp%d-dos", (int) codepage);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
623 return intern (buffer);
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
624 /* We don't need to check that this coding system actually exists
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
625 right here, because that is done later for all coding systems
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
626 used, regardless of where they originate. */
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
627 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
628
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
629 static Lisp_Object
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
630 validate_coding_system (Lisp_Object coding_system)
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
631 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
632 Lisp_Object eol_type;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
633
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
634 /* Make sure the input is valid. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
635 if (NILP (Fcoding_system_p (coding_system)))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
636 return Qnil;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
637
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
638 /* Make sure we use a DOS coding system as mandated by the system
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
639 specs. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
640 eol_type = Fcoding_system_eol_type (coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
641
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
642 /* Already a DOS coding system? */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
643 if (EQ (eol_type, make_number (1)))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
644 return coding_system;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
645
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
646 /* Get EOL_TYPE vector of the base of CODING_SYSTEM. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
647 if (!VECTORP (eol_type))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
648 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
649 eol_type = Fcoding_system_eol_type (Fcoding_system_base (coding_system));
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
650 if (!VECTORP (eol_type))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
651 return Qnil;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
652 }
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
653
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
654 return AREF (eol_type, 1);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
655 }
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
656
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
657 static void
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
658 setup_windows_coding_system (Lisp_Object coding_system,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
659 struct coding_system * coding)
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
660 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
661 memset (coding, 0, sizeof (*coding));
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
662 setup_coding_system (coding_system, coding);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
663
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
664 /* Unset CODING_ANNOTATE_COMPOSITION_MASK. Previous code had
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
665 comments about crashes in encode_coding_iso2022 trying to
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
666 dereference a null pointer when composition was on. Selection
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
667 data should not contain any composition sequence on Windows.
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
668
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
669 CODING_ANNOTATION_MASK also includes
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
670 CODING_ANNOTATE_DIRECTION_MASK and CODING_ANNOTATE_CHARSET_MASK,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
671 which both apply to ISO6429 only. We don't know if these really
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
672 need to be unset on Windows, but it probably doesn't hurt
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
673 either. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
674 coding->mode &= ~CODING_ANNOTATION_MASK;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
675 coding->mode |= CODING_MODE_LAST_BLOCK | CODING_MODE_SAFE_ENCODING;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
676 }
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
677
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
678
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
679
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
680 DEFUN ("w32-set-clipboard-data", Fw32_set_clipboard_data,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
681 Sw32_set_clipboard_data, 1, 2, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
682 doc: /* This sets the clipboard data to the given text. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
683 (Lisp_Object string, Lisp_Object ignored)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
684 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
685 BOOL ok = TRUE;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
686 int nbytes;
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
687 unsigned char *src;
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
688 unsigned char *dst;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
689 unsigned char *end;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
690
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
691 /* This parameter used to be the current frame, but we don't use
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
692 that any more. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
693 (void) ignored;
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
694
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 33697
diff changeset
695 CHECK_STRING (string);
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
696
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
697 setup_config ();
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
698
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
699 current_text = string;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
700 current_coding_system = cfg_coding_system;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
701 current_clipboard_type = cfg_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
702 current_lcid = cfg_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
703 current_num_nls = 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
704 current_requires_encoding = 0;
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
705
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
706 BLOCK_INPUT;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
707
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
708 /* Check for non-ASCII characters. While we are at it, count the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
709 number of LFs, so we know how many CRs we will have to add later
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
710 (just in the case where we can use our internal ASCII rendering,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
711 see code and comment in convert_to_handle_as_ascii() above). */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
712 nbytes = SBYTES (string);
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45988
diff changeset
713 src = SDATA (string);
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
714
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
715 for (dst = src, end = src+nbytes; dst < end; dst++)
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
716 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
717 if (*dst == '\n')
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
718 current_num_nls++;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
719 else if (*dst >= 0x80 || *dst == 0)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
720 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
721 current_requires_encoding = 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
722 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
723 }
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
724 }
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
725
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
726 if (!current_requires_encoding)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
727 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
728 /* If all we have is ASCII we don't need to pretend we offer
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
729 anything fancy. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
730 current_coding_system = Qraw_text;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
731 current_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
732 current_lcid = LOCALE_NEUTRAL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
733 }
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
734
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
735 if (!OpenClipboard (clipboard_owner))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
736 goto error;
33697
e7765cb122c3 (Fw32_set_clipboard_data): Save a copy of what is put on the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 31117
diff changeset
737
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
738 ++modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
739 ok = EmptyClipboard ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
740 --modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
741
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
742 /* If we have something non-ASCII we may want to set a locale. We
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
743 do that directly (non-delayed), as it's just a small bit. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
744 if (ok)
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
745 ok = !NILP (render_locale ());
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
746
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
747 if (ok)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
748 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
749 if (clipboard_owner == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
750 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
751 /* If for some reason we don't have a clipboard_owner, we
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
752 just set the text format as chosen by the configuration
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
753 and than forget about the whole thing. */
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
754 ok = !NILP (render (make_number (current_clipboard_type)));
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
755 current_text = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
756 current_coding_system = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
757 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
758 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
759 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
760 /* Advertise all supported formats so that whatever the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
761 requester chooses, only one encoding step needs to be
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
762 made. This is intentionally different from what we do in
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
763 the handler for WM_RENDERALLFORMATS. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
764 SetClipboardData (CF_UNICODETEXT, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
765 SetClipboardData (CF_TEXT, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
766 SetClipboardData (CF_OEMTEXT, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
767 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
768 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
769
54974
64d01f3f16e5 (Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 53798
diff changeset
770 CloseClipboard ();
64d01f3f16e5 (Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 53798
diff changeset
771
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
772 /* With delayed rendering we haven't really "used" this coding
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
773 system yet, and it's even unclear if we ever will. But this is a
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
774 way to tell the upper level what we *would* use under ideal
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
775 circumstances.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
776
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
777 We don't signal the actually used coding-system later when we
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
778 finally render, because that can happen at any time and we don't
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
779 want to disturb the "foreground" action. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
780 if (ok)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
781 Vlast_coding_system_used = current_coding_system;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
782
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
783 Vnext_selection_coding_system = Qnil;
51777
940c7de274a2 (last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents: 47879
diff changeset
784
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
785 if (ok) goto done;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
786
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
787 error:
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
788
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
789 ok = FALSE;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
790 current_text = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
791 current_coding_system = Qnil;
51777
940c7de274a2 (last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents: 47879
diff changeset
792
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
793 done:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
794 UNBLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
795
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
796 return (ok ? string : Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
797 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
798
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
799
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
800 DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
801 Sw32_get_clipboard_data, 0, 1, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
802 doc: /* This gets the clipboard data in text format. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
803 (Lisp_Object ignored)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
804 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
805 HGLOBAL htext;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
806 Lisp_Object ret = Qnil;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
807 UINT actual_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
808 int use_configured_coding_system = 1;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
809
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
810 /* This parameter used to be the current frame, but we don't use
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
811 that any more. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
812 (void) ignored;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
813
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
814 /* Don't pass our own text from the clipboard (which might be
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
815 troublesome if the killed text includes null characters). */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
816 if (!NILP (current_text))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
817 return ret;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
818
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
819 setup_config ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
820 actual_clipboard_type = cfg_clipboard_type;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
821
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
822 BLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
823
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
824 if (!OpenClipboard (clipboard_owner))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
825 goto done;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
826
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
827 if ((htext = GetClipboardData (actual_clipboard_type)) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
828 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
829 /* If we want CF_UNICODETEXT but can't get it, the current
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
830 coding system is useless. OTOH we can still try and decode
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
831 CF_TEXT based on the locale that the system gives us and that
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
832 we get down below. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
833 if (actual_clipboard_type == CF_UNICODETEXT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
834 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
835 htext = GetClipboardData (CF_TEXT);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
836 if (htext != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
837 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
838 actual_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
839 use_configured_coding_system = 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
840 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
841 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
842 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
843 if (htext == NULL)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
844 goto closeclip;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
845
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
846 {
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
847 unsigned char *src;
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
848 unsigned char *dst;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
849 int nbytes;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
850 int truelen;
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
851 int require_decoding = 0;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
852
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
853 if ((src = (unsigned char *) GlobalLock (htext)) == NULL)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
854 goto closeclip;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
855
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
856 /* If the clipboard data contains any non-ascii code, we need to
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
857 decode it with a coding system. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
858 if (actual_clipboard_type == CF_UNICODETEXT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
859 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
860 nbytes = lstrlenW ((WCHAR *)src) * 2;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
861 require_decoding = 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
862 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
863 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
864 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
865 int i;
33697
e7765cb122c3 (Fw32_set_clipboard_data): Save a copy of what is put on the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 31117
diff changeset
866
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
867 nbytes = strlen (src);
23562
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
868
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
869 for (i = 0; i < nbytes; i++)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
870 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
871 if (src[i] >= 0x80)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
872 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
873 require_decoding = 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
874 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
875 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
876 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
877 }
43483
dcb45a76827f (Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents: 40962
diff changeset
878
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
879 if (require_decoding)
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
880 {
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
881 struct coding_system coding;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
882 Lisp_Object coding_system = Qnil;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
883 Lisp_Object dos_coding_system;
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
884
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
885 /* `next-selection-coding-system' should override everything,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
886 even when the locale passed by the system disagrees. The
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
887 only exception is when `next-selection-coding-system'
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
888 requested CF_UNICODETEXT and we couldn't get that. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
889 if (use_configured_coding_system
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
890 && !NILP (Vnext_selection_coding_system))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
891 coding_system = Vnext_selection_coding_system;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
892
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
893 /* If we have CF_TEXT or CF_OEMTEXT, we want to check out
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
894 CF_LOCALE, too. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
895 else if (actual_clipboard_type != CF_UNICODETEXT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
896 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
897 HGLOBAL hlocale;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
898 LCID lcid = DEFAULT_LCID;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
899 UINT cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
900
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
901 /* Documentation says that the OS always generates
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
902 CF_LOCALE info automatically, so the locale handle
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
903 should always be present. Fact is that this is not
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
904 always true on 9x ;-(. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
905 hlocale = GetClipboardData (CF_LOCALE);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
906 if (hlocale != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
907 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
908 const LCID * lcid_ptr;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
909 lcid_ptr = (const LCID *) GlobalLock (hlocale);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
910 if (lcid_ptr != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
911 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
912 lcid = *lcid_ptr;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
913 GlobalUnlock (hlocale);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
914 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
915
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
916 /* 9x has garbage as the sort order (to be exact there
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
917 is another instance of the language id in the upper
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
918 word). We don't care about sort order anyway, so
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
919 we just filter out the unneeded mis-information to
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
920 avoid irritations. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
921 lcid = MAKELCID (LANGIDFROMLCID (lcid), SORT_DEFAULT);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
922 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
923
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
924 /* If we are using fallback from CF_UNICODETEXT, we can't
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
925 use the configured coding system. Also we don't want
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
926 to use it, if the system has supplied us with a locale
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
927 and it is not just the system default. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
928 if (!use_configured_coding_system || lcid != DEFAULT_LCID)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
929 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
930 cp = cp_from_locale (lcid, actual_clipboard_type);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
931 /* If it's just our current standard setting anyway,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
932 use the coding system that the user has selected.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
933 Otherwise create a new spec to match the locale
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
934 that was specified by the other side or the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
935 system. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
936 if (!use_configured_coding_system || cp != cfg_codepage)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
937 coding_system = coding_from_cp (cp);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
938 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
939 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
940
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
941 if (NILP (coding_system))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
942 coding_system = Vselection_coding_system;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
943 Vnext_selection_coding_system = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
944
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
945 dos_coding_system = validate_coding_system (coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
946 if (!NILP (dos_coding_system))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
947 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
948 setup_windows_coding_system (dos_coding_system, &coding);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
949 coding.source = src;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
950 decode_coding_object (&coding, Qnil, 0, 0, nbytes, nbytes, Qt);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
951 ret = coding.dst_object;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
952
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
953 Vlast_coding_system_used = CODING_ID_NAME (coding.id);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
954 }
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
955 }
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
956 else
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
957 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
958 /* FIXME: We may want to repeat the code in this branch for
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
959 the Unicode case. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
960
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
961 /* Need to know final size after CR chars are removed because
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
962 we can't change the string size manually, and doing an
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
963 extra copy is silly. We only remove CR when it appears as
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
964 part of CRLF. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
965
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
966 truelen = nbytes;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
967 dst = src;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
968 /* 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
969 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
970 {
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
971 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
972 truelen--;
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
973 dst++;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
974 }
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
975
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
976 ret = make_uninit_string (truelen);
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
977
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
978 /* 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
979 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
980
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45988
diff changeset
981 dst = SDATA (ret);
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
982 while (1)
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
983 {
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
984 unsigned char *next;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
985 /* 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
986 next = _memccpy (dst, src, '\r', nbytes);
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
987 if (next)
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
988 {
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
989 /* copied one line ending with '\r' */
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
990 int copied = next - dst;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
991 nbytes -= copied;
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
992 dst += copied;
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
993 src += copied;
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
994 if (*src == '\n')
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
995 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
996 }
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
997 else
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
998 /* copied remaining partial line -> now finished */
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
999 break;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
1000 }
22745
ef9607e709bc (Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents: 22545
diff changeset
1001
ef9607e709bc (Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents: 22545
diff changeset
1002 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
1003 }
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1004
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1005 GlobalUnlock (htext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1006 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1007
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1008 closeclip:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1009 CloseClipboard ();
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
1010
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1011 done:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1012 UNBLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
1013
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1014 return (ret);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1015 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1016
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1017 /* Support checking for a clipboard selection. */
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1018
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1019 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1020 0, 1, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1021 doc: /* Whether there is an owner for the given X Selection.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1022 The arg should be the name of the selection in question, typically one of
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1023 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1024 \(Those are literal upper-case symbol names, since that's what X expects.)
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1025 For convenience, the symbol nil is the same as `PRIMARY',
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1026 and t is the same as `SECONDARY'. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1027 (Lisp_Object selection)
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1028 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 33697
diff changeset
1029 CHECK_SYMBOL (selection);
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1030
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1031 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1032 if the clipboard currently has valid text format contents. */
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1033
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1034 if (EQ (selection, QCLIPBOARD))
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1035 {
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1036 Lisp_Object val = Qnil;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1037
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
1038 setup_config ();
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
1039
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1040 if (OpenClipboard (NULL))
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1041 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1042 UINT format = 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1043 while ((format = EnumClipboardFormats (format)))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1044 /* Check CF_TEXT in addition to cfg_clipboard_type,
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1045 because we can fall back on that if CF_UNICODETEXT is
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1046 not available. Actually a check for CF_TEXT only
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1047 should be enough. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1048 if (format == cfg_clipboard_type || format == CF_TEXT)
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1049 {
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1050 val = Qt;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1051 break;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1052 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1053 CloseClipboard ();
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1054 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1055 return val;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1056 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1057 return Qnil;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1058 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1059
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1060 /* One-time init. Called in the un-dumped Emacs, but not in the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1061 dumped version. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1062
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
1063 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1064 syms_of_w32select (void)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1065 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15235
diff changeset
1066 defsubr (&Sw32_set_clipboard_data);
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15235
diff changeset
1067 defsubr (&Sw32_get_clipboard_data);
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1068 defsubr (&Sx_selection_exists_p);
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1069
22914
4d4e775cf6f7 (Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents: 22745
diff changeset
1070 DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1071 doc: /* Coding system for communicating with other programs.
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1072 When sending or receiving text via cut_buffer, selection, and
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1073 clipboard, the text is encoded or decoded by this coding system.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1074 The default value is the current system default encoding on 9x/Me and
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1075 `utf-16le-dos' (Unicode) on NT/W2K/XP. */);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1076 /* The actual value is set dynamically in the dumped Emacs, see
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1077 below. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1078 Vselection_coding_system = Qnil;
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
1079
23562
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
1080 DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1081 doc: /* Coding system for the next communication with other programs.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1082 Usually, `selection-coding-system' is used for communicating with
47280
7e81df5e2e1a (syms_of_w32select): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
1083 other programs. But, if this variable is set, it is used for the
7e81df5e2e1a (syms_of_w32select): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 46370
diff changeset
1084 next communication only. After the communication, this variable is
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
1085 set to nil. */);
23562
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
1086 Vnext_selection_coding_system = Qnil;
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
1087
90922
a4f75e39ca14 (syms_of_w32select): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90737
diff changeset
1088 DEFSYM (QCLIPBOARD, "CLIPBOARD");
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1089
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1090 cfg_coding_system = Qnil; staticpro (&cfg_coding_system);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1091 current_text = Qnil; staticpro (&current_text);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1092 current_coding_system = Qnil; staticpro (&current_coding_system);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1093
90922
a4f75e39ca14 (syms_of_w32select): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90737
diff changeset
1094 DEFSYM (QUNICODE, "utf-16le-dos");
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1095 QANSICP = Qnil; staticpro (&QANSICP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1096 QOEMCP = Qnil; staticpro (&QOEMCP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1097 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1098
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1099 /* One-time init. Called in the dumped Emacs, but not in the
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1100 un-dumped version. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1101
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1102 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1103 globals_of_w32select (void)
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1104 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1105 DEFAULT_LCID = GetUserDefaultLCID ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1106 /* Drop the sort order from the LCID, so we can compare this with
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1107 CF_LOCALE objects that have the same fix on 9x. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1108 DEFAULT_LCID = MAKELCID (LANGIDFROMLCID (DEFAULT_LCID), SORT_DEFAULT);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1109
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1110 ANSICP = GetACP ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1111 OEMCP = GetOEMCP ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1112
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1113 QANSICP = coding_from_cp (ANSICP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1114 QOEMCP = coding_from_cp (OEMCP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1115
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1116 if (os_subtype == OS_NT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1117 Vselection_coding_system = QUNICODE;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1118 else if (inhibit_window_system)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1119 Vselection_coding_system = QOEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1120 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1121 Vselection_coding_system = QANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1122
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1123 clipboard_owner = create_owner ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1124 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51777
diff changeset
1125
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51777
diff changeset
1126 /* arch-tag: c96e9724-5eb1-4dad-be07-289f092fd2af
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51777
diff changeset
1127 (do not change this comment) */