annotate src/macselect.c @ 64812:0d6aa987778c

Replace `info' with upper-case `Info' where appropriate. (info-title-1, info-title-2, info-title-3, info-title-4) (info-menu-header): Move up face definitions. (info-menu-star): Rename from `info-menu-5'. (Info-fontify-node): Replace `info-menu-5' with `info-menu-star'. (Info-fontify-visited-nodes): Fix docstring. (Info-hide-note-references): Fix docstring. (Info-up, Info-next-reference, Info-prev-reference): Put cursor on menu items in the same way as on cross-references. (info-apropos): Fix sorting order and formatting to be like in the stand-alone Info browser. Display error messages for 1 sec. (Info-mode-map): Move down `c' key binding. Bind `^' to `Info-up'. (Info-mode-menu): Remove item for `Info-search-case-sensitively' from the menu bar. (Info-insert-dir): Restore point after calling `insert-buffer-substring'.
author Juri Linkov <juri@jurta.org>
date Tue, 09 Aug 2005 08:43:02 +0000
parents fefea1491def
children 819dc1a5c256
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1 /* Selection processing for Emacs on Mac OS.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2 Copyright (C) 2005 Free Software Foundation, Inc.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4 This file is part of GNU Emacs.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
9 any later version.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
10
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
14 GNU General Public License for more details.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
15
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62271
diff changeset
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62271
diff changeset
19 Boston, MA 02110-1301, USA. */
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
20
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
21 #include <config.h>
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
22
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
23 #include "lisp.h"
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
24 #include "macterm.h"
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
25 #include "blockinput.h"
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
26
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
27 #if !TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
28 #include <Endian.h>
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
29 typedef int ScrapRef;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
30 typedef ResType ScrapFlavorType;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
31 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
32
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
33 static OSErr get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
34 static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
35 static int valid_scrap_target_type_p P_ ((Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
36 static OSErr clear_scrap P_ ((ScrapRef *));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
37 static OSErr put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
38 static OSErr put_scrap_private_timestamp P_ ((ScrapRef, unsigned long));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
39 static ScrapFlavorType scrap_has_target_type P_ ((ScrapRef, Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
40 static Lisp_Object get_scrap_string P_ ((ScrapRef, Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
41 static OSErr get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
42 static Lisp_Object get_scrap_target_type_list P_ ((ScrapRef));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
43 static void x_own_selection P_ ((Lisp_Object, Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
44 static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
45 static Lisp_Object x_get_foreign_selection P_ ((Lisp_Object,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
46 Lisp_Object,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
47 Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
48 EXFUN (Fx_selection_owner_p, 1);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
49 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
50 static OSStatus mac_handle_service_event P_ ((EventHandlerCallRef,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
51 EventRef, void *));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
52 void init_service_handler P_ ((void));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
53 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
54
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
55 Lisp_Object QPRIMARY, QSECONDARY, QTIMESTAMP, QTARGETS;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
56
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
57 static Lisp_Object Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
58 /* Coding system for communicating with other programs via scrap. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
59 static Lisp_Object Vselection_coding_system;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
60
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
61 /* Coding system for the next communicating with other programs. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
62 static Lisp_Object Vnext_selection_coding_system;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
63
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
64 static Lisp_Object Qforeign_selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
65
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
66 /* The timestamp of the last input event Emacs received from the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
67 window server. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
68 /* Defined in keyboard.c. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
69 extern unsigned long last_event_timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
70
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
71 /* This is an association list whose elements are of the form
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
72 ( SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
73 SELECTION-NAME is a lisp symbol.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
74 SELECTION-VALUE is the value that emacs owns for that selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
75 It may be any kind of Lisp object.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
76 SELECTION-TIMESTAMP is the time at which emacs began owning this selection,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
77 as a cons of two 16-bit numbers (making a 32 bit time.)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
78 FRAME is the frame for which we made the selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
79 If there is an entry in this alist, and the data for the flavor
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
80 type SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP in the corresponding scrap
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
81 (if exists) coincides with SELECTION-TIMESTAMP, then it can be
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
82 assumed that Emacs owns that selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
83 The only (eq) parts of this list that are visible from Lisp are the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
84 selection-values. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
85 static Lisp_Object Vselection_alist;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
86
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
87 #define SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP 'Etsp'
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
88
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
89 /* This is an alist whose CARs are selection-types and whose CDRs are
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
90 the names of Lisp functions to call to convert the given Emacs
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
91 selection value to a string representing the given selection type.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
92 This is for Lisp-level extension of the emacs selection
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
93 handling. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
94 static Lisp_Object Vselection_converter_alist;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
95
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
96 /* A selection name (represented as a Lisp symbol) can be associated
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
97 with a named scrap via `mac-scrap-name' property. Likewise for a
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
98 selection type with a scrap flavor type via `mac-ostype'. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
99 static Lisp_Object Qmac_scrap_name, Qmac_ostype;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
100
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
101 #ifdef MAC_OSX
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
102 /* Selection name for communication via Services menu. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
103 static Lisp_Object Vmac_services_selection;
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
104 #endif
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
105
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
106 /* Get a reference to the scrap corresponding to the symbol SYM. The
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
107 reference is set to *SCRAP, and it becomes NULL if there's no
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
108 corresponding scrap. Clear the scrap if CLEAR_P is non-zero. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
109
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
110 static OSErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
111 get_scrap_from_symbol (sym, clear_p, scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
112 Lisp_Object sym;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
113 int clear_p;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
114 ScrapRef *scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
115 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
116 OSErr err = noErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
117 Lisp_Object str = Fget (sym, Qmac_scrap_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
118
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
119 if (!STRINGP (str))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
120 *scrap = NULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
121 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
122 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
123 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
124 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
125 CFStringRef scrap_name = cfstring_create_with_string (str);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
126 OptionBits options = (clear_p ? kScrapClearNamedScrap
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
127 : kScrapGetNamedScrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
128
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
129 err = GetScrapByName (scrap_name, options, scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
130 CFRelease (scrap_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
131 #else /* !MAC_OSX */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
132 if (clear_p)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
133 err = ClearCurrentScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
134 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
135 err = GetCurrentScrap (scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
136 #endif /* !MAC_OSX */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
137 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
138 if (clear_p)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
139 err = ZeroScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
140 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
141 *scrap = 1;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
142 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
143 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
144
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
145 return err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
146 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
147
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
148 /* Get a scrap flavor type from the symbol SYM. Return 0 if no
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
149 corresponding flavor type. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
150
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
151 static ScrapFlavorType
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
152 get_flavor_type_from_symbol (sym)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
153 Lisp_Object sym;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
154 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
155 ScrapFlavorType val;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
156 Lisp_Object str = Fget (sym, Qmac_ostype);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
157
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
158 if (STRINGP (str) && SBYTES (str) == 4)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
159 return EndianU32_BtoN (*((UInt32 *) SDATA (str)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
160
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
161 return 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
162 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
163
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
164 /* Check if the symbol SYM has a corresponding scrap flavor type. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
165
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
166 static int
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
167 valid_scrap_target_type_p (sym)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
168 Lisp_Object sym;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
169 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
170 return get_flavor_type_from_symbol (sym) != 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
171 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
172
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
173 /* Clear the scrap whose reference is *SCRAP. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
174
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
175 static INLINE OSErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
176 clear_scrap (scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
177 ScrapRef *scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
178 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
179 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
180 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
181 return ClearScrap (scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
182 #else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
183 return ClearCurrentScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
184 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
185 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
186 return ZeroScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
187 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
188 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
189
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
190 /* Put Lisp String STR to the scrap SCRAP. The target type is
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
191 specified by TYPE. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
192
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
193 static OSErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
194 put_scrap_string (scrap, type, str)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
195 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
196 Lisp_Object type, str;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
197 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
198 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
199
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
200 if (flavor_type == 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
201 return noTypeErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
202
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
203 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
204 return PutScrapFlavor (scrap, flavor_type, kScrapFlavorMaskNone,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
205 SBYTES (str), SDATA (str));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
206 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
207 return PutScrap (SBYTES (str), flavor_type, SDATA (str));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
208 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
209 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
210
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
211 /* Put TIMESTAMP to the scrap SCRAP. The timestamp is used for
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
212 checking if the scrap is owned by the process. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
213
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
214 static INLINE OSErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
215 put_scrap_private_timestamp (scrap, timestamp)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
216 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
217 unsigned long timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
218 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
219 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
220 return PutScrapFlavor (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
221 kScrapFlavorMaskSenderOnly,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
222 sizeof (timestamp), &timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
223 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
224 return PutScrap (sizeof (timestamp), SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
225 &timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
226 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
227 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
228
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
229 /* Check if data for the target type TYPE is available in SCRAP. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
230
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
231 static ScrapFlavorType
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
232 scrap_has_target_type (scrap, type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
233 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
234 Lisp_Object type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
235 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
236 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
237 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
238
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
239 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
240 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
241 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
242 ScrapFlavorFlags flags;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
243
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
244 err = GetScrapFlavorFlags (scrap, flavor_type, &flags);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
245 if (err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
246 flavor_type = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
247 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
248 SInt32 size, offset;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
249
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
250 size = GetScrap (NULL, flavor_type, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
251 if (size < 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
252 flavor_type = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
253 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
254 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
255
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
256 return flavor_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
257 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
258
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
259 /* Get data for the target type TYPE from SCRAP and create a Lisp
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
260 string. Return nil if failed to get data. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
261
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
262 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
263 get_scrap_string (scrap, type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
264 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
265 Lisp_Object type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
266 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
267 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
268 Lisp_Object result = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
269 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
270 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
271 Size size;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
272
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
273 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
274 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
275 err = GetScrapFlavorSize (scrap, flavor_type, &size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
276 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
277 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
278 do
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
279 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
280 result = make_uninit_string (size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
281 err = GetScrapFlavorData (scrap, flavor_type,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
282 &size, SDATA (result));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
283 if (err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
284 result = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
285 else if (size < SBYTES (result))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
286 result = make_unibyte_string (SDATA (result), size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
287 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
288 while (STRINGP (result) && size > SBYTES (result));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
289 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
290 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
291 #else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
292 Handle handle;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
293 SInt32 size, offset;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
294
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
295 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
296 size = GetScrap (NULL, flavor_type, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
297 if (size >= 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
298 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
299 handle = NewHandle (size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
300 HLock (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
301 size = GetScrap (handle, flavor_type, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
302 if (size >= 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
303 result = make_unibyte_string (*handle, size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
304 DisposeHandle (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
305 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
306 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
307
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
308 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
309 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
310
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
311 /* Get timestamp from the scrap SCRAP and set to *TIMPSTAMP. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
312
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
313 static OSErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
314 get_scrap_private_timestamp (scrap, timestamp)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
315 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
316 unsigned long *timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
317 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
318 OSErr err = noErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
319 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
320 ScrapFlavorFlags flags;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
321
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
322 err = GetScrapFlavorFlags (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &flags);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
323 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
324 if (!(flags & kScrapFlavorMaskSenderOnly))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
325 err = noTypeErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
326 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
327 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
328 Size size = sizeof (*timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
329
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
330 err = GetScrapFlavorData (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
331 &size, timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
332 if (err == noErr && size != sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
333 err = noTypeErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
334 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
335 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
336 Handle handle;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
337 SInt32 size, offset;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
338
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
339 size = GetScrap (NULL, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
340 if (size == sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
341 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
342 handle = NewHandle (size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
343 HLock (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
344 size = GetScrap (handle, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
345 if (size == sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
346 *timestamp = *((unsigned long *) *handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
347 DisposeHandle (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
348 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
349 if (size != sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
350 err = noTypeErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
351 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
352
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
353 return err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
354 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
355
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
356 /* Get the list of target types in SCRAP. The return value is a list
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
357 of target type symbols possibly followed by scrap flavor type
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
358 strings. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
359
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
360 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
361 get_scrap_target_type_list (scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
362 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
363 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
364 Lisp_Object result = Qnil, rest, target_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
365 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
366 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
367 UInt32 count, i, type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
368 ScrapFlavorInfo *flavor_info = NULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
369 Lisp_Object strings = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
370
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
371 err = GetScrapFlavorCount (scrap, &count);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
372 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
373 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
64312
c528a5858404 (get_scrap_target_type_list): Avoid NULL pointer dereference.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
374 if (flavor_info)
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
375 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
376 err = GetScrapFlavorInfoList (scrap, &count, flavor_info);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
377 if (err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
378 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
379 xfree (flavor_info);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
380 flavor_info = NULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
381 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
382 }
64312
c528a5858404 (get_scrap_target_type_list): Avoid NULL pointer dereference.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
383 if (flavor_info == NULL)
c528a5858404 (get_scrap_target_type_list): Avoid NULL pointer dereference.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
384 count = 0;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
385 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
386 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
387 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
388 ScrapFlavorType flavor_type = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
389
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
390 if (CONSP (XCAR (rest)) && SYMBOLP (target_type = XCAR (XCAR (rest)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
391 && (flavor_type = scrap_has_target_type (scrap, target_type)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
392 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
393 result = Fcons (target_type, result);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
394 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
395 for (i = 0; i < count; i++)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
396 if (flavor_info[i].flavorType == flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
397 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
398 flavor_info[i].flavorType = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
399 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
400 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
401 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
402 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
403 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
404 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
405 if (flavor_info)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
406 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
407 for (i = 0; i < count; i++)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
408 if (flavor_info[i].flavorType)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
409 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
410 type = EndianU32_NtoB (flavor_info[i].flavorType);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
411 strings = Fcons (make_unibyte_string ((char *) &type, 4), strings);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
412 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
413 result = nconc2 (result, strings);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
414 xfree (flavor_info);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
415 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
416 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
417
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
418 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
419 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
420
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
421 /* Do protocol to assert ourself as a selection owner.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
422 Update the Vselection_alist so that we can reply to later requests for
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
423 our selection. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
424
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
425 static void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
426 x_own_selection (selection_name, selection_value)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
427 Lisp_Object selection_name, selection_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
428 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
429 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
430 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
431 struct gcpro gcpro1, gcpro2;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
432 Lisp_Object rest, handler_fn, value, type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
433 int count;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
434
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
435 CHECK_SYMBOL (selection_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
436
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
437 GCPRO2 (selection_name, selection_value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
438
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
439 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
440
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
441 err = get_scrap_from_symbol (selection_name, 1, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
442 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
443 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
444 /* Don't allow a quit within the converter.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
445 When the user types C-g, he would be surprised
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
446 if by luck it came during a converter. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
447 count = SPECPDL_INDEX ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
448 specbind (Qinhibit_quit, Qt);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
449
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
450 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
451 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
452 if (!(CONSP (XCAR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
453 && SYMBOLP (type = XCAR (XCAR (rest)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
454 && valid_scrap_target_type_p (type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
455 && SYMBOLP (handler_fn = XCDR (XCAR (rest)))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
456 continue;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
457
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
458 if (!NILP (handler_fn))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
459 value = call3 (handler_fn, selection_name,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
460 type, selection_value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
461
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
462 if (STRINGP (value))
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
463 err = put_scrap_string (scrap, type, value);
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
464 else if (CONSP (value)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
465 && EQ (XCAR (value), type)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
466 && STRINGP (XCDR (value)))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
467 err = put_scrap_string (scrap, type, XCDR (value));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
468 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
469
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
470 unbind_to (count, Qnil);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
471
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
472 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
473 err = put_scrap_private_timestamp (scrap, last_event_timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
474 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
475
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
476 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
477
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
478 UNGCPRO;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
479
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
480 if (scrap && err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
481 error ("Can't set selection");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
482
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
483 /* Now update the local cache */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
484 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
485 Lisp_Object selection_time;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
486 Lisp_Object selection_data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
487 Lisp_Object prev_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
488
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
489 selection_time = long_to_cons (last_event_timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
490 selection_data = Fcons (selection_name,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
491 Fcons (selection_value,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
492 Fcons (selection_time,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
493 Fcons (selected_frame, Qnil))));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
494 prev_value = assq_no_quit (selection_name, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
495
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
496 Vselection_alist = Fcons (selection_data, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
497
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
498 /* If we already owned the selection, remove the old selection data.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
499 Perhaps we should destructively modify it instead.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
500 Don't use Fdelq as that may QUIT. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
501 if (!NILP (prev_value))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
502 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
503 Lisp_Object rest; /* we know it's not the CAR, so it's easy. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
504 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
505 if (EQ (prev_value, Fcar (XCDR (rest))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
506 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
507 XSETCDR (rest, Fcdr (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
508 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
509 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
510 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
511 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
512 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
513
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
514 /* Given a selection-name and desired type, look up our local copy of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
515 the selection value and convert it to the type.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
516 The value is nil or a string.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
517 This function is used both for remote requests (LOCAL_REQUEST is zero)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
518 and for local x-get-selection-internal (LOCAL_REQUEST is nonzero).
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
519
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
520 This calls random Lisp code, and may signal or gc. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
521
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
522 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
523 x_get_local_selection (selection_symbol, target_type, local_request)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
524 Lisp_Object selection_symbol, target_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
525 int local_request;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
526 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
527 Lisp_Object local_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
528 Lisp_Object handler_fn, value, type, check;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
529 int count;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
530
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
531 if (NILP (Fx_selection_owner_p (selection_symbol)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
532 return Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
533
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
534 local_value = assq_no_quit (selection_symbol, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
535
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
536 /* TIMESTAMP is a special case 'cause that's easiest. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
537 if (EQ (target_type, QTIMESTAMP))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
538 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
539 handler_fn = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
540 value = XCAR (XCDR (XCDR (local_value)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
541 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
542 #if 0
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
543 else if (EQ (target_type, QDELETE))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
544 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
545 handler_fn = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
546 Fx_disown_selection_internal
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
547 (selection_symbol,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
548 XCAR (XCDR (XCDR (local_value))));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
549 value = QNULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
550 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
551 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
552 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
553 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
554 /* Don't allow a quit within the converter.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
555 When the user types C-g, he would be surprised
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
556 if by luck it came during a converter. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
557 count = SPECPDL_INDEX ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
558 specbind (Qinhibit_quit, Qt);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
559
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
560 CHECK_SYMBOL (target_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
561 handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
562 /* gcpro is not needed here since nothing but HANDLER_FN
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
563 is live, and that ought to be a symbol. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
564
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
565 if (!NILP (handler_fn))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
566 value = call3 (handler_fn,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
567 selection_symbol, (local_request ? Qnil : target_type),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
568 XCAR (XCDR (local_value)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
569 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
570 value = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
571 unbind_to (count, Qnil);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
572 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
573
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
574 /* Make sure this value is of a type that we could transmit
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
575 to another X client. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
576
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
577 check = value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
578 if (CONSP (value)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
579 && SYMBOLP (XCAR (value)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
580 type = XCAR (value),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
581 check = XCDR (value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
582
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
583 if (STRINGP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
584 || VECTORP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
585 || SYMBOLP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
586 || INTEGERP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
587 || NILP (value))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
588 return value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
589 /* Check for a value that cons_to_long could handle. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
590 else if (CONSP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
591 && INTEGERP (XCAR (check))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
592 && (INTEGERP (XCDR (check))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
593 ||
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
594 (CONSP (XCDR (check))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
595 && INTEGERP (XCAR (XCDR (check)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
596 && NILP (XCDR (XCDR (check))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
597 return value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
598 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
599 return
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
600 Fsignal (Qerror,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
601 Fcons (build_string ("invalid data returned by selection-conversion function"),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
602 Fcons (handler_fn, Fcons (value, Qnil))));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
603 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
604
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
605
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
606 /* Clear all selections that were made from frame F.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
607 We do this when about to delete a frame. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
608
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
609 void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
610 x_clear_frame_selections (f)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
611 FRAME_PTR f;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
612 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
613 Lisp_Object frame;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
614 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
615
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
616 XSETFRAME (frame, f);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
617
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
618 /* Otherwise, we're really honest and truly being told to drop it.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
619 Don't use Fdelq as that may QUIT;. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
620
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
621 /* Delete elements from the beginning of Vselection_alist. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
622 while (!NILP (Vselection_alist)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
623 && EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (Vselection_alist)))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
624 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
625 /* Let random Lisp code notice that the selection has been stolen. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
626 Lisp_Object hooks, selection_symbol;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
627
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
628 hooks = Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
629 selection_symbol = Fcar (Fcar (Vselection_alist));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
630
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
631 if (!EQ (hooks, Qunbound)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
632 && !NILP (Fx_selection_owner_p (selection_symbol)))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
633 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
634 for (; CONSP (hooks); hooks = Fcdr (hooks))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
635 call1 (Fcar (hooks), selection_symbol);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
636 #if 0 /* This can crash when deleting a frame
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
637 from x_connection_closed. Anyway, it seems unnecessary;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
638 something else should cause a redisplay. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
639 redisplay_preserve_echo_area (21);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
640 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
641 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
642
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
643 Vselection_alist = Fcdr (Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
644 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
645
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
646 /* Delete elements after the beginning of Vselection_alist. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
647 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
648 if (EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (XCDR (rest))))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
649 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
650 /* Let random Lisp code notice that the selection has been stolen. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
651 Lisp_Object hooks, selection_symbol;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
652
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
653 hooks = Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
654 selection_symbol = Fcar (Fcar (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
655
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
656 if (!EQ (hooks, Qunbound)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
657 && !NILP (Fx_selection_owner_p (selection_symbol)))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
658 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
659 for (; CONSP (hooks); hooks = Fcdr (hooks))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
660 call1 (Fcar (hooks), selection_symbol);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
661 #if 0 /* See above */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
662 redisplay_preserve_echo_area (22);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
663 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
664 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
665 XSETCDR (rest, Fcdr (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
666 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
667 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
668 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
669
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
670 /* Do protocol to read selection-data from the server.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
671 Converts this to Lisp data and returns it. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
672
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
673 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
674 x_get_foreign_selection (selection_symbol, target_type, time_stamp)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
675 Lisp_Object selection_symbol, target_type, time_stamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
676 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
677 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
678 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
679 Lisp_Object result = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
680
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
681 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
682
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
683 err = get_scrap_from_symbol (selection_symbol, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
684 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
685 if (EQ (target_type, QTARGETS))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
686 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
687 result = get_scrap_target_type_list (scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
688 result = Fvconcat (1, &result);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
689 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
690 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
691 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
692 result = get_scrap_string (scrap, target_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
693 if (STRINGP (result))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
694 Fput_text_property (make_number (0), make_number (SBYTES (result)),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
695 Qforeign_selection, target_type, result);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
696 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
697
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
698 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
699
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
700 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
701 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
702
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
703
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
704 DEFUN ("x-own-selection-internal", Fx_own_selection_internal,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
705 Sx_own_selection_internal, 2, 2, 0,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
706 doc: /* Assert a selection of the given TYPE with the given VALUE.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
707 TYPE is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
708 VALUE is typically a string, or a cons of two markers, but may be
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
709 anything that the functions on `selection-converter-alist' know about. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
710 (selection_name, selection_value)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
711 Lisp_Object selection_name, selection_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
712 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
713 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
714 CHECK_SYMBOL (selection_name);
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
715 if (NILP (selection_value)) error ("SELECTION-VALUE may not be nil");
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
716 x_own_selection (selection_name, selection_value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
717 return selection_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
718 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
719
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
720
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
721 /* Request the selection value from the owner. If we are the owner,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
722 simply return our selection value. If we are not the owner, this
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
723 will block until all of the data has arrived. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
724
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
725 DEFUN ("x-get-selection-internal", Fx_get_selection_internal,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
726 Sx_get_selection_internal, 2, 3, 0,
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
727 doc: /* Return text selected from some Mac application.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
728 SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
729 TYPE is the type of data desired, typically `STRING'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
730 TIME_STAMP is ignored on Mac. */)
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
731 (selection_symbol, target_type, time_stamp)
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
732 Lisp_Object selection_symbol, target_type, time_stamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
733 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
734 Lisp_Object val = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
735 struct gcpro gcpro1, gcpro2;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
736 GCPRO2 (target_type, val); /* we store newly consed data into these */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
737 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
738 CHECK_SYMBOL (selection_symbol);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
739 CHECK_SYMBOL (target_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
740
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
741 val = x_get_local_selection (selection_symbol, target_type, 1);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
742
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
743 if (NILP (val))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
744 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
745 val = x_get_foreign_selection (selection_symbol, target_type, time_stamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
746 goto DONE;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
747 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
748
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
749 if (CONSP (val)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
750 && SYMBOLP (XCAR (val)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
751 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
752 val = XCDR (val);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
753 if (CONSP (val) && NILP (XCDR (val)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
754 val = XCAR (val);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
755 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
756 DONE:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
757 UNGCPRO;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
758 return val;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
759 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
760
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
761 DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
762 Sx_disown_selection_internal, 1, 2, 0,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
763 doc: /* If we own the selection SELECTION, disown it.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
764 Disowning it means there is no such selection. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
765 (selection, time)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
766 Lisp_Object selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
767 Lisp_Object time;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
768 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
769 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
770 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
771 Lisp_Object local_selection_data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
772
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
773 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
774 CHECK_SYMBOL (selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
775
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
776 if (NILP (Fx_selection_owner_p (selection)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
777 return Qnil; /* Don't disown the selection when we're not the owner. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
778
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
779 local_selection_data = assq_no_quit (selection, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
780
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
781 /* Don't use Fdelq as that may QUIT;. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
782
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
783 if (EQ (local_selection_data, Fcar (Vselection_alist)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
784 Vselection_alist = Fcdr (Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
785 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
786 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
787 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
788 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
789 if (EQ (local_selection_data, Fcar (XCDR (rest))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
790 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
791 XSETCDR (rest, Fcdr (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
792 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
793 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
794 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
795
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
796 /* Let random lisp code notice that the selection has been stolen. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
797
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
798 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
799 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
800 rest = Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
801 if (!EQ (rest, Qunbound))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
802 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
803 for (; CONSP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
804 call1 (Fcar (rest), selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
805 prepare_menu_bars ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
806 redisplay_preserve_echo_area (20);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
807 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
808 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
809
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
810 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
811
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
812 err = get_scrap_from_symbol (selection, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
813 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
814 clear_scrap (&scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
815
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
816 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
817
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
818 return Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
819 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
820
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
821
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
822 DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
823 0, 1, 0,
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
824 doc: /* Whether the current Emacs process owns the given SELECTION.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
825 The arg should be the name of the selection in question, typically one of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
826 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
827 For convenience, the symbol nil is the same as `PRIMARY',
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
828 and t is the same as `SECONDARY'. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
829 (selection)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
830 Lisp_Object selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
831 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
832 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
833 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
834 Lisp_Object result = Qnil, local_selection_data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
835
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
836 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
837 CHECK_SYMBOL (selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
838 if (EQ (selection, Qnil)) selection = QPRIMARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
839 if (EQ (selection, Qt)) selection = QSECONDARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
840
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
841 local_selection_data = assq_no_quit (selection, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
842
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
843 if (NILP (local_selection_data))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
844 return Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
845
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
846 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
847
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
848 err = get_scrap_from_symbol (selection, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
849 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
850 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
851 unsigned long timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
852
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
853 err = get_scrap_private_timestamp (scrap, &timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
854 if (err == noErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
855 && (timestamp
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
856 == cons_to_long (XCAR (XCDR (XCDR (local_selection_data))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
857 result = Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
858 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
859 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
860 result = Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
861
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
862 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
863
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
864 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
865 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
866
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
867 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
868 0, 1, 0,
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
869 doc: /* Whether there is an owner for the given SELECTION.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
870 The arg should be the name of the selection in question, typically one of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
871 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
872 For convenience, the symbol nil is the same as `PRIMARY',
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
873 and t is the same as `SECONDARY'. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
874 (selection)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
875 Lisp_Object selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
876 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
877 OSErr err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
878 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
879 Lisp_Object result = Qnil, rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
880
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
881 /* It should be safe to call this before we have an Mac frame. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
882 if (! FRAME_MAC_P (SELECTED_FRAME ()))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
883 return Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
884
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
885 CHECK_SYMBOL (selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
886 if (!NILP (Fx_selection_owner_p (selection)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
887 return Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
888 if (EQ (selection, Qnil)) selection = QPRIMARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
889 if (EQ (selection, Qt)) selection = QSECONDARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
890
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
891 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
892
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
893 err = get_scrap_from_symbol (selection, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
894 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
895 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
896 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
897 if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
898 && scrap_has_target_type (scrap, XCAR (XCAR (rest))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
899 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
900 result = Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
901 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
902 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
903 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
904
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
905 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
906
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
907 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
908 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
909
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
910
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
911 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
912 void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
913 init_service_handler ()
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
914 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
915 EventTypeSpec specs[] = {{kEventClassService, kEventServiceGetTypes},
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
916 {kEventClassService, kEventServiceCopy},
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
917 {kEventClassService, kEventServicePaste},
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
918 {kEventClassService, kEventServicePerform}};
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
919 InstallApplicationEventHandler (NewEventHandlerUPP (mac_handle_service_event),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
920 GetEventTypeCount (specs), specs, NULL, NULL);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
921 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
922
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
923 extern void mac_store_services_event P_ ((EventRef));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
924
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
925 static OSStatus
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
926 mac_handle_service_event (call_ref, event, data)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
927 EventHandlerCallRef call_ref;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
928 EventRef event;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
929 void *data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
930 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
931 OSStatus err = noErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
932 ScrapRef cur_scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
933
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
934 /* Check if Vmac_services_selection is a valid selection that has a
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
935 corresponding scrap. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
936 if (!SYMBOLP (Vmac_services_selection))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
937 err = eventNotHandledErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
938 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
939 err = get_scrap_from_symbol (Vmac_services_selection, 0, &cur_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
940 if (!(err == noErr && cur_scrap))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
941 return eventNotHandledErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
942
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
943 switch (GetEventKind (event))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
944 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
945 case kEventServiceGetTypes:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
946 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
947 CFMutableArrayRef copy_types, paste_types;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
948 CFStringRef type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
949 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
950 ScrapFlavorType flavor_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
951
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
952 /* Set paste types. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
953 err = GetEventParameter (event, kEventParamServicePasteTypes,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
954 typeCFMutableArrayRef, NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
955 sizeof (CFMutableArrayRef), NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
956 &paste_types);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
957 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
958 for (rest = Vselection_converter_alist; CONSP (rest);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
959 rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
960 if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
961 && (flavor_type =
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
962 get_flavor_type_from_symbol (XCAR (XCAR (rest)))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
963 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
964 type = CreateTypeStringWithOSType (flavor_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
965 if (type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
966 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
967 CFArrayAppendValue (paste_types, type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
968 CFRelease (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
969 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
970 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
971
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
972 /* Set copy types. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
973 err = GetEventParameter (event, kEventParamServiceCopyTypes,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
974 typeCFMutableArrayRef, NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
975 sizeof (CFMutableArrayRef), NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
976 &copy_types);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
977 if (err == noErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
978 && !NILP (Fx_selection_owner_p (Vmac_services_selection)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
979 for (rest = get_scrap_target_type_list (cur_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
980 CONSP (rest) && SYMBOLP (XCAR (rest)); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
981 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
982 flavor_type = get_flavor_type_from_symbol (XCAR (rest));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
983 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
984 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
985 type = CreateTypeStringWithOSType (flavor_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
986 if (type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
987 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
988 CFArrayAppendValue (copy_types, type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
989 CFRelease (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
990 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
991 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
992 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
993 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
994 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
995
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
996 case kEventServiceCopy:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
997 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
998 ScrapRef specific_scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
999 Lisp_Object rest, data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1000
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1001 err = GetEventParameter (event, kEventParamScrapRef,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1002 typeScrapRef, NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1003 sizeof (ScrapRef), NULL, &specific_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1004 if (err == noErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1005 && !NILP (Fx_selection_owner_p (Vmac_services_selection)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1006 for (rest = get_scrap_target_type_list (cur_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1007 CONSP (rest) && SYMBOLP (XCAR (rest)); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1008 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1009 data = get_scrap_string (cur_scrap, XCAR (rest));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1010 if (STRINGP (data))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1011 err = put_scrap_string (specific_scrap, XCAR (rest), data);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1012 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1013 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1014 err = eventNotHandledErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1015 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1016 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1017
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1018 case kEventServicePaste:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1019 case kEventServicePerform:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1020 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1021 ScrapRef specific_scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1022 Lisp_Object rest, data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1023 int data_exists_p = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1024
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1025 err = GetEventParameter (event, kEventParamScrapRef, typeScrapRef,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1026 NULL, sizeof (ScrapRef), NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1027 &specific_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1028 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1029 err = clear_scrap (&cur_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1030 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1031 for (rest = Vselection_converter_alist; CONSP (rest);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1032 rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1033 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1034 if (! (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1035 continue;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1036 data = get_scrap_string (specific_scrap, XCAR (XCAR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1037 if (STRINGP (data))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1038 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1039 err = put_scrap_string (cur_scrap, XCAR (XCAR (rest)),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1040 data);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1041 if (err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1042 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1043 data_exists_p = 1;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1044 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1045 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1046 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1047 if (data_exists_p)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1048 mac_store_application_menu_event (event);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1049 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1050 err = eventNotHandledErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1051 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1052 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1053 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1054
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1055 return err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1056 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1057 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1058
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1059
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1060 void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1061 syms_of_macselect ()
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1062 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1063 defsubr (&Sx_get_selection_internal);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1064 defsubr (&Sx_own_selection_internal);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1065 defsubr (&Sx_disown_selection_internal);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1066 defsubr (&Sx_selection_owner_p);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1067 defsubr (&Sx_selection_exists_p);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1068
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1069 Vselection_alist = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1070 staticpro (&Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1071
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1072 DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_alist,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1073 doc: /* An alist associating selection-types with functions.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1074 These functions are called to convert the selection, with three args:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1075 the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1076 a desired type to which the selection should be converted;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1077 and the local selection value (whatever was given to `x-own-selection').
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1078
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1079 The function should return the value to send to the Scrap Manager
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
1080 \(must be a string). A return value of nil
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1081 means that the conversion could not be done.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1082 A return value which is the symbol `NULL'
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1083 means that a side-effect was executed,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1084 and there is no meaningful selection value. */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1085 Vselection_converter_alist = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1086
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1087 DEFVAR_LISP ("x-lost-selection-functions", &Vx_lost_selection_functions,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1088 doc: /* A list of functions to be called when Emacs loses a selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1089 \(This happens when a Lisp program explicitly clears the selection.)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1090 The functions are called with one argument, the selection type
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1091 \(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'). */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1092 Vx_lost_selection_functions = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1093
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1094 DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1095 doc: /* Coding system for communicating with other programs.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1096 When sending or receiving text via cut_buffer, selection, and clipboard,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1097 the text is encoded or decoded by this coding system.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1098 The default value is determined by the system script code. */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1099 Vselection_coding_system = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1100
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1101 DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1102 doc: /* Coding system for the next communication with other programs.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1103 Usually, `selection-coding-system' is used for communicating with
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1104 other programs. But, if this variable is set, it is used for the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1105 next communication only. After the communication, this variable is
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1106 set to nil. */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1107 Vnext_selection_coding_system = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1108
62271
6cae229f309b (syms_of_macselect) [MAC_OSX]: Apply a change that was previously
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62102
diff changeset
1109 #ifdef MAC_OSX
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1110 DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1111 doc: /* Selection name for communication via Services menu. */);
62271
6cae229f309b (syms_of_macselect) [MAC_OSX]: Apply a change that was previously
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62102
diff changeset
1112 Vmac_services_selection = intern ("PRIMARY");
6cae229f309b (syms_of_macselect) [MAC_OSX]: Apply a change that was previously
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62102
diff changeset
1113 #endif
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1114
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1115 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1116 QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1117 QTIMESTAMP = intern ("TIMESTAMP"); staticpro (&QTIMESTAMP);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1118 QTARGETS = intern ("TARGETS"); staticpro (&QTARGETS);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1119
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1120 Qforeign_selection = intern ("foreign-selection");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1121 staticpro (&Qforeign_selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1122
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1123 Qmac_scrap_name = intern ("mac-scrap-name");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1124 staticpro (&Qmac_scrap_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1125
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1126 Qmac_ostype = intern ("mac-ostype");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1127 staticpro (&Qmac_ostype);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1128 }
61819
df86749111d6 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 61777
diff changeset
1129
df86749111d6 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 61777
diff changeset
1130 /* arch-tag: f3c91ad8-99e0-4bd6-9eef-251b2f848732
df86749111d6 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 61777
diff changeset
1131 (do not change this comment) */