annotate src/objects.c @ 343:8bec6624d99b r21-1-1

Import from CVS: tag r21-1-1
author cvs
date Mon, 13 Aug 2007 10:52:53 +0200
parents c5d627a313b1
children cc15677e0335
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Generic Objects and Functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "elhash.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "faces.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "objects.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "specifier.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 /* Objects that are substituted when an instantiation fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 If we leave in the Qunbound value, we will probably get crashes. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 /* Authors: Ben Wing, Chuck Thompson */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 finalose (void *ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
45 Lisp_Object obj;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
46 XSETOBJ (obj, Lisp_Type_Record, ptr);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ("Can't dump an emacs containing window system objects", obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 * Color-Instance Object *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Lisp_Object Qcolor_instancep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 mark_color_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ((markobj) (c->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 if (!NILP (c->device)) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c, markobj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
67 return c->device;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 print_color_instance (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 char buf[100];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 error ("printing unreadable object #<color-instance 0x%x>",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 c->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 write_c_string ("#<color-instance ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 print_internal (c->name, printcharfun, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 write_c_string (" on ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 print_internal (c->device, printcharfun, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 if (!NILP (c->device)) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (c, printcharfun, escapeflag));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 sprintf (buf, " 0x%x>", c->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 finalize_color_instance (void *header, int for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 struct Lisp_Color_Instance *c = (struct Lisp_Color_Instance *) header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 if (!NILP (c->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 if (for_disksave) finalose (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 color_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 struct Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (o1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 struct Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (o2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 struct device *d1 = DEVICEP (c1->device) ? XDEVICE (c1->device) : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 struct device *d2 = DEVICEP (c2->device) ? XDEVICE (c2->device) : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 if (d1 != d2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 if (!d1 || !HAS_DEVMETH_P (d1, color_instance_equal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 return EQ (o1, o2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 return DEVMETH (d1, color_instance_equal, (c1, c2, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 color_instance_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 return HASH2 ((unsigned long) d,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 !d ? LISP_HASH (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 LISP_HASH (obj)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
129 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
130 mark_color_instance, print_color_instance,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
131 finalize_color_instance, color_instance_equal,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
132 color_instance_hash,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
133 struct Lisp_Color_Instance);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
134
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
135 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
136 Return a new `color-instance' object named NAME (a string).
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
137
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
138 Optional argument DEVICE specifies the device this object applies to
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
139 and defaults to the selected device.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
140
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
141 An error is signaled if the color is unknown or cannot be allocated;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
142 however, if optional argument NO-ERROR is non-nil, nil is simply
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
143 returned in this case. (And if NO-ERROR is other than t, a warning may
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
144 be issued.)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 The returned object is a normal, first-class lisp object. The way you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 `deallocate' the color is the way you deallocate any other lisp object:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 you drop all pointers to it and allow it to be garbage collected. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 these objects are GCed, the underlying window-system data (e.g. X object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 is deallocated as well.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
151 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
152 (name, device, no_error))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 struct Lisp_Color_Instance *c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 Lisp_Object val;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
156 int retval;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 CHECK_STRING (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 XSETDEVICE (device, decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
161 c = alloc_lcrecord_type (struct Lisp_Color_Instance, lrecord_color_instance);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 c->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 c->device = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 c->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (c, name, device,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 decode_error_behavior_flag (no_error)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 if (!retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 XSETCOLOR_INSTANCE (val, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
176 DEFUN ("color-instance-p", Fcolor_instance_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 Return non-nil if OBJECT is a color instance.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
178 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
179 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
181 return COLOR_INSTANCEP (object) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
184 DEFUN ("color-instance-name", Fcolor_instance_name, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 Return the name used to allocate COLOR-INSTANCE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
186 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
187 (color_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 CHECK_COLOR_INSTANCE (color_instance);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
190 return XCOLOR_INSTANCE (color_instance)->name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
193 DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 Return a three element list containing the red, green, and blue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 color components of COLOR-INSTANCE, or nil if unknown.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
196 Component values range from 0 to 65535.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
197 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
198 (color_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 struct Lisp_Color_Instance *c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 CHECK_COLOR_INSTANCE (color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 c = XCOLOR_INSTANCE (color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 if (NILP (c->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 return Qnil;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
207
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
208 return MAYBE_LISP_DEVMETH (XDEVICE (c->device),
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
209 color_instance_rgb_components,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
210 (c));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
213 DEFUN ("valid-color-name-p", Fvalid_color_name_p, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 Return true if COLOR names a valid color for the current device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 whatever the equivalent is on your system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 In addition to being a color this may be one of a number of attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 such as `blink'.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
222 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
223 (color, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 struct device *d = decode_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 CHECK_STRING (color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 /***************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 * Font-Instance Object *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ***************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 Lisp_Object Qfont_instancep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 Error_behavior errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 mark_font_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 struct Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ((markobj) (f->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 if (!NILP (f->device)) /* Vthe_null_font_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f, markobj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 return f->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 struct Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 error ("printing unreadable object #<font-instance 0x%x>", f->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 write_c_string ("#<font-instance ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 print_internal (f->name, printcharfun, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 write_c_string (" on ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 print_internal (f->device, printcharfun, 0);
343
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
264 if (!NILP (f->device))
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
265 MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance,
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
266 (f, printcharfun, escapeflag));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 sprintf (buf, " 0x%x>", f->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 finalize_font_instance (void *header, int for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 struct Lisp_Font_Instance *f = (struct Lisp_Font_Instance *) header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 if (!NILP (f->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 if (for_disksave) finalose (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 /* Fonts are equal if they resolve to the same name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Since we call `font-truename' to do this, and since font-truename is lazy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 this means the `equal' could cause XListFonts to be run the first time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 font_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 /* #### should this be moved into a device method? */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
291 return internal_equal (font_instance_truename_internal (o1, ERROR_ME_NOT),
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
292 font_instance_truename_internal (o2, ERROR_ME_NOT),
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
293 depth + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 font_instance_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 return internal_hash (font_instance_truename_internal (obj, ERROR_ME_NOT),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 depth + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
303 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
304 mark_font_instance, print_font_instance,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
305 finalize_font_instance, font_instance_equal,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
306 font_instance_hash, struct Lisp_Font_Instance);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
307
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
308 DEFUN ("make-font-instance", Fmake_font_instance, 1, 3, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
309 Return a new `font-instance' object named NAME.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 DEVICE specifies the device this object applies to and defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 selected device. An error is signalled if the font is unknown or cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 be allocated; however, if NOERROR is non-nil, nil is simply returned in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 this case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 The returned object is a normal, first-class lisp object. The way you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 `deallocate' the font is the way you deallocate any other lisp object:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 you drop all pointers to it and allow it to be garbage collected. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 these objects are GCed, the underlying X data is deallocated as well.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
319 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
320 (name, device, no_error))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 struct Lisp_Font_Instance *f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 int retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 Error_behavior errb = decode_error_behavior_flag (no_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 if (ERRB_EQ (errb, ERROR_ME))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 CHECK_STRING (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 else if (!STRINGP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 XSETDEVICE (device, decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
334 f = alloc_lcrecord_type (struct Lisp_Font_Instance, lrecord_font_instance);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 f->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 f->device = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 /* Stick some default values here ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 f->ascent = f->height = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 f->descent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 f->width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 f->proportional_p = 0;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
345
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (f, name, device, errb));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 if (!retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 XSETFONT_INSTANCE (val, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
356 DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 Return non-nil if OBJECT is a font instance.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
358 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
359 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
361 return FONT_INSTANCEP (object) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
364 DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 Return the name used to allocate FONT-INSTANCE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
366 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
367 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 CHECK_FONT_INSTANCE (font_instance);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
370 return XFONT_INSTANCE (font_instance)->name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
373 DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 Return the ascent in pixels of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 The returned value is the maximum ascent for all characters in the font,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 where a character's ascent is the number of pixels above (and including)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 the baseline.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
378 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
379 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 return make_int (XFONT_INSTANCE (font_instance)->ascent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
385 DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 Return the descent in pixels of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 The returned value is the maximum descent for all characters in the font,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 where a character's descent is the number of pixels below the baseline.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
389 \(Many characters to do not have any descent. Typical characters with a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 descent are lowercase p and lowercase g.)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
391 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
392 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 return make_int (XFONT_INSTANCE (font_instance)->descent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
398 DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 Return the width in pixels of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 The returned value is the average width for all characters in the font.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
401 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
402 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 return make_int (XFONT_INSTANCE (font_instance)->width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
408 DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 Return whether FONT-INSTANCE is proportional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 This means that different characters in the font have different widths.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
411 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
412 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 CHECK_FONT_INSTANCE (font_instance);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
415 return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 font_instance_truename_internal (Lisp_Object font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 struct Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance);
343
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
423
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
424 if (NILP (f->device))
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
425 {
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
426 maybe_signal_simple_error ("Couldn't determine font truename",
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
427 font_instance, Qfont, errb);
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
428 return Qnil;
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
429 }
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
430
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
431 return DEVMETH_OR_GIVEN (XDEVICE (f->device),
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
432 font_instance_truename, (f, errb), f->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
435 DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 Return the canonical name of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 Font names are patterns which may match any number of fonts, of which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 the first found is used. This returns an unambiguous name for that font
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
439 \(but not necessarily its only unambiguous name).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
440 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
441 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 return font_instance_truename_internal (font_instance, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
447 DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Return the properties (an alist or nil) of FONT-INSTANCE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
449 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
450 (font_instance))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 struct Lisp_Font_Instance *f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 f = XFONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
343
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
457 if (NILP (f->device))
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
458 return Qnil;
8bec6624d99b Import from CVS: tag r21-1-1
cvs
parents: 272
diff changeset
459
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 return MAYBE_LISP_DEVMETH (XDEVICE (f->device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 font_instance_properties, (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
464 DEFUN ("list-fonts", Flist_fonts, 1, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 Return a list of font names matching the given pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 DEVICE specifies which device to search for names, and defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 currently selected device.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
468 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
469 (pattern, device))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 CHECK_STRING (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 XSETDEVICE (device, decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 Color Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ***************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 DEFINE_SPECIFIER_TYPE (color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 /* Qcolor defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 color_create (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 COLOR_SPECIFIER_FACE (color) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 color_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ((markobj) (COLOR_SPECIFIER_FACE (color)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ((markobj) (COLOR_SPECIFIER_FACE_PROPERTY (color)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 /* No equal or hash methods; ignore the face the color is based off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 of for `equal' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 color_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 Lisp_Object domain, Lisp_Object instantiator,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 Lisp_Object depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 /* When called, we're inside of call_with_suspended_errors(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 so we can freely error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 Lisp_Object device = DFW_DEVICE (domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 struct device *d = XDEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 Lisp_Object instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 if (COLOR_INSTANCEP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 /* If we are on the same device then we're done. Otherwise change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 the instantiator to the name used to generate the pixel and let the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 STRINGP case deal with it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 if (NILP (device) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 || EQ (device, XCOLOR_INSTANCE (instantiator)->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 return instantiator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 instantiator = Fcolor_instance_name (instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 if (STRINGP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 /* First, look to see if we can retrieve a cached value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 instance = Fgethash (instantiator, d->color_instance_cache, Qunbound);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 /* Otherwise, make a new one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 if (UNBOUNDP (instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 /* make sure we cache the failures, too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 instance = Fmake_color_instance (instantiator, device, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 Fputhash (instantiator, instance, d->color_instance_cache);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
540 return NILP (instance) ? Qunbound : instance;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
544 switch (XVECTOR_LENGTH (instantiator))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 if (DEVICE_TTY_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 return Vthe_null_color_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 signal_simple_error ("Color instantiator [] only valid on TTY's",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 case 1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 signal_simple_error ("Color specifier not attached to a face",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 return (FACE_PROPERTY_INSTANCE_1
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
558 (Fget_face (XVECTOR_DATA (instantiator)[0]),
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
559 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)),
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
560 domain, ERROR_ME, 0, depth));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 case 2:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 return (FACE_PROPERTY_INSTANCE_1
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
564 (Fget_face (XVECTOR_DATA (instantiator)[0]),
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
565 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, 0, depth));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 else if (NILP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 if (DEVICE_TTY_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 return Vthe_null_color_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 signal_simple_error ("Color instantiator [] only valid on TTY's",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 abort (); /* The spec validation routines are screwed up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 color_validate (Lisp_Object instantiator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
592 if (XVECTOR_LENGTH (instantiator) > 2)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 signal_simple_error ("Inheritance vector must be of size 0 - 2",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 instantiator);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
595 else if (XVECTOR_LENGTH (instantiator) > 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
597 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
598
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 Fget_face (face);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
600 if (XVECTOR_LENGTH (instantiator) == 2)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
602 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 if (!EQ (field, Qforeground) && !EQ (field, Qbackground))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ("Inheritance field must be `foreground' or `background'",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 signal_simple_error ("Invalid color instantiator", instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 color_after_change (Lisp_Object specifier, Lisp_Object locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 Lisp_Object property =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 if (!NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 face_property_was_changed (face, property, locale);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 COLOR_SPECIFIER_FACE (color) = face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 COLOR_SPECIFIER_FACE_PROPERTY (color) = property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
633 DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 227
diff changeset
634 Return t if OBJECT is a color specifier.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 Valid instantiators for color specifiers are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
638 -- a string naming a color (e.g. under X this might be "lightseagreen2"
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
639 or "#F534B2")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 -- a color instance (use that instance directly if the device matches,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 or use the string that generated it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 -- a vector of no elements (only on TTY's; this means to set no color
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
643 at all, thus using the "natural" color of the terminal's text)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 -- a vector of one or two elements: a face to inherit from, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 optionally a symbol naming which property of that face to inherit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 either `foreground' or `background' (if omitted, defaults to the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 property that this color specifier is used for; if this specifier is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 not part of a face, the instantiator would not be valid)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
649 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
650 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
652 return COLOR_SPECIFIERP (object) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 Font Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ***************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 DEFINE_SPECIFIER_TYPE (font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 /* Qfont defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 font_create (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 FONT_SPECIFIER_FACE (font) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 font_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ((markobj) (FONT_SPECIFIER_FACE (font)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ((markobj) (FONT_SPECIFIER_FACE_PROPERTY (font)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 /* No equal or hash methods; ignore the face the font is based off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 of for `equal' */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
682
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
683 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
684
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
685 int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
686 font_spec_matches_charset (struct device *d, Lisp_Object charset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
687 CONST Bufbyte *nonreloc, Lisp_Object reloc,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
688 Bytecount offset, Bytecount length)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
689 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
690 return DEVMETH_OR_GIVEN (d, font_spec_matches_charset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
691 (d, charset, nonreloc, reloc, offset, length),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
692 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
693 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
694
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
695 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
696 font_validate_matchspec (Lisp_Object matchspec)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
697 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
698 Fget_charset (matchspec);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
699 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
700
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
701 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
702
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
703
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 font_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 Lisp_Object domain, Lisp_Object instantiator,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 Lisp_Object depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 /* When called, we're inside of call_with_suspended_errors(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 so we can freely error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 Lisp_Object device = DFW_DEVICE (domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 struct device *d = XDEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Lisp_Object instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
715 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
716 if (!UNBOUNDP (matchspec))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
717 matchspec = Fget_charset (matchspec);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
718 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
719
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 if (FONT_INSTANCEP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 {
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
722 if (NILP (device)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 || EQ (device, XFONT_INSTANCE (instantiator)->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 {
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
725 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
726 if (font_spec_matches_charset (d, matchspec, 0,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
727 Ffont_instance_truename
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
728 (instantiator),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
729 0, -1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
730 return instantiator;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
731 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 return instantiator;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
733 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 instantiator = Ffont_instance_name (instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
737
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
738 if (STRINGP (instantiator))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 {
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
740 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
741 if (!UNBOUNDP (matchspec))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
742 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
743 /* The instantiator is a font spec that could match many
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
744 different fonts. We need to find one of those fonts
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
745 whose registry matches the registry of the charset in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
746 MATCHSPEC. This is potentially a very slow operation,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
747 as it involves doing an XListFonts() or equivalent to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
748 iterate over all possible fonts, and a regexp match
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
749 on each one. So we cache the results. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
750 Lisp_Object matching_font = Qunbound;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
751 Lisp_Object hashtab = Fgethash (matchspec, d->charset_font_cache,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
752 Qunbound);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
753 if (UNBOUNDP (hashtab))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
754 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
755 /* need to make a sub hash table. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
756 hashtab = make_lisp_hashtable (20, HASHTABLE_KEY_WEAK,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
757 HASHTABLE_EQUAL);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
758 Fputhash (matchspec, hashtab, d->charset_font_cache);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
759 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
760 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
761 matching_font = Fgethash (instantiator, hashtab, Qunbound);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
762
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
763 if (UNBOUNDP (matching_font))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
764 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
765 /* make sure we cache the failures, too. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
766 matching_font =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
767 DEVMETH_OR_GIVEN (d, find_charset_font,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
768 (device, instantiator, matchspec),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
769 instantiator);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
770 Fputhash (instantiator, matching_font, hashtab);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
771 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
772 if (NILP (matching_font))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
773 return Qunbound;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
774 instantiator = matching_font;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
775 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
776 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
777
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 /* First, look to see if we can retrieve a cached value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 instance = Fgethash (instantiator, d->font_instance_cache, Qunbound);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 /* Otherwise, make a new one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 if (UNBOUNDP (instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 /* make sure we cache the failures, too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 instance = Fmake_font_instance (instantiator, device, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 Fputhash (instantiator, instance, d->font_instance_cache);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
788 return NILP (instance) ? Qunbound : instance;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
792 assert (XVECTOR_LENGTH (instantiator) == 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 return (face_property_matching_instance
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
794 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 matchspec, domain, ERROR_ME, 0, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 else if (NILP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 abort (); /* Eh? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 font_validate (Lisp_Object instantiator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
812 if (XVECTOR_LENGTH (instantiator) != 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ("Vector length must be one for font inheritance", instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
817 Fget_face (XVECTOR_DATA (instantiator)[0]);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 signal_simple_error ("Must be string, vector, or font-instance",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 font_after_change (Lisp_Object specifier, Lisp_Object locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 Lisp_Object property =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 if (!NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 face_property_was_changed (face, property, locale);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 FONT_SPECIFIER_FACE (font) = face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 FONT_SPECIFIER_FACE_PROPERTY (font) = property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
843 DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 Return non-nil if OBJECT is a font specifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 Valid instantiators for font specifiers are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 -- a string naming a font (e.g. under X this might be
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
849 "-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*" for a 14-point
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 upright medium-weight Courier font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 -- a font instance (use that instance directly if the device matches,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 or use the string that generated it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 -- a vector of no elements (only on TTY's; this means to set no font
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
854 at all, thus using the "natural" font of the terminal's text)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 -- a vector of one element (a face to inherit from)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
856 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
857 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
859 return FONT_SPECIFIERP (object) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 Face Boolean Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 DEFINE_SPECIFIER_TYPE (face_boolean);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 Lisp_Object Qface_boolean;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 face_boolean_create (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 face_boolean_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ((markobj) (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ((markobj) (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 /* No equal or hash methods; ignore the face the face-boolean is based off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 of for `equal' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 face_boolean_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 Lisp_Object domain, Lisp_Object instantiator,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 Lisp_Object depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 /* When called, we're inside of call_with_suspended_errors(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 so we can freely error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 if (NILP (instantiator) || EQ (instantiator, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 return instantiator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 Lisp_Object prop;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
903 int instantiator_len = XVECTOR_LENGTH (instantiator);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
905 assert (instantiator_len >= 1 && instantiator_len <= 3);
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
906 if (instantiator_len > 1)
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
907 prop = XVECTOR_DATA (instantiator)[1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 if (NILP (FACE_BOOLEAN_SPECIFIER_FACE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (XFACE_BOOLEAN_SPECIFIER (specifier))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ("Face-boolean specifier not attached to a face", instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (XFACE_BOOLEAN_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 retval = (FACE_PROPERTY_INSTANCE_1
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
919 (Fget_face (XVECTOR_DATA (instantiator)[0]),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 prop, domain, ERROR_ME, 0, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
922 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2]))
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
923 retval = NILP (retval) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 abort (); /* Eh? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 face_boolean_validate (Lisp_Object instantiator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 if (NILP (instantiator) || EQ (instantiator, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 else if (VECTORP (instantiator) &&
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
939 (XVECTOR_LENGTH (instantiator) >= 1 &&
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
940 XVECTOR_LENGTH (instantiator) <= 3))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
942 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
943
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 Fget_face (face);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
946 if (XVECTOR_LENGTH (instantiator) > 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
948 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 if (!EQ (field, Qunderline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 && !EQ (field, Qstrikethru)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 && !EQ (field, Qhighlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 && !EQ (field, Qdim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 && !EQ (field, Qblinking)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 && !EQ (field, Qreverse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 signal_simple_error ("Invalid face-boolean inheritance field",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 signal_simple_error ("Wrong length for face-boolean inheritance spec",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 signal_simple_error ("Face-boolean instantiator must be nil, t, or vector",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 Lisp_Object face =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 Lisp_Object property =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 if (!NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 face_property_was_changed (face, property, locale);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
988 DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 Return non-nil if OBJECT is a face-boolean specifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 Valid instantiators for face-boolean specifiers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 -- t or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 -- a vector of two or three elements: a face to inherit from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 optionally a symbol naming the property of that face to inherit from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (if omitted, defaults to the same property that this face-boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 specifier is used for; if this specifier is not part of a face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 the instantiator would not be valid), and optionally a value which,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 if non-nil, means to invert the sense of the inherited property.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1000 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1001 (object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
1003 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 syms_of_objects (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 {
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1014 DEFSUBR (Fcolor_specifier_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1015 DEFSUBR (Ffont_specifier_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1016 DEFSUBR (Fface_boolean_specifier_p);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 defsymbol (&Qcolor_instancep, "color-instance-p");
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1019 DEFSUBR (Fmake_color_instance);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1020 DEFSUBR (Fcolor_instance_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1021 DEFSUBR (Fcolor_instance_name);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1022 DEFSUBR (Fcolor_instance_rgb_components);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1023 DEFSUBR (Fvalid_color_name_p);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 defsymbol (&Qfont_instancep, "font-instance-p");
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1026 DEFSUBR (Fmake_font_instance);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1027 DEFSUBR (Ffont_instance_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1028 DEFSUBR (Ffont_instance_name);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1029 DEFSUBR (Ffont_instance_ascent);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1030 DEFSUBR (Ffont_instance_descent);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1031 DEFSUBR (Ffont_instance_width);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1032 DEFSUBR (Ffont_instance_proportional_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1033 DEFSUBR (Ffont_instance_truename);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1034 DEFSUBR (Ffont_instance_properties);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 2
diff changeset
1035 DEFSUBR (Flist_fonts);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 /* Qcolor, Qfont defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 defsymbol (&Qface_boolean, "face-boolean");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 specifier_type_create_objects (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 "face-boolean-specifier-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 SPECIFIER_HAS_METHOD (color, instantiate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 SPECIFIER_HAS_METHOD (font, instantiate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 SPECIFIER_HAS_METHOD (face_boolean, instantiate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 SPECIFIER_HAS_METHOD (color, validate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 SPECIFIER_HAS_METHOD (font, validate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 SPECIFIER_HAS_METHOD (face_boolean, validate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 SPECIFIER_HAS_METHOD (color, create);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 SPECIFIER_HAS_METHOD (font, create);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 SPECIFIER_HAS_METHOD (face_boolean, create);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 SPECIFIER_HAS_METHOD (color, mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 SPECIFIER_HAS_METHOD (font, mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 SPECIFIER_HAS_METHOD (face_boolean, mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 SPECIFIER_HAS_METHOD (color, after_change);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 SPECIFIER_HAS_METHOD (font, after_change);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 SPECIFIER_HAS_METHOD (face_boolean, after_change);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1068
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1069 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1070 SPECIFIER_HAS_METHOD (font, validate_matchspec);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 20
diff changeset
1071 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 vars_of_objects (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 staticpro (&Vthe_null_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
1079 struct Lisp_Color_Instance *c =
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
1080 alloc_lcrecord_type (struct Lisp_Color_Instance, lrecord_color_instance);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 c->name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 c->device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 c->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 XSETCOLOR_INSTANCE (Vthe_null_color_instance, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 }
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
1087
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 staticpro (&Vthe_null_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
1090 struct Lisp_Font_Instance *f =
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 173
diff changeset
1091 alloc_lcrecord_type (struct Lisp_Font_Instance, lrecord_font_instance);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 f->name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 f->device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 f->ascent = f->height = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 f->descent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 f->width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 f->proportional_p = 0;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 70
diff changeset
1100
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 XSETFONT_INSTANCE (Vthe_null_font_instance, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 }