annotate src/w32select.c @ 112429:6e50030da731

Some copyright.el updates. * lisp/emacs-lisp/copyright.el (copyright-find-copyright): New function, split out from copyright-update-year. (copyright-update): Don't mess with the GPL version if we don't own the copyright. Update license regexp, and remove no longer needed Esperanto stuff.
author Glenn Morris <rgm@gnu.org>
date Sat, 22 Jan 2011 14:09:09 -0800
parents 42e22c4f06b7
children
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.
112284
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
2
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
3 Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
4 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
5
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
6 This file is part of GNU Emacs.
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
7
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91327
diff changeset
8 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
9 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
10 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
11 (at your option) any later version.
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
12
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
13 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
14 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
15 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
16 GNU General Public License for more details.
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
17
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13434
diff changeset
18 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
19 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
20
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
21 /* 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
22
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
23
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
24 /*
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
25 * 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
26 * 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
27 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
28 * 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
29 * 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
30 * 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
31 * (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
32 * 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
33 * else they apply to the normal 8-bit text clipboard (CF_TEXT).
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
34 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
35 * 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
36 * 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
37 * 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
38 * 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
39 * 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
40 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
41 * 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
42 * 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
43 * 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
44 * {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
45 * 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
46 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
47 * 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
48 * coding system are:
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
49 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
50 * ;; 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
51 * ;; the 8-bit clipboard.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
52 * (set-selection-coding-system 'koi8-r-dos)
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
53 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
54 * Or
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
55 *
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
56 * ;; 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
57 * ;; 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
58 * ;; application.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
59 * (defun greek-copy (beg end)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
60 * (interactive "r")
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
61 * (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
62 * (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
63 * (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
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 /*
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
67 * Ideas for further directions:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
68 *
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
69 * 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
70 * 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
71 * 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
72 * 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
73 * 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
74 */
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
75
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
76 #include <config.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 100951
diff changeset
77 #include <setjmp.h>
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
78 #include "lisp.h"
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15235
diff changeset
79 #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
80 #include "w32heap.h" /* os_subtype */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
81 #include "blockinput.h"
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
82 #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
83 #include "charset.h"
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
84 #include "coding.h"
90930
218b1814ca2e Include character.h
Jason Rumney <jasonr@gnu.org>
parents: 90922
diff changeset
85 #include "character.h"
45988
37913830a881 Include composite.h
Juanma Barranquero <lekktu@gmail.com>
parents: 45984
diff changeset
86 #include "composite.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
87
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
88
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_ascii (void);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 WPARAM wp, LPARAM lp);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
98 static HWND create_owner (void);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
99
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
100 static void setup_config (void);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
101 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
102 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
103 static Lisp_Object coding_from_cp (UINT codepage);
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
104 static Lisp_Object validate_coding_system (Lisp_Object coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
105 static void setup_windows_coding_system (Lisp_Object coding_system,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
106 struct coding_system * coding);
60092
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
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
109 /* 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
110 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
111 PRIMARY and SECONDARY. */
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
112 Lisp_Object QCLIPBOARD;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
113
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
114 /* 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
115 based on current system parameters. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
116 static LCID DEFAULT_LCID;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
117 static UINT ANSICP, OEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
118 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
119
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
120 /* 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
121 static HWND clipboard_owner;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
122 /* 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
123 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
124 static int modifying_clipboard = 0;
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 /* 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
127 selection-coding-system. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
128 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
129 static UINT cfg_codepage;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
130 static LCID cfg_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
131 static UINT cfg_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
132
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
133 /* 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
134 static Lisp_Object current_text;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
135 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
136 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
137 static UINT current_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
138 static LCID current_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
139
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
140 #if TRACE
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
141 #define ONTRACE(stmt) stmt
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
142 #else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
143 #define ONTRACE(stmt) /*stmt*/
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
144 #endif
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
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
147 /* 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
148 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
149
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
150 static HGLOBAL
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
151 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
152 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
153 HGLOBAL htext = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
154 int nbytes;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
155 int truelen;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
156 unsigned char *src;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
157 unsigned char *dst;
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 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
160
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
161 nbytes = SBYTES (current_text) + 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
162 src = SDATA (current_text);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
163
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
164 /* 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
165 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
166 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
167
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
168 truelen = nbytes + current_num_nls;
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 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
171 return NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
172
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
173 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
174 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
175 GlobalFree (htext);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
176 return NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
177 }
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 /* 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
180 while (1)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
181 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
182 unsigned char *next;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
183 /* 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
184 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
185 if (next)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
186 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
187 /* 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
188 int copied = next - dst;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
189 nbytes -= copied;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
190 src += copied;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
191 /* insert '\r' before '\n' */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
192 next[-1] = '\r';
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
193 next[0] = '\n';
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
194 dst = next + 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
195 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
196 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
197 /* 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
198 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
199 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
200
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
201 GlobalUnlock (htext);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
202
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
203 return htext;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
204 }
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 /* 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
207 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
208 text through the encoding machinery. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
209
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
210 static HGLOBAL
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
211 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
212 {
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
213 HGLOBAL htext;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
214 unsigned char *dst = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
215 struct coding_system coding;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
216
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
217 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
218 SDATA (SYMBOL_NAME (coding_system))));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
219
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
220 setup_windows_coding_system (coding_system, &coding);
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
221 coding.dst_bytes = SBYTES (current_text) * 2;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
222 coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
223 encode_coding_object (&coding, current_text, 0, 0,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
224 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
225
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
226 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
227
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
228 if (htext != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
229 dst = (unsigned char *) GlobalLock (htext);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
230
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
231 if (dst != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
232 {
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
233 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
234 /* 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
235 producing Unicode here. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
236 dst[coding.produced] = dst[coding.produced+1] = '\0';
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
237
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
238 GlobalUnlock (htext);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
239 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
240
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
241 xfree (coding.destination);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
242
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
243 return htext;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
244 }
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 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
247 render (Lisp_Object oformat)
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 HGLOBAL htext = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
250 UINT format = XFASTINT (oformat);
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 ONTRACE (fprintf (stderr, "render\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
253
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
254 if (NILP (current_text))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
255 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
256
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
257 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
258 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
259 if (format == current_clipboard_type)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
260 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
261 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
262 switch (format)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
263 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
264 case CF_UNICODETEXT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
265 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
266 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
267 case CF_TEXT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
268 case CF_OEMTEXT:
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 Lisp_Object cs;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
271 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
272 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
273 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
274 }
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 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
277 else
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_ascii ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
279
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
280 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
281
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
282 if (htext == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
283 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
284
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
285 if (SetClipboardData (format, htext) == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
286 {
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
287 GlobalFree (htext);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
288 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
289 }
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 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
292 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
293
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
294 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
295 render_locale (void)
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 HANDLE hlocale = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
298 LCID * lcid_ptr;
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 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
301
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
302 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
303 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
304
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
305 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
306 if (hlocale == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
307 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
308
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
309 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
310 {
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
311 GlobalFree (hlocale);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
312 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
313 }
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
314
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
315 *lcid_ptr = current_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
316 GlobalUnlock (hlocale);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
317
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
318 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
319 {
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
320 GlobalFree (hlocale);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
321 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
322 }
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 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
325 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
326
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
327 /* 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
328 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
329
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
330 static Lisp_Object
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
331 render_all (Lisp_Object ignore)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
332 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
333 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
334
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
335 /* 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
336 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
337 it is actually necessary. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
338
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
339 OpenClipboard (NULL);
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 /* 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
342 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
343 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
344 bothering with error handling. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
345
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
346 ++modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
347 EmptyClipboard ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
348 --modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
349
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
350 /* 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
351 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
352 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
353 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
354 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
355
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
356 - 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
357 (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
358 CF_UNICODETEXT.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
359
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
360 - 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
361 for CF_TEXT.
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
362
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
363 - 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
364 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
365 it.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
366
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
367 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
368 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
369 conversions, just in case.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
370
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
371 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
372 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
373 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
374 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
375 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
376
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
377 render_locale ();
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
378
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
379 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
380 render (make_number (CF_TEXT));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
381 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
382
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
383 CloseClipboard ();
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 return Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
386 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
387
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
388 static void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
389 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
390 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
391 /* 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
392 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
393 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
394
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
395 int owfi;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
396
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
397 BLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
398
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
399 /* 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
400 set. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
401 owfi = waiting_for_input;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
402 waiting_for_input = 0;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
403
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
404 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
405
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
406 waiting_for_input = owfi;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
407
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
408 UNBLOCK_INPUT;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
409 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
410
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
411 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
412 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
413 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
414 Vsignaling_function = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
415 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
416 Vinhibit_quit = Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
417 return Qt;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
418 }
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
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
421 static LRESULT CALLBACK
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
422 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
423 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
424 switch (msg)
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 case WM_RENDERFORMAT:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
427 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
428 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
429 return 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
430
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
431 case WM_RENDERALLFORMATS:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
432 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
433 run_protected (render_all, Qnil);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
434 return 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
435
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
436 case WM_DESTROYCLIPBOARD:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
437 if (!modifying_clipboard)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
438 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
439 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
440 current_text = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
441 current_coding_system = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
442 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
443 else
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 (self)\n"));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
446 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
447 return 0;
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 case WM_DESTROY:
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
450 if (win == clipboard_owner)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
451 clipboard_owner = NULL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
452 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
453 }
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 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
456 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
457
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
458 static HWND
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
459 create_owner (void)
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 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
462 WNDCLASS wc;
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 memset (&wc, 0, sizeof (wc));
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
465 wc.lpszClassName = CLASSNAME;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
466 wc.lpfnWndProc = owner_callback;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
467 RegisterClass (&wc);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
468
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
469 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
470 NULL, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
471 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
472
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
473 /* 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
474
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
475 void
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
476 term_w32select (void)
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 /* 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
479 if (clipboard_owner != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
480 DestroyWindow (clipboard_owner);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
481 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
482
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
483 static void
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
484 setup_config (void)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
485 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
486 const char *coding_name;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
487 const char *cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
488 char *end;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
489 int slen;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
490 Lisp_Object coding_system;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
491 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
492
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
493 CHECK_SYMBOL (Vselection_coding_system);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
494
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
495 coding_system = NILP (Vnext_selection_coding_system) ?
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
496 Vselection_coding_system : Vnext_selection_coding_system;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
497
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
498 dos_coding_system = validate_coding_system (coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
499 if (NILP (dos_coding_system))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
500 Fsignal (Qerror,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
501 list2 (build_string ("Coding system is invalid or doesn't have "
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
502 "an eol variant for dos line ends"),
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
503 coding_system));
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
504
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
505 /* 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
506 if (!NILP (cfg_coding_system)
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
507 && 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
508 return;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
509 cfg_coding_system = dos_coding_system;
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
510
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
511 /* Set some sensible fallbacks */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
512 cfg_codepage = ANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
513 cfg_lcid = LOCALE_NEUTRAL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
514 cfg_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
515
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
516 /* 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
517 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
518
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
519 /* "(.*-)?utf-16.*" -> CF_UNICODETEXT */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
520 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
521 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
522 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
523 cfg_clipboard_type = CF_UNICODETEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
524 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
525 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
526
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
527 /* "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
528 slen = strlen (coding_name);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
529 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
530 cp = coding_name + 2;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
531 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
532 cp = coding_name + 8;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
533 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
534 return;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
535
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
536 end = (char*)cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
537 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
538
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
539 /* 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
540 default and drop it. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
541 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
542 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
543 cfg_codepage = ANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
544 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
545 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
546
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
547 /* 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
548 if (cfg_codepage == ANSICP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
549 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
550 /* cfg_clipboard_type = CF_TEXT; */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
551 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
552 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
553 if (cfg_codepage == OEMCP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
554 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
555 cfg_clipboard_type = CF_OEMTEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
556 return;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
557 }
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 /* 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
560 EnumSystemLocales (enum_locale_callback, LCID_INSTALLED);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
561 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
562
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
563 static BOOL WINAPI
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
564 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
565 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
566 LCID lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
567 UINT codepage;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
568
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
569 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
570
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
571 /* 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
572 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
573 if (codepage == cfg_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 cfg_lcid = lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
576 cfg_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
577 return FALSE; /* Stop enumeration */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
578 }
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
579
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
580 /* 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
581 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
582 if (codepage == cfg_codepage)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
583 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
584 cfg_lcid = lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
585 cfg_clipboard_type = CF_OEMTEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
586 return FALSE; /* Stop enumeration */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
587 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
588
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
589 return TRUE; /* Continue enumeration */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
590 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
591
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
592 static UINT
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
593 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
594 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
595 char buffer[20] = "";
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
596 UINT variant, cp;
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 variant =
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
599 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
600
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
601 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
602 cp = strtoul (buffer, NULL, 10);
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 if (cp == CP_ACP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
605 return ANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
606 else if (cp == CP_OEMCP)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
607 return OEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
608 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
609 return cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
610 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
611
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
612 static Lisp_Object
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
613 coding_from_cp (UINT codepage)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
614 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
615 char buffer[30];
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
616 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
617 return intern (buffer);
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
618 /* 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
619 right here, because that is done later for all coding systems
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
620 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
621 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
622
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
623 static Lisp_Object
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
624 validate_coding_system (Lisp_Object coding_system)
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
625 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
626 Lisp_Object eol_type;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
627
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
628 /* Make sure the input is valid. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
629 if (NILP (Fcoding_system_p (coding_system)))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
630 return Qnil;
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 /* 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
633 specs. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
634 eol_type = Fcoding_system_eol_type (coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
635
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
636 /* Already a DOS coding system? */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
637 if (EQ (eol_type, make_number (1)))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
638 return coding_system;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
639
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
640 /* Get EOL_TYPE vector of the base of CODING_SYSTEM. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
641 if (!VECTORP (eol_type))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
642 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
643 eol_type = Fcoding_system_eol_type (Fcoding_system_base (coding_system));
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
644 if (!VECTORP (eol_type))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
645 return Qnil;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
646 }
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
647
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
648 return AREF (eol_type, 1);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
649 }
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
650
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
651 static void
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
652 setup_windows_coding_system (Lisp_Object coding_system,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
653 struct coding_system * coding)
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
654 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
655 memset (coding, 0, sizeof (*coding));
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
656 setup_coding_system (coding_system, coding);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
657
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
658 /* Unset CODING_ANNOTATE_COMPOSITION_MASK. Previous code had
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
659 comments about crashes in encode_coding_iso2022 trying to
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
660 dereference a null pointer when composition was on. Selection
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
661 data should not contain any composition sequence on Windows.
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
662
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
663 CODING_ANNOTATION_MASK also includes
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
664 CODING_ANNOTATE_DIRECTION_MASK and CODING_ANNOTATE_CHARSET_MASK,
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
665 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
666 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
667 either. */
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
668 coding->mode &= ~CODING_ANNOTATION_MASK;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
669 coding->mode |= CODING_MODE_LAST_BLOCK | CODING_MODE_SAFE_ENCODING;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
670 }
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
671
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
672
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
673
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
674 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
675 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
676 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
677 (Lisp_Object string, Lisp_Object ignored)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
678 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
679 BOOL ok = TRUE;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
680 int nbytes;
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
681 unsigned char *src;
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
682 unsigned char *dst;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
683 unsigned char *end;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
684
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
685 /* 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
686 that any more. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
687 (void) ignored;
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
688
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 33697
diff changeset
689 CHECK_STRING (string);
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
690
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
691 setup_config ();
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
692
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
693 current_text = string;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
694 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
695 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
696 current_lcid = cfg_lcid;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
697 current_num_nls = 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
698 current_requires_encoding = 0;
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
699
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
700 BLOCK_INPUT;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
701
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
702 /* 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
703 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
704 (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
705 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
706 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
707 src = SDATA (string);
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
708
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
709 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
710 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
711 if (*dst == '\n')
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
712 current_num_nls++;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
713 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
714 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
715 current_requires_encoding = 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
716 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
717 }
24518
a0423d2b9302 (Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents: 23874
diff changeset
718 }
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
719
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
720 if (!current_requires_encoding)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
721 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
722 /* 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
723 anything fancy. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
724 current_coding_system = Qraw_text;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
725 current_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
726 current_lcid = LOCALE_NEUTRAL;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
727 }
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
728
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
729 if (!OpenClipboard (clipboard_owner))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
730 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
731
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
732 ++modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
733 ok = EmptyClipboard ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
734 --modifying_clipboard;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
735
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
736 /* 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
737 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
738 if (ok)
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
739 ok = !NILP (render_locale ());
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
740
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
741 if (ok)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
742 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
743 if (clipboard_owner == NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
744 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
745 /* 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
746 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
747 and than forget about the whole thing. */
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
748 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
749 current_text = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
750 current_coding_system = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
751 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
752 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
753 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
754 /* 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
755 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
756 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
757 the handler for WM_RENDERALLFORMATS. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
758 SetClipboardData (CF_UNICODETEXT, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
759 SetClipboardData (CF_TEXT, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
760 SetClipboardData (CF_OEMTEXT, NULL);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
761 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
762 }
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
763
54974
64d01f3f16e5 (Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 53798
diff changeset
764 CloseClipboard ();
64d01f3f16e5 (Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents: 53798
diff changeset
765
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
766 /* 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
767 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
768 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
769 circumstances.
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
770
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
771 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
772 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
773 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
774 if (ok)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
775 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
776
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
777 Vnext_selection_coding_system = Qnil;
51777
940c7de274a2 (last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents: 47879
diff changeset
778
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
779 if (ok) goto done;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
780
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
781 error:
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
782
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
783 ok = FALSE;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
784 current_text = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
785 current_coding_system = Qnil;
51777
940c7de274a2 (last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents: 47879
diff changeset
786
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
787 done:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
788 UNBLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
789
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
790 return (ok ? string : Qnil);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
791 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
792
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
793
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40656
diff changeset
794 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
795 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
796 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
797 (Lisp_Object ignored)
13434
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 HGLOBAL htext;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
800 Lisp_Object ret = Qnil;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
801 UINT actual_clipboard_type;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
802 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
803
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
804 /* 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
805 that any more. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
806 (void) ignored;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
807
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
808 /* 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
809 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
810 if (!NILP (current_text))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
811 return ret;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
812
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
813 setup_config ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
814 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
815
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
816 BLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
817
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
818 if (!OpenClipboard (clipboard_owner))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
819 goto done;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
820
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
821 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
822 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
823 /* 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
824 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
825 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
826 we get down below. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
827 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
828 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
829 htext = GetClipboardData (CF_TEXT);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
830 if (htext != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
831 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
832 actual_clipboard_type = CF_TEXT;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
833 use_configured_coding_system = 0;
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 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
836 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
837 if (htext == NULL)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
838 goto closeclip;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
839
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
840 {
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
841 unsigned char *src;
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
842 unsigned char *dst;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
843 int nbytes;
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
844 int truelen;
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
845 int require_decoding = 0;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
846
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
847 if ((src = (unsigned char *) GlobalLock (htext)) == NULL)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
848 goto closeclip;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
849
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
850 /* 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
851 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
852 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
853 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
854 nbytes = lstrlenW ((WCHAR *)src) * 2;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
855 require_decoding = 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
856 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
857 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
858 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
859 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
860
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
861 nbytes = strlen (src);
23562
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
862
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
863 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
864 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
865 if (src[i] >= 0x80)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
866 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
867 require_decoding = 1;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
868 break;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
869 }
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 }
43483
dcb45a76827f (Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents: 40962
diff changeset
872
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
873 if (require_decoding)
15150
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
874 {
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
875 struct coding_system coding;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
876 Lisp_Object coding_system = Qnil;
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
877 Lisp_Object dos_coding_system;
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
878
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
879 /* `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
880 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
881 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
882 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
883 if (use_configured_coding_system
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
884 && !NILP (Vnext_selection_coding_system))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
885 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
886
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
887 /* 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
888 CF_LOCALE, too. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
889 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
890 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
891 HGLOBAL hlocale;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
892 LCID lcid = DEFAULT_LCID;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
893 UINT cp;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
894
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
895 /* 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
896 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
897 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
898 always true on 9x ;-(. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
899 hlocale = GetClipboardData (CF_LOCALE);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
900 if (hlocale != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
901 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
902 const LCID * lcid_ptr;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
903 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
904 if (lcid_ptr != NULL)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
905 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
906 lcid = *lcid_ptr;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
907 GlobalUnlock (hlocale);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
908 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
909
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
910 /* 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
911 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
912 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
913 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
914 avoid irritations. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
915 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
916 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
917
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
918 /* 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
919 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
920 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
921 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
922 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
923 {
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
924 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
925 /* 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
926 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
927 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
928 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
929 system. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
930 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
931 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
932 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
933 }
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
934
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
935 if (NILP (coding_system))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
936 coding_system = Vselection_coding_system;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
937 Vnext_selection_coding_system = Qnil;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
938
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
939 dos_coding_system = validate_coding_system (coding_system);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
940 if (!NILP (dos_coding_system))
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
941 {
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
942 setup_windows_coding_system (dos_coding_system, &coding);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
943 coding.source = src;
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
944 decode_coding_object (&coding, Qnil, 0, 0, nbytes, nbytes, Qt);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
945 ret = coding.dst_object;
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
946
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
947 Vlast_coding_system_used = CODING_ID_NAME (coding.id);
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
948 }
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
949 }
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
950 else
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
951 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
952 /* 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
953 the Unicode case. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
954
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
955 /* 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
956 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
957 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
958 part of CRLF. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
959
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
960 truelen = nbytes;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
961 dst = src;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
962 /* 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
963 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
964 {
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
965 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
966 truelen--;
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
967 dst++;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
968 }
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
969
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
970 ret = make_uninit_string (truelen);
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
971
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
972 /* 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
973 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
974
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45988
diff changeset
975 dst = SDATA (ret);
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
976 while (1)
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
977 {
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
978 unsigned char *next;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
979 /* 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
980 next = _memccpy (dst, src, '\r', nbytes);
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
981 if (next)
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
982 {
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
983 /* copied one line ending with '\r' */
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
984 int copied = next - dst;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
985 nbytes -= copied;
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
986 dst += copied;
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
987 src += copied;
23835
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
988 if (*src == '\n')
ad04307ef465 (Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents: 23562
diff changeset
989 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
990 }
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
991 else
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
992 /* copied remaining partial line -> now finished */
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
993 break;
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
994 }
22745
ef9607e709bc (Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents: 22545
diff changeset
995
ef9607e709bc (Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents: 22545
diff changeset
996 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
997 }
e37489592e27 (Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
998
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
999 GlobalUnlock (htext);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1000 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1001
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1002 closeclip:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1003 CloseClipboard ();
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
1004
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1005 done:
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1006 UNBLOCK_INPUT;
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
1007
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1008 return (ret);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1009 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1010
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1011 /* Support checking for a clipboard selection. */
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1012
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1013 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
1014 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
1015 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
1016 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
1017 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
1018 \(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
1019 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
1020 and t is the same as `SECONDARY'. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1021 (Lisp_Object selection)
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1022 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 33697
diff changeset
1023 CHECK_SYMBOL (selection);
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1024
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1025 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1026 if the clipboard currently has valid text format contents. */
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1027
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1028 if (EQ (selection, QCLIPBOARD))
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1029 {
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1030 Lisp_Object val = Qnil;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1031
90157
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
1032 setup_config ();
a1ee5124bb20 (validate_coding_system)
Kenichi Handa <handa@m17n.org>
parents: 90105
diff changeset
1033
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1034 if (OpenClipboard (NULL))
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1035 {
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1036 UINT format = 0;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1037 while ((format = EnumClipboardFormats (format)))
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1038 /* 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
1039 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
1040 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
1041 should be enough. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1042 if (format == cfg_clipboard_type || format == CF_TEXT)
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1043 {
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1044 val = Qt;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1045 break;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1046 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1047 CloseClipboard ();
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1048 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1049 return val;
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1050 }
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1051 return Qnil;
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
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1054 /* 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
1055 dumped version. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1056
47879
4ef507bc376e (syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents: 47280
diff changeset
1057 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1058 syms_of_w32select (void)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1059 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15235
diff changeset
1060 defsubr (&Sw32_set_clipboard_data);
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15235
diff changeset
1061 defsubr (&Sw32_get_clipboard_data);
15235
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1062 defsubr (&Sx_selection_exists_p);
440d937a60f7 (QCLIPBOARD): New symbol.
Karl Heuer <kwzh@gnu.org>
parents: 15150
diff changeset
1063
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112284
diff changeset
1064 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
1065 doc: /* Coding system for communicating with other programs.
111136
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1066
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1067 For MS-Windows and MS-DOS:
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1068 When sending or receiving text via selection and clipboard, the text
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1069 is encoded or decoded by this coding system. The default value is
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1070 the current system default encoding on 9x/Me, `utf-16le-dos'
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1071 \(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS.
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1072
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1073 For X Windows:
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1074 When sending text via selection and clipboard, if the target
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1075 data-type matches with the type of this coding system, it is used
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1076 for encoding the text. Otherwise (including the case that this
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1077 variable is nil), a proper coding system is used as below:
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1078
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1079 data-type coding system
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1080 --------- -------------
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1081 UTF8_STRING utf-8
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1082 COMPOUND_TEXT compound-text-with-extensions
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1083 STRING iso-latin-1
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1084 C_STRING no-conversion
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1085
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1086 When receiving text, if this coding system is non-nil, it is used
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1087 for decoding regardless of the data-type. If this is nil, a
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1088 proper coding system is used according to the data-type as above.
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1089
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1090 See also the documentation of the variable `x-select-request-type' how
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1091 to control which data-type to request for receiving text.
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1092
bc1274182cc8 Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents: 111135
diff changeset
1093 The default value is nil. */);
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1094 /* 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
1095 below. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1096 Vselection_coding_system = Qnil;
22545
5d3f50b4c8d2 Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents: 16884
diff changeset
1097
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112284
diff changeset
1098 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
1099 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
1100 Usually, `selection-coding-system' is used for communicating with
111135
600f564fdc23 Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents: 110997
diff changeset
1101 other programs (X Windows clients or MS Windows programs). But, if this
600f564fdc23 Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents: 110997
diff changeset
1102 variable is set, it is used for the next communication only.
600f564fdc23 Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents: 110997
diff changeset
1103 After the communication, this variable is set to nil. */);
23562
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
1104 Vnext_selection_coding_system = Qnil;
5f3243813b18 (Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23422
diff changeset
1105
90922
a4f75e39ca14 (syms_of_w32select): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90737
diff changeset
1106 DEFSYM (QCLIPBOARD, "CLIPBOARD");
60092
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1107
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1108 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
1109 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
1110 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
1111
90922
a4f75e39ca14 (syms_of_w32select): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90737
diff changeset
1112 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
1113 QANSICP = Qnil; staticpro (&QANSICP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1114 QOEMCP = Qnil; staticpro (&QOEMCP);
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
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1117 /* 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
1118 un-dumped version. */
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1119
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1120 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1121 globals_of_w32select (void)
60092
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 DEFAULT_LCID = GetUserDefaultLCID ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1124 /* 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
1125 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
1126 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
1127
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1128 ANSICP = GetACP ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1129 OEMCP = GetOEMCP ();
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1130
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1131 QANSICP = coding_from_cp (ANSICP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1132 QOEMCP = coding_from_cp (OEMCP);
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1133
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1134 if (os_subtype == OS_NT)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1135 Vselection_coding_system = QUNICODE;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1136 else if (inhibit_window_system)
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1137 Vselection_coding_system = QOEMCP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1138 else
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1139 Vselection_coding_system = QANSICP;
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1140
04686828d0da 2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents: 56299
diff changeset
1141 clipboard_owner = create_owner ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1142 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51777
diff changeset
1143