Mercurial > emacs
annotate src/macselect.c @ 61839:f2c42b716361
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 26 Apr 2005 04:07:40 +0000 |
parents | df86749111d6 |
children | b710f3bc2da3 |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
101 /* 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
|
102 static Lisp_Object Vmac_services_selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
103 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
104 /* 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
|
105 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
|
106 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
|
107 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
108 static OSErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
109 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
|
110 Lisp_Object sym; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
111 int clear_p; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
112 ScrapRef *scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
113 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
114 OSErr err = noErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
115 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
|
116 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
117 if (!STRINGP (str)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
118 *scrap = NULL; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
119 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
120 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
121 #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
|
122 #ifdef MAC_OSX |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
123 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
|
124 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
|
125 : kScrapGetNamedScrap); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
126 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
127 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
|
128 CFRelease (scrap_name); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
129 #else /* !MAC_OSX */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
130 if (clear_p) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
131 err = ClearCurrentScrap (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
132 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
133 err = GetCurrentScrap (scrap); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
134 #endif /* !MAC_OSX */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
135 #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
|
136 if (clear_p) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
137 err = ZeroScrap (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
138 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
139 *scrap = 1; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
140 #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
|
141 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
142 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
143 return err; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
146 /* 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
|
147 corresponding flavor type. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
148 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
149 static ScrapFlavorType |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
150 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
|
151 Lisp_Object sym; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
152 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
153 ScrapFlavorType val; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
154 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
|
155 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
156 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
|
157 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
|
158 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
159 return 0; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
162 /* 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
|
163 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
164 static int |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
165 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
|
166 Lisp_Object sym; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
167 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
168 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
|
169 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
170 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
171 /* 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
|
172 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
173 static INLINE OSErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
174 clear_scrap (scrap) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
175 ScrapRef *scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
176 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
177 #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
|
178 #ifdef MAC_OSX |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
179 return ClearScrap (scrap); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
180 #else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
181 return ClearCurrentScrap (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
182 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
183 #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
|
184 return ZeroScrap (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
185 #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
|
186 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
187 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
188 /* 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
|
189 specified by TYPE. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
190 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
191 static OSErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
192 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
|
193 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
194 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
|
195 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
196 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
|
197 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
198 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
|
199 return noTypeErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
200 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
201 #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
|
202 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
|
203 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
|
204 #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
|
205 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
|
206 #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
|
207 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
208 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
209 /* 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
|
210 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
|
211 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
212 static INLINE OSErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
213 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
|
214 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
215 unsigned long timestamp; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
216 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
217 #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
|
218 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
|
219 kScrapFlavorMaskSenderOnly, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
220 sizeof (timestamp), ×tamp); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
221 #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
|
222 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
|
223 ×tamp); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
224 #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
|
225 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
226 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
227 /* 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
|
228 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
229 static ScrapFlavorType |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
230 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
|
231 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
232 Lisp_Object type; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
233 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
234 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
235 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
|
236 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
237 if (flavor_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 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
|
240 ScrapFlavorFlags flags; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
241 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
242 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
|
243 if (err != noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
244 flavor_type = 0; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
245 #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
|
246 SInt32 size, offset; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
247 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
248 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
|
249 if (size < 0) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
250 flavor_type = 0; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
251 #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
|
252 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
253 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
254 return flavor_type; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
257 /* 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
|
258 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
|
259 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
260 static Lisp_Object |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
261 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
|
262 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
263 Lisp_Object type; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
264 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
265 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
266 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
|
267 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
|
268 #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
|
269 Size size; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
270 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
271 if (flavor_type) |
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 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
|
274 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
275 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
276 do |
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 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
|
279 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
|
280 &size, SDATA (result)); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
281 if (err != noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
282 result = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
283 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
|
284 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
|
285 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
286 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
|
287 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
288 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
289 #else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
290 Handle handle; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
291 SInt32 size, offset; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
292 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
293 if (flavor_type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
294 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
|
295 if (size >= 0) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
296 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
297 handle = NewHandle (size); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
298 HLock (handle); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
299 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
|
300 if (size >= 0) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
301 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
|
302 DisposeHandle (handle); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
303 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
304 #endif |
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 return result; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
309 /* 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
|
310 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
311 static OSErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
312 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
|
313 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
314 unsigned long *timestamp; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
315 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
316 OSErr err = noErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
317 #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
|
318 ScrapFlavorFlags flags; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
319 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
320 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
|
321 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
322 if (!(flags & kScrapFlavorMaskSenderOnly)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
323 err = noTypeErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
324 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
325 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
326 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
|
327 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
328 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
|
329 &size, timestamp); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
330 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
|
331 err = noTypeErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
332 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
333 #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
|
334 Handle handle; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
335 SInt32 size, offset; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
336 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
337 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
|
338 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
|
339 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
340 handle = NewHandle (size); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
341 HLock (handle); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
342 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
|
343 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
|
344 *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
|
345 DisposeHandle (handle); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
346 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
347 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
|
348 err = noTypeErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
349 #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
|
350 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
351 return err; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
354 /* 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
|
355 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
|
356 strings. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
357 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
358 static Lisp_Object |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
359 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
|
360 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
361 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
362 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
|
363 #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
|
364 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
365 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
|
366 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
|
367 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
|
368 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
369 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
|
370 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
371 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
|
372 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
|
373 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
374 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
|
375 if (err != noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
376 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
377 xfree (flavor_info); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
378 flavor_info = NULL; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
379 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
380 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
381 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
382 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
|
383 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
384 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
|
385 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
386 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
|
387 && (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
|
388 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
389 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
|
390 #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
|
391 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
|
392 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
|
393 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
394 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
|
395 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
396 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
397 #endif |
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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
400 #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
|
401 if (flavor_info) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
402 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
403 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
|
404 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
|
405 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
406 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
|
407 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
|
408 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
409 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
|
410 xfree (flavor_info); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
411 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
412 #endif |
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 return result; |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
417 /* 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
|
418 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
|
419 our selection. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
420 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
421 static void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
422 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
|
423 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
|
424 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
425 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
426 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
427 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
|
428 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
|
429 int count; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
430 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
431 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
|
432 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
433 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
|
434 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
435 BLOCK_INPUT; |
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 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
|
438 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
|
439 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
440 /* 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
|
441 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
|
442 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
|
443 count = SPECPDL_INDEX (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
444 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
|
445 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
446 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
|
447 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
448 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
|
449 && 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
|
450 && 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
|
451 && 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
|
452 continue; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
453 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
454 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
|
455 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
|
456 type, selection_value); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
457 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
458 if (CONSP (value) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
459 && EQ (XCAR (value), type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
460 && STRINGP (XCDR (value))) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
461 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
|
462 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
463 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
464 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
|
465 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
466 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
467 err = put_scrap_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
|
468 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
469 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
470 UNBLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
471 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
472 UNGCPRO; |
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 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
|
475 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
|
476 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
477 /* 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
|
478 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
479 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
|
480 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
|
481 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
|
482 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
483 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
|
484 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
|
485 Fcons (selection_value, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
486 Fcons (selection_time, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
487 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
|
488 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
|
489 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
490 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
|
491 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
492 /* 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
|
493 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
|
494 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
|
495 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
|
496 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
497 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
|
498 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
|
499 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
|
500 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
501 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
|
502 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
503 } |
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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
506 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
507 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
508 /* 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
514 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
|
515 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
516 static Lisp_Object |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
517 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
|
518 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
|
519 int local_request; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
520 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
521 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
|
522 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
|
523 int count; |
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 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
|
526 return Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
527 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
528 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
|
529 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
530 /* 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
|
531 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
|
532 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
533 handler_fn = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
534 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
|
535 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
536 #if 0 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
537 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
|
538 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
539 handler_fn = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
540 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
|
541 (selection_symbol, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
542 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
|
543 value = QNULL; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
544 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
545 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
546 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
547 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
548 /* 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
|
549 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
|
550 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
|
551 count = SPECPDL_INDEX (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
552 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
|
553 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
554 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
|
555 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
|
556 /* 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
|
557 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
|
558 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
559 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
|
560 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
|
561 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
|
562 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
|
563 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
564 value = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
565 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
|
566 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
567 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
568 /* 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
|
569 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
|
570 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
571 check = value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
572 if (CONSP (value) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
573 && SYMBOLP (XCAR (value))) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
574 type = XCAR (value), |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
575 check = XCDR (value); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
576 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
577 if (STRINGP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
578 || VECTORP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
579 || SYMBOLP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
580 || INTEGERP (check) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
581 || NILP (value)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
582 return value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
583 /* 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
|
584 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
|
585 && INTEGERP (XCAR (check)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
586 && (INTEGERP (XCDR (check)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
587 || |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
588 (CONSP (XCDR (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 (XCDR (check))) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
590 && 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
|
591 return value; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
592 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
593 return |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
594 Fsignal (Qerror, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
595 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
|
596 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
|
597 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
598 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
599 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
600 /* 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
|
601 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
|
602 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
603 void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
604 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
|
605 FRAME_PTR f; |
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 Lisp_Object frame; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
608 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
609 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
610 XSETFRAME (frame, f); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
611 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
612 /* 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
|
613 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
|
614 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
615 /* 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
|
616 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
|
617 && 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
|
618 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
619 /* 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
|
620 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
|
621 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
622 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
|
623 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
|
624 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
625 if (!EQ (hooks, Qunbound)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
626 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
627 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
|
628 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
|
629 #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
|
630 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
|
631 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
|
632 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
|
633 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
634 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
635 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
636 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
|
637 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
638 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
639 /* 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
|
640 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
|
641 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
|
642 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
643 /* 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
|
644 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
|
645 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
646 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
|
647 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
|
648 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
649 if (!EQ (hooks, Qunbound)) |
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 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
|
652 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
|
653 #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
|
654 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
|
655 #endif |
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 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
|
658 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
659 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
660 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
661 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
662 /* 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
|
663 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
|
664 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
665 static Lisp_Object |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
666 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
|
667 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
|
668 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
669 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
670 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
671 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
|
672 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
673 BLOCK_INPUT; |
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 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
|
676 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
|
677 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
|
678 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
679 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
|
680 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
|
681 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
682 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
683 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
684 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
|
685 if (STRINGP (result)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
686 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
|
687 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
|
688 } |
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 UNBLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
691 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
692 return result; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
693 } |
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 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
|
697 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 (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
|
703 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
|
704 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
705 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
706 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
|
707 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
|
708 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
|
709 return 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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
712 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
713 /* 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
|
714 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
|
715 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
|
716 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 (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
|
724 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
|
725 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
726 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
|
727 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
|
728 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
|
729 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
730 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
|
731 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
|
732 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
733 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
|
734 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
735 if (NILP (val)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
736 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
737 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
|
738 goto DONE; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
739 } |
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 (CONSP (val) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
742 && SYMBOLP (XCAR (val))) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
743 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
744 val = XCDR (val); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
745 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
|
746 val = XCAR (val); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
747 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
748 DONE: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
749 UNGCPRO; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
750 return val; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
751 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
752 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 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
|
757 (selection, time) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
758 Lisp_Object selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
759 Lisp_Object time; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
760 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
761 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
762 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
763 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
|
764 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
765 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
766 CHECK_SYMBOL (selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
767 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
768 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
|
769 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
|
770 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
771 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
|
772 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
773 /* 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
|
774 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
775 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
|
776 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
|
777 else |
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 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
780 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
|
781 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
|
782 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
783 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
|
784 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
785 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
786 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
787 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
788 /* 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
|
789 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
790 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
791 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
792 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
|
793 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
|
794 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
795 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
|
796 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
|
797 prepare_menu_bars (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
798 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
|
799 } |
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 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
802 BLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
803 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
804 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
|
805 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
|
806 clear_scrap (&scrap); |
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 UNBLOCK_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 return Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
811 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
812 |
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 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
|
815 0, 1, 0, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
816 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
|
817 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
|
818 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
|
819 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
|
820 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
|
821 (selection) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
822 Lisp_Object selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
823 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
824 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
825 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
826 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
|
827 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
828 check_mac (); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
829 CHECK_SYMBOL (selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
830 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
|
831 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
|
832 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
833 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
|
834 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
835 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
|
836 return Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
837 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
838 BLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
839 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
840 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
|
841 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
|
842 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
843 unsigned long timestamp; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
844 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
845 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
|
846 if (err == noErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
847 && (timestamp |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
848 == 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
|
849 result = Qt; |
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 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
852 result = Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
853 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
854 UNBLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
855 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
856 return result; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
857 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
858 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
859 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
|
860 0, 1, 0, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
861 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
|
862 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
|
863 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
|
864 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
|
865 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
|
866 (selection) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
867 Lisp_Object selection; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
868 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
869 OSErr err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
870 ScrapRef scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
871 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
|
872 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
873 /* 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
|
874 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
|
875 return Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
876 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
877 CHECK_SYMBOL (selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
878 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
|
879 return Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
880 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
|
881 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
|
882 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
883 BLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
884 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
885 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
|
886 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
|
887 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
|
888 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
889 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
|
890 && 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
|
891 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
892 result = Qt; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
893 break; |
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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
896 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
897 UNBLOCK_INPUT; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
898 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
899 return result; |
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 #ifdef MAC_OSX |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
904 void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
905 init_service_handler () |
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 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
|
908 {kEventClassService, kEventServiceCopy}, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
909 {kEventClassService, kEventServicePaste}, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
910 {kEventClassService, kEventServicePerform}}; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
911 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
|
912 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
|
913 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
914 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
915 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
|
916 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
917 static OSStatus |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
918 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
|
919 EventHandlerCallRef call_ref; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
920 EventRef event; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
921 void *data; |
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 OSStatus err = noErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
924 ScrapRef cur_scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
925 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
926 /* 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
|
927 corresponding scrap. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
928 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
|
929 err = eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
930 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
931 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
|
932 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
|
933 return eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
934 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
935 switch (GetEventKind (event)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
936 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
937 case kEventServiceGetTypes: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
938 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
939 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
|
940 CFStringRef type; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
941 Lisp_Object rest; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
942 ScrapFlavorType flavor_type; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
943 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
944 /* Set paste types. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
945 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
|
946 typeCFMutableArrayRef, NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
947 sizeof (CFMutableArrayRef), NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
948 &paste_types); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
949 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
950 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
|
951 rest = XCDR (rest)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
952 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
|
953 && (flavor_type = |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
954 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
|
955 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
956 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
|
957 if (type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
958 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
959 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
|
960 CFRelease (type); |
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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
963 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
964 /* Set copy types. */ |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
965 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
|
966 typeCFMutableArrayRef, NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
967 sizeof (CFMutableArrayRef), NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
968 ©_types); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
969 if (err == noErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
970 && !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
|
971 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
|
972 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
|
973 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
974 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
|
975 if (flavor_type) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
976 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
977 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
|
978 if (type) |
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 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
|
981 CFRelease (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 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
984 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
985 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
986 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
987 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
988 case kEventServiceCopy: |
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 ScrapRef specific_scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
991 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
|
992 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
993 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
|
994 typeScrapRef, NULL, |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
995 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
|
996 if (err == noErr |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
997 && !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
|
998 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
|
999 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
|
1000 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1001 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
|
1002 if (STRINGP (data)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1003 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
|
1004 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1005 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1006 err = eventNotHandledErr; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1007 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1008 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1009 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1010 case kEventServicePaste: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1011 case kEventServicePerform: |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1012 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1013 ScrapRef specific_scrap; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1014 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
|
1015 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
|
1016 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1017 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
|
1018 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
|
1019 &specific_scrap); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1020 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1021 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
|
1022 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1023 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
|
1024 rest = XCDR (rest)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1025 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1026 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
|
1027 continue; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1028 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
|
1029 if (STRINGP (data)) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1030 { |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1031 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
|
1032 data); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1033 if (err != noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1034 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1035 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
|
1036 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1037 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1038 if (err == noErr) |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1039 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
|
1040 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
|
1041 else |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1042 err = eventNotHandledErr; |
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 break; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1045 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1046 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1047 return err; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1048 } |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1049 #endif |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1050 |
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 void |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1053 syms_of_macselect () |
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 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
|
1056 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
|
1057 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
|
1058 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
|
1059 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
|
1060 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1061 Vselection_alist = Qnil; |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1062 staticpro (&Vselection_alist); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1063 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1064 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
|
1065 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
|
1066 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
|
1067 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
|
1068 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
|
1069 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
|
1070 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1071 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
|
1072 \(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
|
1073 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
|
1074 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
|
1075 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
|
1076 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
|
1077 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
|
1078 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1079 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
|
1080 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
|
1081 \(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
|
1082 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
|
1083 \(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
|
1084 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
|
1085 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1086 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
|
1087 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
|
1088 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
|
1089 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
|
1090 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
|
1091 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
|
1092 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 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
|
1098 set to nil. */); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1099 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
|
1100 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1101 DEFVAR_LISP ("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
|
1102 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
|
1103 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
|
1104 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1110 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
|
1111 staticpro (&Qforeign_selection); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1112 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1113 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
|
1114 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
|
1115 |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1116 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
|
1117 staticpro (&Qmac_ostype); |
c323711ae68f
New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff
changeset
|
1118 } |
61819 | 1119 |
1120 /* arch-tag: f3c91ad8-99e0-4bd6-9eef-251b2f848732 | |
1121 (do not change this comment) */ |