annotate src/w32select.c @ 106934:65e9e6e166f6

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