Mercurial > emacs
annotate src/w32select.c @ 112316:2887524f362a
Include <getopt.h> not "getopt.h".
* ebrowse.c, emacsclient.c: Include <getopt.h>, not "getopt.h".
Since getopt.h is no longer in this directory, there's no point
using the form with double-quotes.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sun, 09 Jan 2011 00:00:02 -0800 |
parents | bc1274182cc8 |
children | 417b1e4d63cd |
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. |
111135
600f564fdc23
Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents:
110997
diff
changeset
|
2 |
600f564fdc23
Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents:
110997
diff
changeset
|
3 Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
600f564fdc23
Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents:
110997
diff
changeset
|
4 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
|
5 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
6 This file is part of GNU Emacs. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
7 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
8 GNU Emacs is free software: you can redistribute it and/or modify |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
9 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
11 (at your option) any later version. |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
12 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
13 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
16 GNU General Public License for more details. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
17 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91327
diff
changeset
|
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
13434 | 20 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
21 /* Written by Kevin Gallo, Benjamin Riefenstahl */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
22 |
13434 | 23 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
24 /* |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
25 * Notes on usage of selection-coding-system and |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
26 * next-selection-coding-system on MS Windows: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
27 * |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
28 * The selection coding system variables apply only to the version of |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
29 * the clipboard data that is closest in type, i.e. when a 16-bit |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
30 * Unicode coding system is given, they apply to he Unicode clipboard |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
31 * (CF_UNICODETEXT), when a well-known console codepage is given, they |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
32 * apply to the console version of the clipboard data (CF_OEMTEXT), |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
33 * else they apply to the normal 8-bit text clipboard (CF_TEXT). |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
34 * |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
35 * When pasting (getting data from the OS), the clipboard format that |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
36 * matches the {next-}selection-coding-system is retrieved. If |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
37 * Unicode is requested, but not available, 8-bit text (CF_TEXT) is |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
38 * used. In all other cases the OS will transparently convert |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
39 * formats, so no other fallback is needed. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
40 * |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
41 * When copying or cutting (sending data to the OS), the data is |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
42 * announced and stored internally, but only actually rendered on |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
43 * request. The requester determines the format provided. The |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
44 * {next-}selection-coding-system is only used, when its corresponding |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
45 * clipboard type matches the type requested. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
46 * |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
47 * Scenarios to use the facilities for customizing the selection |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
48 * coding system are: |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
49 * |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
50 * ;; Generally use KOI8-R instead of the russian MS codepage for |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
51 * ;; the 8-bit clipboard. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
52 * (set-selection-coding-system 'koi8-r-dos) |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
53 * |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
54 * Or |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
55 * |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
56 * ;; Create a special clipboard copy function that uses codepage |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
57 * ;; 1253 (Greek) to copy Greek text to a specific non-Unicode |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
58 * ;; application. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
59 * (defun greek-copy (beg end) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
60 * (interactive "r") |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
61 * (set-next-selection-coding-system 'cp1253-dos) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
62 * (copy-region-as-kill beg end)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
63 * (global-set-key "\C-c\C-c" 'greek-copy) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
64 */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
65 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
66 /* |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
67 * Ideas for further directions: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
68 * |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
69 * The encoding and decoding routines could be moved to Lisp code |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
70 * similar to how xselect.c does it (using well-known routine names |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
71 * for the delayed rendering). If the definition of which clipboard |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
72 * types should be supported is also moved to Lisp, functionality |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
73 * could be expanded to CF_HTML, CF_RTF and maybe other types. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
74 */ |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
75 |
13434 | 76 #include <config.h> |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100951
diff
changeset
|
77 #include <setjmp.h> |
13434 | 78 #include "lisp.h" |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
79 #include "w32term.h" /* for all of the w32 includes */ |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
80 #include "w32heap.h" /* os_subtype */ |
13434 | 81 #include "blockinput.h" |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
82 #include "keyboard.h" /* cmd_error_internal() */ |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
83 #include "charset.h" |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
84 #include "coding.h" |
90930 | 85 #include "character.h" |
45988
37913830a881
Include composite.h
Juanma Barranquero <lekktu@gmail.com>
parents:
45984
diff
changeset
|
86 #include "composite.h" |
13434 | 87 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
88 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
89 static HGLOBAL convert_to_handle_as_ascii (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
90 static HGLOBAL convert_to_handle_as_coded (Lisp_Object coding_system); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
91 static Lisp_Object render (Lisp_Object oformat); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
92 static Lisp_Object render_locale (void); |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
93 static Lisp_Object render_all (Lisp_Object ignore); |
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
94 static void run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
95 static Lisp_Object lisp_error_handler (Lisp_Object error); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
96 static LRESULT CALLBACK owner_callback (HWND win, UINT msg, |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
97 WPARAM wp, LPARAM lp); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
98 static HWND create_owner (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
99 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
100 static void setup_config (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
101 static BOOL WINAPI enum_locale_callback (/*const*/ char* loc_string); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
102 static UINT cp_from_locale (LCID lcid, UINT format); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
103 static Lisp_Object coding_from_cp (UINT codepage); |
90157 | 104 static Lisp_Object validate_coding_system (Lisp_Object coding_system); |
105 static void setup_windows_coding_system (Lisp_Object coding_system, | |
106 struct coding_system * coding); | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
107 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
108 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
109 /* A remnant from X11: Symbol for the CLIPBORD selection type. Other |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
110 selections are not used on Windows, so we don't need symbols for |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
111 PRIMARY and SECONDARY. */ |
15235 | 112 Lisp_Object QCLIPBOARD; |
113 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
114 /* 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
|
115 clipboard. */ |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
116 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
|
117 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
118 /* 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
|
119 static Lisp_Object Vnext_selection_coding_system; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
120 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
121 /* 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
|
122 based on current system parameters. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
123 static LCID DEFAULT_LCID; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
124 static UINT ANSICP, OEMCP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
125 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
|
126 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
127 /* 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
|
128 static HWND clipboard_owner; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
129 /* 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
|
130 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
|
131 static int modifying_clipboard = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
132 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
133 /* 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
|
134 selection-coding-system. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
135 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
|
136 static UINT cfg_codepage; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
137 static LCID cfg_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
138 static UINT cfg_clipboard_type; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
139 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
140 /* 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
|
141 static Lisp_Object current_text; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
142 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
|
143 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
|
144 static UINT current_clipboard_type; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
145 static LCID current_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
146 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
147 #if TRACE |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
148 #define ONTRACE(stmt) stmt |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
149 #else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
150 #define ONTRACE(stmt) /*stmt*/ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
151 #endif |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
154 /* 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
|
155 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
|
156 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
157 static HGLOBAL |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
158 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
|
159 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
160 HGLOBAL htext = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
161 int nbytes; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
162 int truelen; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
163 unsigned char *src; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
164 unsigned char *dst; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
165 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
166 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
|
167 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
168 nbytes = SBYTES (current_text) + 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
169 src = SDATA (current_text); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
170 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
171 /* 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
|
172 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
|
173 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
|
174 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
175 truelen = nbytes + current_num_nls; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
176 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
177 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
|
178 return NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
179 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
180 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
|
181 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
182 GlobalFree (htext); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
183 return NULL; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
186 /* 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
|
187 while (1) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
188 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
189 unsigned char *next; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
190 /* 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
|
191 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
|
192 if (next) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
193 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
194 /* 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
|
195 int copied = next - dst; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
196 nbytes -= copied; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
197 src += copied; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
198 /* insert '\r' before '\n' */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
199 next[-1] = '\r'; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
200 next[0] = '\n'; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
201 dst = next + 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
202 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
203 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
204 /* 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
|
205 break; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
208 GlobalUnlock (htext); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
209 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
210 return htext; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
213 /* 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
|
214 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
|
215 text through the encoding machinery. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
216 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
217 static HGLOBAL |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
218 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
|
219 { |
90157 | 220 HGLOBAL htext; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
221 unsigned char *dst = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
222 struct coding_system coding; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
223 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
224 ONTRACE (fprintf (stderr, "convert_to_handle_as_coded: %s\n", |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
225 SDATA (SYMBOL_NAME (coding_system)))); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
226 |
90157 | 227 setup_windows_coding_system (coding_system, &coding); |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
228 coding.dst_bytes = SBYTES (current_text) * 2; |
90157 | 229 coding.destination = (unsigned char *) xmalloc (coding.dst_bytes); |
230 encode_coding_object (&coding, current_text, 0, 0, | |
231 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
|
232 |
90157 | 233 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
|
234 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
235 if (htext != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
236 dst = (unsigned char *) GlobalLock (htext); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
237 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
238 if (dst != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
239 { |
90157 | 240 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
|
241 /* 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
|
242 producing Unicode here. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
243 dst[coding.produced] = dst[coding.produced+1] = '\0'; |
90157 | 244 |
245 GlobalUnlock (htext); | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
246 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
247 |
90157 | 248 xfree (coding.destination); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
249 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
250 return htext; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
253 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
254 render (Lisp_Object oformat) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
255 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
256 HGLOBAL htext = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
257 UINT format = XFASTINT (oformat); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
258 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
259 ONTRACE (fprintf (stderr, "render\n")); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
260 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
261 if (NILP (current_text)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
262 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
263 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
264 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
|
265 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
266 if (format == current_clipboard_type) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
267 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
|
268 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
269 switch (format) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
270 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
271 case CF_UNICODETEXT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
272 htext = convert_to_handle_as_coded (QUNICODE); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
273 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
274 case CF_TEXT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
275 case CF_OEMTEXT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
276 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
277 Lisp_Object cs; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
278 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
|
279 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
|
280 break; |
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 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
284 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
285 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
|
286 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
287 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
|
288 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
289 if (htext == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
290 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
291 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
292 if (SetClipboardData (format, htext) == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
293 { |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
294 GlobalFree (htext); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
295 return Qnil; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
298 return Qt; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
301 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
302 render_locale (void) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
303 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
304 HANDLE hlocale = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
305 LCID * lcid_ptr; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
306 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
307 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
|
308 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
309 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
|
310 return Qt; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
311 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
312 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
|
313 if (hlocale == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
314 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
315 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
316 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
|
317 { |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
318 GlobalFree (hlocale); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
319 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
320 } |
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
|
321 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
322 *lcid_ptr = current_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
323 GlobalUnlock (hlocale); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
324 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
325 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
|
326 { |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
327 GlobalFree (hlocale); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
328 return Qnil; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
331 return Qt; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
334 /* 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
|
335 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
|
336 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
337 static Lisp_Object |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
338 render_all (Lisp_Object ignore) |
13434 | 339 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
340 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
|
341 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
342 /* 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
|
343 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
|
344 it is actually necessary. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
345 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
346 OpenClipboard (NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
347 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
348 /* 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
|
349 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
|
350 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
|
351 bothering with error handling. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
352 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
353 ++modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
354 EmptyClipboard (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
355 --modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
356 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
357 /* 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
363 - 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
|
364 (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
|
365 CF_UNICODETEXT. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
366 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
367 - 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
|
368 for CF_TEXT. |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
369 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
370 - 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
|
371 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
|
372 it. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
373 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
374 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
|
375 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
|
376 conversions, just in case. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
377 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
384 render_locale (); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
385 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
386 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
|
387 render (make_number (CF_TEXT)); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
388 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
|
389 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
390 CloseClipboard (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
391 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
392 return Qnil; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
395 static void |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
396 run_protected (Lisp_Object (*code) (Lisp_Object), Lisp_Object arg) |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
397 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
398 /* 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
|
399 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
|
400 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
|
401 |
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 | 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 | 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 | 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 | 488 } |
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 | 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 | 497 Lisp_Object coding_system; |
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 | 502 coding_system = NILP (Vnext_selection_coding_system) ? |
503 Vselection_coding_system : Vnext_selection_coding_system; | |
504 | |
505 dos_coding_system = validate_coding_system (coding_system); | |
506 if (NILP (dos_coding_system)) | |
507 Fsignal (Qerror, | |
508 list2 (build_string ("Coding system is invalid or doesn't have " | |
509 "an eol variant for dos line ends"), | |
510 coding_system)); | |
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 | 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 | 516 cfg_coding_system = dos_coding_system; |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
517 |
60092
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 | 568 } |
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 } |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
586 |
60092
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 | 625 /* We don't need to check that this coding system actually exists |
626 right here, because that is done later for all coding systems | |
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 | 630 static Lisp_Object |
631 validate_coding_system (Lisp_Object coding_system) | |
632 { | |
633 Lisp_Object eol_type; | |
634 | |
635 /* Make sure the input is valid. */ | |
636 if (NILP (Fcoding_system_p (coding_system))) | |
637 return Qnil; | |
638 | |
639 /* Make sure we use a DOS coding system as mandated by the system | |
640 specs. */ | |
641 eol_type = Fcoding_system_eol_type (coding_system); | |
642 | |
643 /* Already a DOS coding system? */ | |
644 if (EQ (eol_type, make_number (1))) | |
645 return coding_system; | |
646 | |
647 /* Get EOL_TYPE vector of the base of CODING_SYSTEM. */ | |
648 if (!VECTORP (eol_type)) | |
649 { | |
650 eol_type = Fcoding_system_eol_type (Fcoding_system_base (coding_system)); | |
651 if (!VECTORP (eol_type)) | |
652 return Qnil; | |
653 } | |
654 | |
655 return AREF (eol_type, 1); | |
656 } | |
657 | |
658 static void | |
659 setup_windows_coding_system (Lisp_Object coding_system, | |
660 struct coding_system * coding) | |
661 { | |
662 memset (coding, 0, sizeof (*coding)); | |
663 setup_coding_system (coding_system, coding); | |
664 | |
665 /* Unset CODING_ANNOTATE_COMPOSITION_MASK. Previous code had | |
666 comments about crashes in encode_coding_iso2022 trying to | |
667 dereference a null pointer when composition was on. Selection | |
668 data should not contain any composition sequence on Windows. | |
669 | |
670 CODING_ANNOTATION_MASK also includes | |
671 CODING_ANNOTATE_DIRECTION_MASK and CODING_ANNOTATE_CHARSET_MASK, | |
672 which both apply to ISO6429 only. We don't know if these really | |
673 need to be unset on Windows, but it probably doesn't hurt | |
674 either. */ | |
675 coding->mode &= ~CODING_ANNOTATION_MASK; | |
676 coding->mode |= CODING_MODE_LAST_BLOCK | CODING_MODE_SAFE_ENCODING; | |
677 } | |
678 | |
679 | |
13434 | 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. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
684 (Lisp_Object string, Lisp_Object ignored) |
13434 | 685 { |
686 BOOL ok = TRUE; | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
687 int nbytes; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
688 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
689 unsigned char *dst; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
690 unsigned char *end; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
691 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
692 /* 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
|
693 that any more. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
694 (void) ignored; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
695 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
33697
diff
changeset
|
696 CHECK_STRING (string); |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
697 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
698 setup_config (); |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
699 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
700 current_text = string; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
701 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
|
702 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
|
703 current_lcid = cfg_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
704 current_num_nls = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
705 current_requires_encoding = 0; |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
706 |
13434 | 707 BLOCK_INPUT; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
708 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
709 /* 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
|
710 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
|
711 (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
|
712 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
|
713 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
|
714 src = SDATA (string); |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
715 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
716 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
|
717 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
718 if (*dst == '\n') |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
719 current_num_nls++; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
720 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
|
721 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
722 current_requires_encoding = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
723 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
724 } |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
725 } |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
726 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
727 if (!current_requires_encoding) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
728 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
729 /* 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
|
730 anything fancy. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
731 current_coding_system = Qraw_text; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
732 current_clipboard_type = CF_TEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
733 current_lcid = LOCALE_NEUTRAL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
734 } |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
735 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
736 if (!OpenClipboard (clipboard_owner)) |
13434 | 737 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
|
738 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
739 ++modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
740 ok = EmptyClipboard (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
741 --modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
742 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
743 /* If 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
|
744 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
|
745 if (ok) |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
746 ok = !NILP (render_locale ()); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
747 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
748 if (ok) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
749 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
750 if (clipboard_owner == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
751 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
752 /* 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
|
753 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
|
754 and than forget about the whole thing. */ |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
755 ok = !NILP (render (make_number (current_clipboard_type))); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
756 current_text = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
757 current_coding_system = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
758 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
759 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
760 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
761 /* 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
|
762 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
|
763 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
|
764 the handler for WM_RENDERALLFORMATS. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
765 SetClipboardData (CF_UNICODETEXT, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
766 SetClipboardData (CF_TEXT, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
767 SetClipboardData (CF_OEMTEXT, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
768 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
769 } |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
770 |
54974
64d01f3f16e5
(Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents:
53798
diff
changeset
|
771 CloseClipboard (); |
64d01f3f16e5
(Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents:
53798
diff
changeset
|
772 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
773 /* 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
|
774 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
|
775 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
|
776 circumstances. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
777 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
778 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
|
779 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
|
780 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
|
781 if (ok) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
782 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
|
783 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
784 Vnext_selection_coding_system = Qnil; |
51777
940c7de274a2
(last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
47879
diff
changeset
|
785 |
13434 | 786 if (ok) goto done; |
787 | |
788 error: | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
789 |
13434 | 790 ok = FALSE; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
791 current_text = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
792 current_coding_system = Qnil; |
51777
940c7de274a2
(last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
47879
diff
changeset
|
793 |
13434 | 794 done: |
795 UNBLOCK_INPUT; | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
796 |
13434 | 797 return (ok ? string : Qnil); |
798 } | |
799 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
800 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
801 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
|
802 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
|
803 doc: /* This gets the clipboard data in text format. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
804 (Lisp_Object ignored) |
13434 | 805 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
806 HGLOBAL htext; |
13434 | 807 Lisp_Object ret = Qnil; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
808 UINT actual_clipboard_type; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
809 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
|
810 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
811 /* 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
|
812 that any more. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
813 (void) ignored; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
814 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
815 /* 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
|
816 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
|
817 if (!NILP (current_text)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
818 return ret; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
819 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
820 setup_config (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
821 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
|
822 |
13434 | 823 BLOCK_INPUT; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
824 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
825 if (!OpenClipboard (clipboard_owner)) |
13434 | 826 goto done; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
827 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
828 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
|
829 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
830 /* 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
|
831 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
|
832 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
|
833 we get down below. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
834 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
|
835 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
836 htext = GetClipboardData (CF_TEXT); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
837 if (htext != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
838 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
839 actual_clipboard_type = CF_TEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
840 use_configured_coding_system = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
841 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
842 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
843 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
844 if (htext == NULL) |
13434 | 845 goto closeclip; |
846 | |
847 { | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
848 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
849 unsigned char *dst; |
13434 | 850 int nbytes; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
851 int truelen; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
852 int require_decoding = 0; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
853 |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
854 if ((src = (unsigned char *) GlobalLock (htext)) == NULL) |
13434 | 855 goto closeclip; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
856 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
857 /* 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
|
858 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
|
859 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
|
860 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
861 nbytes = lstrlenW ((WCHAR *)src) * 2; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
862 require_decoding = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
863 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
864 else |
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 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
|
867 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
868 nbytes = strlen (src); |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
869 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
870 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
|
871 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
872 if (src[i] >= 0x80) |
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 require_decoding = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
875 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
876 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
877 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
878 } |
43483
dcb45a76827f
(Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
879 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
880 if (require_decoding) |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
881 { |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
882 struct coding_system coding; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
883 Lisp_Object coding_system = Qnil; |
90157 | 884 Lisp_Object dos_coding_system; |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
885 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
886 /* `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
|
887 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
|
888 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
|
889 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
|
890 if (use_configured_coding_system |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
891 && !NILP (Vnext_selection_coding_system)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
892 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
|
893 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
894 /* 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
|
895 CF_LOCALE, too. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
896 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
|
897 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
898 HGLOBAL hlocale; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
899 LCID lcid = DEFAULT_LCID; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
900 UINT cp; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
901 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
902 /* 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
|
903 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
|
904 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
|
905 always true on 9x ;-(. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
906 hlocale = GetClipboardData (CF_LOCALE); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
907 if (hlocale != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
908 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
909 const LCID * lcid_ptr; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
910 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
|
911 if (lcid_ptr != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
912 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
913 lcid = *lcid_ptr; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
914 GlobalUnlock (hlocale); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
915 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
916 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
917 /* 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
|
918 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
|
919 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
|
920 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
|
921 avoid irritations. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
922 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
|
923 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
924 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
925 /* 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
|
926 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
|
927 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
|
928 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
|
929 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
|
930 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
931 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
|
932 /* 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
|
933 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
|
934 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
|
935 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
|
936 system. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
937 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
|
938 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
|
939 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
940 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
941 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
942 if (NILP (coding_system)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
943 coding_system = Vselection_coding_system; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
944 Vnext_selection_coding_system = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
945 |
90157 | 946 dos_coding_system = validate_coding_system (coding_system); |
947 if (!NILP (dos_coding_system)) | |
948 { | |
949 setup_windows_coding_system (dos_coding_system, &coding); | |
950 coding.source = src; | |
951 decode_coding_object (&coding, Qnil, 0, 0, nbytes, nbytes, Qt); | |
952 ret = coding.dst_object; | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
953 |
90157 | 954 Vlast_coding_system_used = CODING_ID_NAME (coding.id); |
955 } | |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
956 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
957 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
958 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
959 /* 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
|
960 the Unicode case. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
961 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
962 /* 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
|
963 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
|
964 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
|
965 part of CRLF. */ |
13434 | 966 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
967 truelen = nbytes; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
968 dst = src; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
969 /* 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
|
970 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
|
971 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
972 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
|
973 truelen--; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
974 dst++; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
975 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
976 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
977 ret = make_uninit_string (truelen); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
978 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
979 /* 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
|
980 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
|
981 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45988
diff
changeset
|
982 dst = SDATA (ret); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
983 while (1) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
984 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
985 unsigned char *next; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
986 /* 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
|
987 next = _memccpy (dst, src, '\r', nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
988 if (next) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
989 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
990 /* copied one line ending with '\r' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
991 int copied = next - dst; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
992 nbytes -= copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
993 dst += copied; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
994 src += copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
995 if (*src == '\n') |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
996 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
|
997 } |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
998 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
999 /* copied remaining partial line -> now finished */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
1000 break; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
1001 } |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
1002 |
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
1003 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
|
1004 } |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1005 |
13434 | 1006 GlobalUnlock (htext); |
1007 } | |
1008 | |
1009 closeclip: | |
1010 CloseClipboard (); | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
1011 |
13434 | 1012 done: |
1013 UNBLOCK_INPUT; | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
1014 |
13434 | 1015 return (ret); |
1016 } | |
1017 | |
15235 | 1018 /* Support checking for a clipboard selection. */ |
1019 | |
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 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
|
1025 \(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
|
1026 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
|
1027 and t is the same as `SECONDARY'. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1028 (Lisp_Object selection) |
15235 | 1029 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
33697
diff
changeset
|
1030 CHECK_SYMBOL (selection); |
15235 | 1031 |
1032 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check | |
1033 if the clipboard currently has valid text format contents. */ | |
1034 | |
1035 if (EQ (selection, QCLIPBOARD)) | |
1036 { | |
1037 Lisp_Object val = Qnil; | |
1038 | |
90157 | 1039 setup_config (); |
1040 | |
15235 | 1041 if (OpenClipboard (NULL)) |
1042 { | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1043 UINT format = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1044 while ((format = EnumClipboardFormats (format))) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1045 /* 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
|
1046 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
|
1047 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
|
1048 should be enough. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1049 if (format == cfg_clipboard_type || format == CF_TEXT) |
15235 | 1050 { |
1051 val = Qt; | |
1052 break; | |
1053 } | |
1054 CloseClipboard (); | |
1055 } | |
1056 return val; | |
1057 } | |
1058 return Qnil; | |
1059 } | |
1060 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1061 /* 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
|
1062 dumped version. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1063 |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
1064 void |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1065 syms_of_w32select (void) |
13434 | 1066 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
1067 defsubr (&Sw32_set_clipboard_data); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
1068 defsubr (&Sw32_get_clipboard_data); |
15235 | 1069 defsubr (&Sx_selection_exists_p); |
1070 | |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
1071 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
|
1072 doc: /* Coding system for communicating with other programs. |
111136
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1073 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1074 For MS-Windows and MS-DOS: |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1075 When sending or receiving text via selection and clipboard, the text |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1076 is encoded or decoded by this coding system. The default value is |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1077 the current system default encoding on 9x/Me, `utf-16le-dos' |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1078 \(Unicode) on NT/W2K/XP, and `iso-latin-1-dos' on MS-DOS. |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1079 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1080 For X Windows: |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1081 When sending text via selection and clipboard, if the target |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1082 data-type matches with the type of this coding system, it is used |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1083 for encoding the text. Otherwise (including the case that this |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1084 variable is nil), a proper coding system is used as below: |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1085 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1086 data-type coding system |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1087 --------- ------------- |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1088 UTF8_STRING utf-8 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1089 COMPOUND_TEXT compound-text-with-extensions |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1090 STRING iso-latin-1 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1091 C_STRING no-conversion |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1092 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1093 When receiving text, if this coding system is non-nil, it is used |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1094 for decoding regardless of the data-type. If this is nil, a |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1095 proper coding system is used according to the data-type as above. |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1096 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1097 See also the documentation of the variable `x-select-request-type' how |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1098 to control which data-type to request for receiving text. |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1099 |
bc1274182cc8
Sync docs of selection-coding-system between C and Lisp.
Glenn Morris <rgm@gnu.org>
parents:
111135
diff
changeset
|
1100 The default value is nil. */); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1101 /* 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
|
1102 below. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1103 Vselection_coding_system = Qnil; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
1104 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
1105 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
|
1106 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
|
1107 Usually, `selection-coding-system' is used for communicating with |
111135
600f564fdc23
Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents:
110997
diff
changeset
|
1108 other programs (X Windows clients or MS Windows programs). But, if this |
600f564fdc23
Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents:
110997
diff
changeset
|
1109 variable is set, it is used for the next communication only. |
600f564fdc23
Sync Lisp and C docs of next-selection-coding-system.
Glenn Morris <rgm@gnu.org>
parents:
110997
diff
changeset
|
1110 After the communication, this variable is set to nil. */); |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
1111 Vnext_selection_coding_system = Qnil; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
1112 |
90922
a4f75e39ca14
(syms_of_w32select): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents:
90737
diff
changeset
|
1113 DEFSYM (QCLIPBOARD, "CLIPBOARD"); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1114 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1115 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
|
1116 current_text = Qnil; staticpro (¤t_text); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1117 current_coding_system = Qnil; staticpro (¤t_coding_system); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1118 |
90922
a4f75e39ca14
(syms_of_w32select): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents:
90737
diff
changeset
|
1119 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
|
1120 QANSICP = Qnil; staticpro (&QANSICP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1121 QOEMCP = Qnil; staticpro (&QOEMCP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1122 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1123 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1124 /* 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
|
1125 un-dumped version. */ |
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 void |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1128 globals_of_w32select (void) |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1129 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1130 DEFAULT_LCID = GetUserDefaultLCID (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1131 /* 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
|
1132 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
|
1133 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
|
1134 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1135 ANSICP = GetACP (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1136 OEMCP = GetOEMCP (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1137 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1138 QANSICP = coding_from_cp (ANSICP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1139 QOEMCP = coding_from_cp (OEMCP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1140 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1141 if (os_subtype == OS_NT) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1142 Vselection_coding_system = QUNICODE; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1143 else if (inhibit_window_system) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1144 Vselection_coding_system = QOEMCP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1145 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1146 Vselection_coding_system = QANSICP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1147 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1148 clipboard_owner = create_owner (); |
13434 | 1149 } |
52401 | 1150 |