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