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