Mercurial > emacs
annotate src/w32select.c @ 64680:32b32ccdedc0
Update. Include emacs-devel message fragment.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Fri, 29 Jul 2005 18:05:51 +0000 |
parents | a8fa7c632ee4 |
children | a0d1312ede66 f9a65d7ebd29 |
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. |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
2 Copyright (C) 1993, 1994, 2004 Free Software Foundation. |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
3 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
4 This file is part of GNU Emacs. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
5 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
9 any later version. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
10 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
14 GNU General Public License for more details. |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
15 |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13434
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
64084 | 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 Boston, MA 02110-1301, USA. */ | |
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). |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
34 * |
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: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
49 * |
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) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
53 * |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
54 * Or |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
55 * |
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 */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
75 |
13434 | 76 #include <config.h> |
77 #include "lisp.h" | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
78 #include "w32term.h" /* for all of the w32 includes */ |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
79 #include "w32heap.h" /* os_subtype */ |
13434 | 80 #include "blockinput.h" |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
81 #include "keyboard.h" /* cmd_error_internal() */ |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
82 #include "charset.h" |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
83 #include "coding.h" |
45988
37913830a881
Include composite.h
Juanma Barranquero <lekktu@gmail.com>
parents:
45984
diff
changeset
|
84 #include "composite.h" |
13434 | 85 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
86 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
87 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
|
88 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
|
89 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
|
90 static Lisp_Object render_locale (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
91 static Lisp_Object render_all (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
92 static void run_protected (Lisp_Object (*code) (), Lisp_Object arg); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
93 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
|
94 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
|
95 WPARAM wp, LPARAM lp); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
96 static HWND create_owner (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
97 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
98 static void setup_config (void); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
99 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
|
100 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
|
101 static Lisp_Object coding_from_cp (UINT codepage); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
102 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
103 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
104 /* 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
|
105 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
|
106 PRIMARY and SECONDARY. */ |
15235 | 107 Lisp_Object QCLIPBOARD; |
108 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
109 /* 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
|
110 clipboard. */ |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
111 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
|
112 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
113 /* Coding system for the next communication with other programs. */ |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
114 static Lisp_Object Vnext_selection_coding_system; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
115 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
116 /* 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
|
117 based on current system parameters. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
118 static LCID DEFAULT_LCID; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
119 static UINT ANSICP, OEMCP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
120 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
|
121 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
122 /* 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
|
123 static HWND clipboard_owner; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
124 /* 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
|
125 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
|
126 static int modifying_clipboard = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
127 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
128 /* 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
|
129 selection-coding-system. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
130 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
|
131 static UINT cfg_codepage; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
132 static LCID cfg_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
133 static UINT cfg_clipboard_type; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
134 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
135 /* 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
|
136 static Lisp_Object current_text; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
137 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
|
138 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
|
139 static UINT current_clipboard_type; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
140 static LCID current_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
141 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
142 #if TRACE |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
143 #define ONTRACE(stmt) stmt |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
144 #else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
145 #define ONTRACE(stmt) /*stmt*/ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
146 #endif |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
147 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
148 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
149 /* 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
|
150 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
|
151 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
152 static HGLOBAL |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
153 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
|
154 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
155 HGLOBAL htext = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
156 int nbytes; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
157 int truelen; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
158 unsigned char *src; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
159 unsigned char *dst; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
160 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
161 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
|
162 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
163 nbytes = SBYTES (current_text) + 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
164 src = SDATA (current_text); |
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 /* 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
|
167 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
|
168 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
|
169 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
170 truelen = nbytes + current_num_nls; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
171 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
172 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
|
173 return NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
174 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
175 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
|
176 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
177 GlobalFree (htext); |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
181 /* 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
|
182 while (1) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
183 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
184 unsigned char *next; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
185 /* 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
|
186 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
|
187 if (next) |
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 /* 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
|
190 int copied = next - dst; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
191 nbytes -= copied; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
192 src += copied; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
193 /* insert '\r' before '\n' */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
194 next[-1] = '\r'; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
195 next[0] = '\n'; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
196 dst = next + 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
197 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
198 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
199 /* 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
|
200 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
201 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
202 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
203 GlobalUnlock (htext); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
204 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
205 return htext; |
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 /* 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
|
209 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
|
210 text through the encoding machinery. */ |
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 static HGLOBAL |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
213 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
|
214 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
215 HGLOBAL htext = NULL, htext2; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
216 int nbytes; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
217 unsigned char *src; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
218 unsigned char *dst = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
219 int bufsize; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
220 struct coding_system coding; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
221 Lisp_Object string = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
222 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
223 ONTRACE (fprintf (stderr, "convert_to_handle_as_coded: %s\n", |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
224 SDATA (SYMBOL_NAME (coding_system)))); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
225 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
226 setup_coding_system (Fcheck_coding_system (coding_system), &coding); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
227 coding.src_multibyte = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
228 coding.dst_multibyte = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
229 /* Need to set COMPOSITION_DISABLED, otherwise Emacs crashes in |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
230 encode_coding_iso2022 trying to dereference a null pointer. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
231 coding.composing = COMPOSITION_DISABLED; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
232 if (coding.type == coding_type_iso2022) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
233 coding.flags |= CODING_FLAG_ISO_SAFE; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
234 coding.mode |= CODING_MODE_LAST_BLOCK; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
235 /* Force DOS line-ends. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
236 coding.eol_type = CODING_EOL_CRLF; |
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 (SYMBOLP (coding.pre_write_conversion) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
239 && !NILP (Ffboundp (coding.pre_write_conversion))) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
240 string = run_pre_post_conversion_on_str (current_text, &coding, 1); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
241 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
242 string = current_text; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
243 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
244 nbytes = SBYTES (string); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
245 src = SDATA (string); |
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 bufsize = encoding_buffer_size (&coding, nbytes) +2; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
248 htext = GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, bufsize); |
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 if (htext != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
251 dst = (unsigned char *) GlobalLock (htext); |
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 if (dst != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
254 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
255 encode_coding (&coding, src, dst, nbytes, bufsize-2); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
256 /* 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
|
257 producing Unicode here. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
258 dst[coding.produced] = dst[coding.produced+1] = '\0'; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
259 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
260 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
261 if (dst != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
262 GlobalUnlock (htext); |
51777
940c7de274a2
(last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
47879
diff
changeset
|
263 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
264 if (htext != NULL) |
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 /* Shrink data block to actual size. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
267 htext2 = GlobalReAlloc (htext, coding.produced+2, |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
268 GMEM_MOVEABLE | GMEM_DDESHARE); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
269 if (htext2 != NULL) htext = htext2; |
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 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
272 return htext; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
273 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
274 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
275 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
276 render (Lisp_Object oformat) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
277 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
278 HGLOBAL htext = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
279 UINT format = XFASTINT (oformat); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
280 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
281 ONTRACE (fprintf (stderr, "render\n")); |
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 if (NILP (current_text)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
284 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
285 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
286 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
|
287 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
288 if (format == current_clipboard_type) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
289 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
|
290 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
291 switch (format) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
292 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
293 case CF_UNICODETEXT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
294 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
|
295 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
296 case CF_TEXT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
297 case CF_OEMTEXT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
298 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
299 Lisp_Object cs; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
300 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
|
301 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
|
302 break; |
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 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
305 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
306 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
307 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
|
308 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
309 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
|
310 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
311 if (htext == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
312 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
313 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
314 if (SetClipboardData (format, htext) == NULL) |
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 GlobalFree(htext); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
317 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
318 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
319 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
320 return Qt; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
321 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
322 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
323 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
324 render_locale (void) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
325 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
326 HANDLE hlocale = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
327 LCID * lcid_ptr; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
328 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
329 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
|
330 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
331 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
|
332 return Qt; |
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 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
|
335 if (hlocale == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
336 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
337 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
338 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
|
339 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
340 GlobalFree(hlocale); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
341 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
342 } |
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
|
343 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
344 *lcid_ptr = current_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
345 GlobalUnlock (hlocale); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
346 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
347 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
|
348 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
349 GlobalFree(hlocale); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
350 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
351 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
352 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
353 return Qt; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
354 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
355 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
356 /* 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
|
357 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
|
358 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
359 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
360 render_all (void) |
13434 | 361 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
362 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
|
363 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
364 /* 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
|
365 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
|
366 it is actually necessary. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
367 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
368 OpenClipboard (NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
369 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
370 /* 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
|
371 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
|
372 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
|
373 bothering with error handling. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
374 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
375 ++modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
376 EmptyClipboard (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
377 --modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
378 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
379 /* 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
385 - 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
|
386 (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
|
387 CF_UNICODETEXT. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
388 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
389 - 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
|
390 for CF_TEXT. |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
391 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
392 - 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
|
393 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
|
394 it. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
395 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
396 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
|
397 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
|
398 conversions, just in case. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
399 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 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
|
404 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
|
405 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
406 render_locale(); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
407 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
408 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
|
409 render (make_number (CF_TEXT)); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
410 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
|
411 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
412 CloseClipboard (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
413 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
414 return Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
415 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
416 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
417 static void |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
418 run_protected (Lisp_Object (*code) (), Lisp_Object arg) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
419 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
420 /* 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
|
421 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
|
422 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
|
423 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
424 extern int waiting_for_input; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
425 int owfi; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
426 |
13434 | 427 BLOCK_INPUT; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
428 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
429 /* 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
|
430 set. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
431 owfi = waiting_for_input; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
432 waiting_for_input = 0; |
13434 | 433 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
434 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
|
435 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
436 waiting_for_input = owfi; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
437 |
13434 | 438 UNBLOCK_INPUT; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
439 } |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
440 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
441 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
442 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
|
443 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
444 Vsignaling_function = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
445 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
|
446 Vinhibit_quit = Qt; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
447 return Qt; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
448 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
449 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
450 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
451 static LRESULT CALLBACK |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
452 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
|
453 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
454 switch (msg) |
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_RENDERFORMAT: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
457 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
|
458 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
|
459 return 0; |
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 case WM_RENDERALLFORMATS: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
462 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
|
463 run_protected (render_all, Qnil); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
464 return 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
465 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
466 case WM_DESTROYCLIPBOARD: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
467 if (!modifying_clipboard) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
468 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
469 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
|
470 current_text = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
471 current_coding_system = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
472 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
473 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
474 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
475 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
|
476 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
477 return 0; |
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 case WM_DESTROY: |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
480 if (win == clipboard_owner) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
481 clipboard_owner = NULL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
482 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
483 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
484 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
485 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
|
486 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
487 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
488 static HWND |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
489 create_owner (void) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
490 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
491 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
|
492 WNDCLASS wc; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
493 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
494 memset (&wc, 0, sizeof (wc)); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
495 wc.lpszClassName = CLASSNAME; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
496 wc.lpfnWndProc = owner_callback; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
497 RegisterClass (&wc); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
498 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
499 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
|
500 NULL, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
501 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
502 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
503 /* 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
|
504 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
505 void |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
506 term_w32select (void) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
507 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
508 /* 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
|
509 if (clipboard_owner != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
510 DestroyWindow (clipboard_owner); |
13434 | 511 } |
512 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
513 static void |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
514 setup_config (void) |
13434 | 515 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
516 const char *coding_name; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
517 const char *cp; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
518 char *end; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
519 int slen; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
520 Lisp_Object new_coding_system; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
521 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
522 CHECK_SYMBOL (Vselection_coding_system); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
523 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
524 /* 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
|
525 new_coding_system = NILP (Vnext_selection_coding_system) ? |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
526 Vselection_coding_system : Vnext_selection_coding_system; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
527 if (!NILP (cfg_coding_system) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
528 && EQ (cfg_coding_system, new_coding_system)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
529 return; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
530 cfg_coding_system = new_coding_system; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
531 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
532 /* Set some sensible fallbacks */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
533 cfg_codepage = ANSICP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
534 cfg_lcid = LOCALE_NEUTRAL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
535 cfg_clipboard_type = CF_TEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
536 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
537 /* 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
|
538 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
|
539 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
540 /* "(.*-)?utf-16.*" -> CF_UNICODETEXT */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
541 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
|
542 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
|
543 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
544 cfg_clipboard_type = CF_UNICODETEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
545 return; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
546 } |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
547 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
548 /* "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
|
549 slen = strlen (coding_name); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
550 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
|
551 cp = coding_name + 2; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
552 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
|
553 cp = coding_name + 8; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
554 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
555 return; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
556 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
557 end = (char*)cp; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
558 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
|
559 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
560 /* 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
|
561 default and drop it. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
562 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
|
563 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
564 cfg_codepage = ANSICP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
565 return; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
566 } |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
567 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
568 /* 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
|
569 if (cfg_codepage == ANSICP) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
570 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
571 /* cfg_clipboard_type = CF_TEXT; */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
572 return; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
573 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
574 if (cfg_codepage == OEMCP) |
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 cfg_clipboard_type = CF_OEMTEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
577 return; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
578 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
579 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
580 /* 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
|
581 EnumSystemLocales (enum_locale_callback, LCID_INSTALLED); |
13434 | 582 } |
583 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
584 static BOOL WINAPI |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
585 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
|
586 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
587 LCID lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
588 UINT codepage; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
589 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
590 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
|
591 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
592 /* 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
|
593 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
|
594 if (codepage == cfg_codepage) |
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 cfg_lcid = lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
597 cfg_clipboard_type = CF_TEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
598 return FALSE; /* Stop enumeration */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
599 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
600 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
601 /* 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
|
602 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
|
603 if (codepage == cfg_codepage) |
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 cfg_lcid = lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
606 cfg_clipboard_type = CF_OEMTEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
607 return FALSE; /* Stop enumeration */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
608 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
609 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
610 return TRUE; /* Continue enumeration */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
611 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
612 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
613 static UINT |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
614 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
|
615 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
616 char buffer[20] = ""; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
617 UINT variant, cp; |
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 variant = |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
620 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
|
621 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
622 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
|
623 cp = strtoul (buffer, NULL, 10); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
624 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
625 if (cp == CP_ACP) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
626 return ANSICP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
627 else if (cp == CP_OEMCP) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
628 return OEMCP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
629 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
630 return cp; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
631 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
632 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
633 static Lisp_Object |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
634 coding_from_cp (UINT codepage) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
635 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
636 char buffer[30]; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
637 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
|
638 return intern (buffer); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
639 /* We don't need to check that this coding system exists right here, |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
640 because that is done when the coding system is actually |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
641 instantiated, i.e. it is passed through Fcheck_coding_system() |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
642 there. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
643 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
644 |
13434 | 645 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
646 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
|
647 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
|
648 doc: /* This sets the clipboard data to the given text. */) |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
649 (string, ignored) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
650 Lisp_Object string, ignored; |
13434 | 651 { |
652 BOOL ok = TRUE; | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
653 int nbytes; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
654 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
655 unsigned char *dst; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
656 unsigned char *end; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
657 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
658 /* 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
|
659 that any more. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
660 (void) ignored; |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
661 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
33697
diff
changeset
|
662 CHECK_STRING (string); |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
663 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
664 setup_config (); |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
665 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
666 current_text = string; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
667 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
|
668 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
|
669 current_lcid = cfg_lcid; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
670 current_num_nls = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
671 current_requires_encoding = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
672 |
13434 | 673 BLOCK_INPUT; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
674 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
675 /* 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
|
676 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
|
677 (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
|
678 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
|
679 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
|
680 src = SDATA (string); |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
681 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
682 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
|
683 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
684 if (*dst == '\n') |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
685 current_num_nls++; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
686 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
|
687 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
688 current_requires_encoding = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
689 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
690 } |
24518
a0423d2b9302
(Fw32_set_clipboard_data): Take into account line
Andrew Innes <andrewi@gnu.org>
parents:
23874
diff
changeset
|
691 } |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
692 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
693 if (!current_requires_encoding) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
694 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
695 /* 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
|
696 anything fancy. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
697 current_coding_system = Qraw_text; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
698 current_clipboard_type = CF_TEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
699 current_lcid = LOCALE_NEUTRAL; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
700 } |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
701 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
702 if (!OpenClipboard (clipboard_owner)) |
13434 | 703 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
|
704 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
705 ++modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
706 ok = EmptyClipboard (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
707 --modifying_clipboard; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
708 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
709 /* 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
|
710 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
|
711 if (ok) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
712 ok = !NILP(render_locale()); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
713 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
714 if (ok) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
715 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
716 if (clipboard_owner == NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
717 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
718 /* 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
|
719 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
|
720 and than forget about the whole thing. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
721 ok = !NILP(render (make_number (current_clipboard_type))); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
722 current_text = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
723 current_coding_system = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
724 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
725 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
726 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
727 /* 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
|
728 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
|
729 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
|
730 the handler for WM_RENDERALLFORMATS. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
731 SetClipboardData (CF_UNICODETEXT, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
732 SetClipboardData (CF_TEXT, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
733 SetClipboardData (CF_OEMTEXT, NULL); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
734 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
735 } |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
736 |
54974
64d01f3f16e5
(Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents:
53798
diff
changeset
|
737 CloseClipboard (); |
64d01f3f16e5
(Fw32_set_clipboard_data): Get sequence number after closing the clipboard.
Jason Rumney <jasonr@gnu.org>
parents:
53798
diff
changeset
|
738 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
739 /* 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
|
740 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
|
741 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
|
742 circumstances. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
743 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
744 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
|
745 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
|
746 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
|
747 if (ok) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
748 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
|
749 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
750 Vnext_selection_coding_system = Qnil; |
51777
940c7de274a2
(last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
47879
diff
changeset
|
751 |
13434 | 752 if (ok) goto done; |
753 | |
754 error: | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
755 |
13434 | 756 ok = FALSE; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
757 current_text = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
758 current_coding_system = Qnil; |
51777
940c7de274a2
(last_clipboard_sequence_number): New variable.
Jason Rumney <jasonr@gnu.org>
parents:
47879
diff
changeset
|
759 |
13434 | 760 done: |
761 UNBLOCK_INPUT; | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
762 |
13434 | 763 return (ok ? string : Qnil); |
764 } | |
765 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
766 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
767 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
|
768 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
|
769 doc: /* This gets the clipboard data in text format. */) |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
770 (ignored) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
771 Lisp_Object ignored; |
13434 | 772 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
773 HGLOBAL htext; |
13434 | 774 Lisp_Object ret = Qnil; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
775 UINT actual_clipboard_type; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
776 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
|
777 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
778 /* 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
|
779 that any more. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
780 (void) ignored; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
781 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
782 /* 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
|
783 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
|
784 if (!NILP (current_text)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
785 return ret; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
786 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
787 setup_config (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
788 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
|
789 |
13434 | 790 BLOCK_INPUT; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
791 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
792 if (!OpenClipboard (clipboard_owner)) |
13434 | 793 goto done; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
794 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
795 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
|
796 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
797 /* 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
|
798 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
|
799 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
|
800 we get down below. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
801 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
|
802 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
803 htext = GetClipboardData (CF_TEXT); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
804 if (htext != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
805 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
806 actual_clipboard_type = CF_TEXT; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
807 use_configured_coding_system = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
808 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
809 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
810 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
811 if (htext == NULL) |
13434 | 812 goto closeclip; |
813 | |
814 { | |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
815 unsigned char *src; |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
816 unsigned char *dst; |
13434 | 817 int nbytes; |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
818 int truelen; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
819 int require_decoding = 0; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
820 |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
821 if ((src = (unsigned char *) GlobalLock (htext)) == NULL) |
13434 | 822 goto closeclip; |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
823 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
824 /* If 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
|
825 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
|
826 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
|
827 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
828 nbytes = lstrlenW ((WCHAR *)src) * 2; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
829 require_decoding = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
830 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
831 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
832 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
833 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
|
834 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
835 nbytes = strlen (src); |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
836 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
837 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
|
838 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
839 if (src[i] >= 0x80) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
840 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
841 require_decoding = 1; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
842 break; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
843 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
844 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
845 } |
43483
dcb45a76827f
(Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
846 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
847 if (require_decoding) |
15150
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
848 { |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
849 int bufsize; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
850 unsigned char *buf; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
851 struct coding_system coding; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
852 Lisp_Object coding_system = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
853 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
854 /* `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
|
855 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
|
856 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
|
857 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
|
858 if (use_configured_coding_system |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
859 && !NILP (Vnext_selection_coding_system)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
860 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
|
861 |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
862 /* 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
|
863 CF_LOCALE, too. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
864 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
|
865 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
866 HGLOBAL hlocale; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
867 LCID lcid = DEFAULT_LCID; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
868 UINT cp; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
869 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
870 /* 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
|
871 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
|
872 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
|
873 always true on 9x ;-(. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
874 hlocale = GetClipboardData (CF_LOCALE); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
875 if (hlocale != NULL) |
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 const LCID * lcid_ptr; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
878 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
|
879 if (lcid_ptr != NULL) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
880 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
881 lcid = *lcid_ptr; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
882 GlobalUnlock (hlocale); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
883 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
884 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
885 /* 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
|
886 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
|
887 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
|
888 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
|
889 avoid irritations. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
890 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
|
891 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
892 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
893 /* 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
|
894 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
|
895 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
|
896 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
|
897 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
|
898 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
899 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
|
900 /* 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
|
901 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
|
902 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
|
903 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
|
904 system. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
905 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
|
906 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
|
907 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
908 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
909 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
910 if (NILP (coding_system)) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
911 coding_system = Vselection_coding_system; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
912 Vnext_selection_coding_system = Qnil; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
913 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
914 setup_coding_system (Fcheck_coding_system (coding_system), &coding); |
29022
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
915 coding.src_multibyte = 0; |
3eec558de0ef
(Fw32_set_clipboard_data): Setup members
Kenichi Handa <handa@m17n.org>
parents:
27401
diff
changeset
|
916 coding.dst_multibyte = 1; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
917 coding.mode |= CODING_MODE_LAST_BLOCK; |
45984
f95eb5f690c3
(Fw32_get_clipboard_data): Disable composition handling.
Kenichi Handa <handa@m17n.org>
parents:
43483
diff
changeset
|
918 /* We explicitely disable composition handling because |
f95eb5f690c3
(Fw32_get_clipboard_data): Disable composition handling.
Kenichi Handa <handa@m17n.org>
parents:
43483
diff
changeset
|
919 selection data should not contain any composition |
f95eb5f690c3
(Fw32_get_clipboard_data): Disable composition handling.
Kenichi Handa <handa@m17n.org>
parents:
43483
diff
changeset
|
920 sequence. */ |
f95eb5f690c3
(Fw32_get_clipboard_data): Disable composition handling.
Kenichi Handa <handa@m17n.org>
parents:
43483
diff
changeset
|
921 coding.composing = COMPOSITION_DISABLED; |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
922 /* Force DOS line-ends. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
923 coding.eol_type = CODING_EOL_CRLF; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
924 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
925 bufsize = decoding_buffer_size (&coding, nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
926 buf = (unsigned char *) xmalloc (bufsize); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
927 decode_coding (&coding, src, buf, nbytes, bufsize); |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
928 Vlast_coding_system_used = coding.symbol; |
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
|
929 ret = make_string_from_bytes ((char *) buf, |
e7765cb122c3
(Fw32_set_clipboard_data): Save a copy of what is put on the clipboard.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
930 coding.produced_char, coding.produced); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
931 xfree (buf); |
43483
dcb45a76827f
(Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
932 if (SYMBOLP (coding.post_read_conversion) |
dcb45a76827f
(Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
933 && !NILP (Ffboundp (coding.post_read_conversion))) |
dcb45a76827f
(Fw32_set_clipboard_data): Run pre-write-conversion
Jason Rumney <jasonr@gnu.org>
parents:
40962
diff
changeset
|
934 ret = run_pre_post_conversion_on_str (ret, &coding, 0); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
935 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
936 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
937 { |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
938 /* 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
|
939 the Unicode case. */ |
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 /* 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
|
942 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
|
943 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
|
944 part of CRLF. */ |
13434 | 945 |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
946 truelen = nbytes; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
947 dst = src; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
948 /* 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
|
949 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
|
950 { |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
951 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
|
952 truelen--; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
953 dst++; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
954 } |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
955 |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
956 ret = make_uninit_string (truelen); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
957 |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
958 /* 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
|
959 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
|
960 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45988
diff
changeset
|
961 dst = SDATA (ret); |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
962 while (1) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
963 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
964 unsigned char *next; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
965 /* 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
|
966 next = _memccpy (dst, src, '\r', nbytes); |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
967 if (next) |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
968 { |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
969 /* copied one line ending with '\r' */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
970 int copied = next - dst; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
971 nbytes -= copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
972 dst += copied; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
973 src += copied; |
23835
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
974 if (*src == '\n') |
ad04307ef465
(Fw32_get_clipboard_data): Do not delete isolated CR
Geoff Voelker <voelker@cs.washington.edu>
parents:
23562
diff
changeset
|
975 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
|
976 } |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
977 else |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
978 /* copied remaining partial line -> now finished */ |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
979 break; |
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
980 } |
22745
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
981 |
ef9607e709bc
(Fw32_set_clipboard_data): Set Vlast_coding_system_used.
Andrew Innes <andrewi@gnu.org>
parents:
22545
diff
changeset
|
982 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
|
983 } |
e37489592e27
(Fwin32_set_clipboard_data, Fwin32_get_clipboard_data):
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
984 |
13434 | 985 GlobalUnlock (htext); |
986 } | |
987 | |
988 closeclip: | |
989 CloseClipboard (); | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
990 |
13434 | 991 done: |
992 UNBLOCK_INPUT; | |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
993 |
13434 | 994 return (ret); |
995 } | |
996 | |
15235 | 997 /* Support checking for a clipboard selection. */ |
998 | |
999 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 \(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
|
1005 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
|
1006 and t is the same as `SECONDARY'. */) |
15235 | 1007 (selection) |
1008 Lisp_Object selection; | |
1009 { | |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
33697
diff
changeset
|
1010 CHECK_SYMBOL (selection); |
15235 | 1011 |
1012 /* Return nil for PRIMARY and SECONDARY selections; for CLIPBOARD, check | |
1013 if the clipboard currently has valid text format contents. */ | |
1014 | |
1015 if (EQ (selection, QCLIPBOARD)) | |
1016 { | |
1017 Lisp_Object val = Qnil; | |
1018 | |
1019 if (OpenClipboard (NULL)) | |
1020 { | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1021 UINT format = 0; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1022 setup_config (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1023 while ((format = EnumClipboardFormats (format))) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1024 /* 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
|
1025 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
|
1026 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
|
1027 should be enough. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1028 if (format == cfg_clipboard_type || format == CF_TEXT) |
15235 | 1029 { |
1030 val = Qt; | |
1031 break; | |
1032 } | |
1033 CloseClipboard (); | |
1034 } | |
1035 return val; | |
1036 } | |
1037 return Qnil; | |
1038 } | |
1039 | |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1040 /* 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
|
1041 dumped version. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1042 |
47879
4ef507bc376e
(syms_of_win32select): Fix docstring for `selection-coding-system'.
Juanma Barranquero <lekktu@gmail.com>
parents:
47280
diff
changeset
|
1043 void |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
1044 syms_of_w32select () |
13434 | 1045 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
1046 defsubr (&Sw32_set_clipboard_data); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15235
diff
changeset
|
1047 defsubr (&Sw32_get_clipboard_data); |
15235 | 1048 defsubr (&Sx_selection_exists_p); |
1049 | |
22914
4d4e775cf6f7
(Vselection_coding_system): Renamed from Vclipboard_coding_system.
Richard M. Stallman <rms@gnu.org>
parents:
22745
diff
changeset
|
1050 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
|
1051 doc: /* Coding system for communicating with other programs. |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1052 When sending or receiving text via cut_buffer, selection, and |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1053 clipboard, the text is encoded or decoded by this coding system. |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1054 The default value is the current system default encoding on 9x/Me and |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1055 `utf-16le-dos' (Unicode) on NT/W2K/XP. */); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1056 /* 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
|
1057 below. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1058 Vselection_coding_system = Qnil; |
22545
5d3f50b4c8d2
Include buffer.h, charset.h, and coding.h.
Andrew Innes <andrewi@gnu.org>
parents:
16884
diff
changeset
|
1059 |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
1060 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
|
1061 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
|
1062 Usually, `selection-coding-system' is used for communicating with |
47280
7e81df5e2e1a
(syms_of_w32select): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
1063 other programs. But, if this variable is set, it is used for the |
7e81df5e2e1a
(syms_of_w32select): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
1064 next communication only. After the communication, this variable is |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40656
diff
changeset
|
1065 set to nil. */); |
23562
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
1066 Vnext_selection_coding_system = Qnil; |
5f3243813b18
(Vnext_selection_coding_system): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23422
diff
changeset
|
1067 |
15235 | 1068 QCLIPBOARD = intern ("CLIPBOARD"); staticpro (&QCLIPBOARD); |
60092
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1069 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1070 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
|
1071 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
|
1072 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
|
1073 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1074 QUNICODE = intern ("utf-16le-dos"); staticpro (&QUNICODE); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1075 QANSICP = Qnil; staticpro (&QANSICP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1076 QOEMCP = Qnil; staticpro (&QOEMCP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1077 } |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1078 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1079 /* 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
|
1080 un-dumped version. */ |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1081 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1082 void |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1083 globals_of_w32select () |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1084 { |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1085 DEFAULT_LCID = GetUserDefaultLCID (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1086 /* 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
|
1087 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
|
1088 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
|
1089 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1090 ANSICP = GetACP (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1091 OEMCP = GetOEMCP (); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1092 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1093 QANSICP = coding_from_cp (ANSICP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1094 QOEMCP = coding_from_cp (OEMCP); |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1095 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1096 if (os_subtype == OS_NT) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1097 Vselection_coding_system = QUNICODE; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1098 else if (inhibit_window_system) |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1099 Vselection_coding_system = QOEMCP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1100 else |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1101 Vselection_coding_system = QANSICP; |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1102 |
04686828d0da
2004-11-08 Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>
Jason Rumney <jasonr@gnu.org>
parents:
56299
diff
changeset
|
1103 clipboard_owner = create_owner (); |
13434 | 1104 } |
52401 | 1105 |
1106 /* arch-tag: c96e9724-5eb1-4dad-be07-289f092fd2af | |
1107 (do not change this comment) */ |