Mercurial > emacs
annotate src/macselect.c @ 62126:f892f6a40629
*** empty log message ***
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 06 May 2005 20:41:58 +0000 |
parents | b710f3bc2da3 |
children | 6cae229f309b |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
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), ×tamp); |
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 ×tamp); |
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); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
374 if (err == noErr && flavor_info) |
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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
383 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
384 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
|
385 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
386 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
|
387 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
388 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
|
389 && (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
|
390 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
391 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
|
392 #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
|
393 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
|
394 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
|
395 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
396 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
|
397 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
398 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
399 #endif |
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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
402 #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
|
403 if (flavor_info) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
404 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
405 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
|
406 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
|
407 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
408 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
|
409 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
|
410 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
411 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
|
412 xfree (flavor_info); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
413 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
414 #endif |
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 return result; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
419 /* 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
|
420 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
|
421 our selection. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
422 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
423 static void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
424 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
|
425 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
|
426 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
427 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
428 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
429 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
|
430 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
|
431 int count; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
432 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
433 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
|
434 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
435 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
|
436 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
437 BLOCK_INPUT; |
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 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
|
440 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
|
441 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
442 /* 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
|
443 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
|
444 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
|
445 count = SPECPDL_INDEX (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
446 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
|
447 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
448 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
|
449 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
450 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
|
451 && 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
|
452 && 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
|
453 && 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
|
454 continue; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
455 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
456 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
|
457 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
|
458 type, selection_value); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
459 |
62102
b710f3bc2da3
(x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61819
diff
changeset
|
460 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
|
461 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
|
462 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
|
463 && 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
|
464 && 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
|
465 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
|
466 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
467 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
468 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
|
469 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
470 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
471 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
|
472 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
473 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
474 UNBLOCK_INPUT; |
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 UNGCPRO; |
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 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
|
479 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
|
480 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
481 /* 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
|
482 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
487 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
|
488 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
|
489 Fcons (selection_value, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
490 Fcons (selection_time, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
491 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
|
492 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
|
493 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
494 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
|
495 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
496 /* 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
|
497 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
|
498 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
|
499 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
|
500 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
501 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
|
502 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
|
503 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
|
504 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
505 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
|
506 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
507 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
508 } |
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 /* 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
|
513 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
|
514 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
|
515 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
|
516 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
|
517 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
518 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
|
519 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
520 static Lisp_Object |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
521 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
|
522 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
|
523 int local_request; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
524 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
525 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
|
526 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
|
527 int count; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
528 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
529 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
|
530 return Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
531 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
532 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
|
533 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
534 /* 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
|
535 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
|
536 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
537 handler_fn = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
538 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
|
539 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
540 #if 0 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
541 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
|
542 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
543 handler_fn = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
544 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
|
545 (selection_symbol, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
546 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
|
547 value = QNULL; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
548 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
549 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
550 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
551 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
552 /* 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
|
553 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
|
554 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
|
555 count = SPECPDL_INDEX (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
556 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
|
557 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
558 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
|
559 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
|
560 /* 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
|
561 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
|
562 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
563 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
|
564 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
|
565 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
|
566 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
|
567 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
568 value = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
569 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
|
570 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
571 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
572 /* 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
|
573 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
|
574 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
575 check = value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
576 if (CONSP (value) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
577 && SYMBOLP (XCAR (value))) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
578 type = XCAR (value), |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
579 check = XCDR (value); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
580 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
581 if (STRINGP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
582 || VECTORP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
583 || SYMBOLP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
584 || INTEGERP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
585 || NILP (value)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
586 return value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
587 /* 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
|
588 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
|
589 && INTEGERP (XCAR (check)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
590 && (INTEGERP (XCDR (check)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
591 || |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
592 (CONSP (XCDR (check)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
593 && 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
|
594 && 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
|
595 return value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
596 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
597 return |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
598 Fsignal (Qerror, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
599 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
|
600 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
|
601 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
602 |
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 /* 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
|
605 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
|
606 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
607 void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
608 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
|
609 FRAME_PTR f; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
610 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
611 Lisp_Object frame; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
612 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
613 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
614 XSETFRAME (frame, f); |
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 /* 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
|
617 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
|
618 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
619 /* 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
|
620 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
|
621 && 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
|
622 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
623 /* 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
|
624 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
|
625 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
626 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
|
627 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
|
628 |
62102
b710f3bc2da3
(x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61819
diff
changeset
|
629 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
|
630 && !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
|
631 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
632 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
|
633 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
|
634 #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
|
635 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
|
636 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
|
637 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
|
638 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
639 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
640 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
641 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
|
642 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
643 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
644 /* 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
|
645 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
|
646 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
|
647 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
648 /* 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
|
649 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
|
650 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
651 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
|
652 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
|
653 |
62102
b710f3bc2da3
(x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
61819
diff
changeset
|
654 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
|
655 && !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
|
656 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
657 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
|
658 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
|
659 #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
|
660 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
|
661 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
662 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
663 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
|
664 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
665 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
666 } |
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 /* 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
|
669 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
|
670 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
671 static Lisp_Object |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
672 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
|
673 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
|
674 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
675 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
676 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
677 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
|
678 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
679 BLOCK_INPUT; |
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 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
|
682 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
|
683 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
|
684 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
685 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
|
686 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
|
687 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
688 else |
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 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
|
691 if (STRINGP (result)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
692 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
|
693 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
|
694 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
695 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
696 UNBLOCK_INPUT; |
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 return result; |
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 |
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 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 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
|
708 (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
|
709 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
|
710 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
711 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
712 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
|
713 if (NILP (selection_value)) error ("selection-value may not be nil"); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
714 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
|
715 return selection_value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
716 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
717 |
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 /* 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
|
720 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
|
721 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
|
722 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
723 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
|
724 Sx_get_selection_internal, 2, 3, 0, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
725 doc: /* Return text selected from some Mac window. |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
726 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
|
727 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
|
728 TIME_STAMP is ignored on Mac. */) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
729 (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
|
730 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
|
731 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
732 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
|
733 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
|
734 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
|
735 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
736 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
|
737 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
|
738 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
739 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
|
740 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
741 if (NILP (val)) |
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 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
|
744 goto DONE; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
745 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
746 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
747 if (CONSP (val) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
748 && SYMBOLP (XCAR (val))) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
749 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
750 val = XCDR (val); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
751 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
|
752 val = XCAR (val); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
753 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
754 DONE: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
755 UNGCPRO; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
756 return val; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
757 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
758 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
759 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
|
760 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
|
761 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
|
762 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
|
763 (selection, time) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
764 Lisp_Object selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
765 Lisp_Object time; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
766 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
767 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
768 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
769 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
|
770 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
771 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
772 CHECK_SYMBOL (selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
773 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
774 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
|
775 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
|
776 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
777 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
|
778 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
779 /* 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
|
780 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
781 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
|
782 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
|
783 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
784 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
785 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
786 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
|
787 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
|
788 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
789 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
|
790 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
791 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
792 } |
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 /* 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
|
795 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
796 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
797 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
798 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
|
799 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
|
800 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
801 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
|
802 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
|
803 prepare_menu_bars (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
804 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
|
805 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
806 } |
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 BLOCK_INPUT; |
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 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
|
811 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
|
812 clear_scrap (&scrap); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
813 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
814 UNBLOCK_INPUT; |
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 return Qt; |
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 |
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 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
|
821 0, 1, 0, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
822 doc: /* Whether the current Emacs process owns the given Selection. |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
823 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
|
824 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
|
825 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
|
826 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
|
827 (selection) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
828 Lisp_Object selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
829 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
830 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
831 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
832 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
|
833 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
834 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
835 CHECK_SYMBOL (selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
836 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
|
837 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
|
838 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
839 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
|
840 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
841 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
|
842 return Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
843 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
844 BLOCK_INPUT; |
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 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
|
847 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
|
848 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
849 unsigned long timestamp; |
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 err = get_scrap_private_timestamp (scrap, ×tamp); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
852 if (err == noErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
853 && (timestamp |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
854 == 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
|
855 result = Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
856 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
857 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
858 result = Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
859 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
860 UNBLOCK_INPUT; |
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 return result; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
865 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
|
866 0, 1, 0, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
867 doc: /* Whether there is an owner for the given Selection. |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
868 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
|
869 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
|
870 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
|
871 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
|
872 (selection) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
873 Lisp_Object selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
874 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
875 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
876 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
877 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
|
878 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
879 /* 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
|
880 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
|
881 return Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
882 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
883 CHECK_SYMBOL (selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
884 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
|
885 return Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
886 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
|
887 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
|
888 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
889 BLOCK_INPUT; |
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 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
|
892 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
|
893 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
|
894 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
895 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
|
896 && 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
|
897 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
898 result = Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
899 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
900 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
901 } |
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 UNBLOCK_INPUT; |
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 return result; |
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 |
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 #ifdef MAC_OSX |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
910 void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
911 init_service_handler () |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
912 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
913 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
|
914 {kEventClassService, kEventServiceCopy}, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
915 {kEventClassService, kEventServicePaste}, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
916 {kEventClassService, kEventServicePerform}}; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
917 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
|
918 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
|
919 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
920 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
921 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
|
922 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
923 static OSStatus |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
924 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
|
925 EventHandlerCallRef call_ref; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
926 EventRef event; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
927 void *data; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
928 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
929 OSStatus err = noErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
930 ScrapRef cur_scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
931 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
932 /* 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
|
933 corresponding scrap. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
934 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
|
935 err = eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
936 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
937 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
|
938 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
|
939 return eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
940 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
941 switch (GetEventKind (event)) |
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 case kEventServiceGetTypes: |
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 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
|
946 CFStringRef type; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
947 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
948 ScrapFlavorType flavor_type; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
949 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
950 /* Set paste types. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
951 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
|
952 typeCFMutableArrayRef, NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
953 sizeof (CFMutableArrayRef), NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
954 &paste_types); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
955 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
956 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
|
957 rest = XCDR (rest)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
958 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
|
959 && (flavor_type = |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
960 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
|
961 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
962 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
|
963 if (type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
964 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
965 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
|
966 CFRelease (type); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
967 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
968 } |
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 /* Set copy types. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
971 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
|
972 typeCFMutableArrayRef, NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
973 sizeof (CFMutableArrayRef), NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
974 ©_types); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
975 if (err == noErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
976 && !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
|
977 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
|
978 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
|
979 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
980 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
|
981 if (flavor_type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
982 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
983 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
|
984 if (type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
985 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
986 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
|
987 CFRelease (type); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
988 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
989 } |
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 break; |
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 case kEventServiceCopy: |
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 ScrapRef specific_scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
997 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
|
998 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
999 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
|
1000 typeScrapRef, NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1001 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
|
1002 if (err == noErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1003 && !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
|
1004 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
|
1005 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
|
1006 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1007 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
|
1008 if (STRINGP (data)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1009 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
|
1010 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1011 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1012 err = eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1013 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1014 break; |
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 case kEventServicePaste: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1017 case kEventServicePerform: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1018 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1019 ScrapRef specific_scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1020 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
|
1021 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
|
1022 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1023 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
|
1024 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
|
1025 &specific_scrap); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1026 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1027 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
|
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 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
|
1030 rest = XCDR (rest)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1031 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1032 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
|
1033 continue; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1034 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
|
1035 if (STRINGP (data)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1036 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1037 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
|
1038 data); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1039 if (err != noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1040 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1041 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
|
1042 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1043 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1044 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1045 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
|
1046 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
|
1047 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1048 err = eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1049 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1050 break; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1053 return err; |
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 #endif |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1058 void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1059 syms_of_macselect () |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1060 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1061 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
|
1062 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
|
1063 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
|
1064 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
|
1065 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
|
1066 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1067 Vselection_alist = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1068 staticpro (&Vselection_alist); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1069 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1070 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
|
1071 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
|
1072 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
|
1073 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
|
1074 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
|
1075 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
|
1076 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1077 The function should return the value to send to the Scrap Manager |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1078 \(a string). A return value of nil |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1079 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
|
1080 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
|
1081 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
|
1082 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
|
1083 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
|
1084 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1085 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
|
1086 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
|
1087 \(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
|
1088 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
|
1089 \(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
|
1090 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
|
1091 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1092 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
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 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
|
1098 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 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
|
1104 set to nil. */); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1105 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
|
1106 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1107 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
|
1108 doc: /* 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
|
1109 Vmac_services_selection = intern ("CLIPBOARD"); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1110 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1111 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
|
1112 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
|
1113 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
|
1114 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
|
1115 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1116 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
|
1117 staticpro (&Qforeign_selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1118 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1119 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
|
1120 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
|
1121 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1122 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
|
1123 staticpro (&Qmac_ostype); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1124 } |
61819 | 1125 |
1126 /* arch-tag: f3c91ad8-99e0-4bd6-9eef-251b2f848732 | |
1127 (do not change this comment) */ |