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"
|
872
|
29 #include "device-impl.h"
|
428
|
30 #include "elhash.h"
|
|
31 #include "faces.h"
|
|
32 #include "frame.h"
|
800
|
33 #include "glyphs.h"
|
872
|
34 #include "objects-impl.h"
|
428
|
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);
|
872
|
241 mark_object (f->truename);
|
428
|
242 if (!NILP (f->device)) /* Vthe_null_font_instance */
|
|
243 MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f));
|
|
244
|
|
245 return f->device;
|
|
246 }
|
|
247
|
|
248 static void
|
|
249 print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
250 {
|
440
|
251 Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
|
428
|
252 if (print_readably)
|
563
|
253 printing_unreadable_object ("#<font-instance 0x%x>", f->header.uid);
|
800
|
254 write_fmt_string_lisp (printcharfun, "#<font-instance %S", 1, f->name);
|
|
255 write_fmt_string_lisp (printcharfun, " on %s", 1, f->device);
|
428
|
256 if (!NILP (f->device))
|
|
257 MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance,
|
|
258 (f, printcharfun, escapeflag));
|
800
|
259 write_fmt_string (printcharfun, " 0x%x>", f->header.uid);
|
428
|
260 }
|
|
261
|
|
262 static void
|
|
263 finalize_font_instance (void *header, int for_disksave)
|
|
264 {
|
440
|
265 Lisp_Font_Instance *f = (Lisp_Font_Instance *) header;
|
428
|
266
|
|
267 if (!NILP (f->device))
|
|
268 {
|
|
269 if (for_disksave) finalose (f);
|
|
270 MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f));
|
|
271 }
|
|
272 }
|
|
273
|
|
274 /* Fonts are equal if they resolve to the same name.
|
|
275 Since we call `font-truename' to do this, and since font-truename is lazy,
|
|
276 this means the `equal' could cause XListFonts to be run the first time.
|
|
277 */
|
|
278 static int
|
|
279 font_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
280 {
|
|
281 /* #### should this be moved into a device method? */
|
793
|
282 return internal_equal (font_instance_truename_internal
|
|
283 (obj1, ERROR_ME_DEBUG_WARN),
|
|
284 font_instance_truename_internal
|
|
285 (obj2, ERROR_ME_DEBUG_WARN),
|
428
|
286 depth + 1);
|
|
287 }
|
|
288
|
|
289 static unsigned long
|
|
290 font_instance_hash (Lisp_Object obj, int depth)
|
|
291 {
|
793
|
292 return internal_hash (font_instance_truename_internal
|
|
293 (obj, ERROR_ME_DEBUG_WARN),
|
428
|
294 depth + 1);
|
|
295 }
|
|
296
|
|
297 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
|
|
298 mark_font_instance, print_font_instance,
|
|
299 finalize_font_instance, font_instance_equal,
|
440
|
300 font_instance_hash, 0, Lisp_Font_Instance);
|
428
|
301
|
|
302 DEFUN ("make-font-instance", Fmake_font_instance, 1, 3, 0, /*
|
|
303 Return a new `font-instance' object named NAME.
|
|
304 DEVICE specifies the device this object applies to and defaults to the
|
|
305 selected device. An error is signalled if the font is unknown or cannot
|
|
306 be allocated; however, if NOERROR is non-nil, nil is simply returned in
|
|
307 this case.
|
|
308
|
|
309 The returned object is a normal, first-class lisp object. The way you
|
|
310 `deallocate' the font is the way you deallocate any other lisp object:
|
|
311 you drop all pointers to it and allow it to be garbage collected. When
|
|
312 these objects are GCed, the underlying X data is deallocated as well.
|
|
313 */
|
444
|
314 (name, device, noerror))
|
428
|
315 {
|
440
|
316 Lisp_Font_Instance *f;
|
428
|
317 int retval = 0;
|
578
|
318 Error_Behavior errb = decode_error_behavior_flag (noerror);
|
428
|
319
|
|
320 if (ERRB_EQ (errb, ERROR_ME))
|
|
321 CHECK_STRING (name);
|
|
322 else if (!STRINGP (name))
|
|
323 return Qnil;
|
|
324
|
793
|
325 device = wrap_device (decode_device (device));
|
428
|
326
|
440
|
327 f = alloc_lcrecord_type (Lisp_Font_Instance, &lrecord_font_instance);
|
428
|
328 f->name = name;
|
872
|
329 f->truename = Qnil;
|
428
|
330 f->device = device;
|
|
331
|
|
332 f->data = 0;
|
|
333
|
|
334 /* Stick some default values here ... */
|
|
335 f->ascent = f->height = 1;
|
|
336 f->descent = 0;
|
|
337 f->width = 1;
|
|
338 f->proportional_p = 0;
|
|
339
|
|
340 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance,
|
|
341 (f, name, device, errb));
|
|
342
|
|
343 if (!retval)
|
|
344 return Qnil;
|
|
345
|
793
|
346 return wrap_font_instance (f);
|
428
|
347 }
|
|
348
|
|
349 DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /*
|
|
350 Return non-nil if OBJECT is a font instance.
|
|
351 */
|
|
352 (object))
|
|
353 {
|
|
354 return FONT_INSTANCEP (object) ? Qt : Qnil;
|
|
355 }
|
|
356
|
|
357 DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /*
|
|
358 Return the name used to allocate FONT-INSTANCE.
|
|
359 */
|
|
360 (font_instance))
|
|
361 {
|
|
362 CHECK_FONT_INSTANCE (font_instance);
|
|
363 return XFONT_INSTANCE (font_instance)->name;
|
|
364 }
|
|
365
|
|
366 DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /*
|
|
367 Return the ascent in pixels of FONT-INSTANCE.
|
|
368 The returned value is the maximum ascent for all characters in the font,
|
|
369 where a character's ascent is the number of pixels above (and including)
|
|
370 the baseline.
|
|
371 */
|
|
372 (font_instance))
|
|
373 {
|
|
374 CHECK_FONT_INSTANCE (font_instance);
|
|
375 return make_int (XFONT_INSTANCE (font_instance)->ascent);
|
|
376 }
|
|
377
|
|
378 DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /*
|
|
379 Return the descent in pixels of FONT-INSTANCE.
|
|
380 The returned value is the maximum descent for all characters in the font,
|
|
381 where a character's descent is the number of pixels below the baseline.
|
|
382 \(Many characters to do not have any descent. Typical characters with a
|
|
383 descent are lowercase p and lowercase g.)
|
|
384 */
|
|
385 (font_instance))
|
|
386 {
|
|
387 CHECK_FONT_INSTANCE (font_instance);
|
|
388 return make_int (XFONT_INSTANCE (font_instance)->descent);
|
|
389 }
|
|
390
|
|
391 DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /*
|
|
392 Return the width in pixels of FONT-INSTANCE.
|
|
393 The returned value is the average width for all characters in the font.
|
|
394 */
|
|
395 (font_instance))
|
|
396 {
|
|
397 CHECK_FONT_INSTANCE (font_instance);
|
|
398 return make_int (XFONT_INSTANCE (font_instance)->width);
|
|
399 }
|
|
400
|
|
401 DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /*
|
|
402 Return whether FONT-INSTANCE is proportional.
|
|
403 This means that different characters in the font have different widths.
|
|
404 */
|
|
405 (font_instance))
|
|
406 {
|
|
407 CHECK_FONT_INSTANCE (font_instance);
|
|
408 return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil;
|
|
409 }
|
|
410
|
|
411 static Lisp_Object
|
|
412 font_instance_truename_internal (Lisp_Object font_instance,
|
578
|
413 Error_Behavior errb)
|
428
|
414 {
|
440
|
415 Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance);
|
|
416
|
428
|
417 if (NILP (f->device))
|
|
418 {
|
563
|
419 maybe_signal_error (Qgui_error, "Couldn't determine font truename",
|
|
420 font_instance, Qfont, errb);
|
428
|
421 return Qnil;
|
|
422 }
|
440
|
423
|
428
|
424 return DEVMETH_OR_GIVEN (XDEVICE (f->device),
|
|
425 font_instance_truename, (f, errb), f->name);
|
|
426 }
|
|
427
|
|
428 DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /*
|
|
429 Return the canonical name of FONT-INSTANCE.
|
|
430 Font names are patterns which may match any number of fonts, of which
|
|
431 the first found is used. This returns an unambiguous name for that font
|
|
432 \(but not necessarily its only unambiguous name).
|
|
433 */
|
|
434 (font_instance))
|
|
435 {
|
|
436 CHECK_FONT_INSTANCE (font_instance);
|
|
437 return font_instance_truename_internal (font_instance, ERROR_ME);
|
|
438 }
|
|
439
|
|
440 DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /*
|
|
441 Return the properties (an alist or nil) of FONT-INSTANCE.
|
|
442 */
|
|
443 (font_instance))
|
|
444 {
|
440
|
445 Lisp_Font_Instance *f;
|
428
|
446
|
|
447 CHECK_FONT_INSTANCE (font_instance);
|
|
448 f = XFONT_INSTANCE (font_instance);
|
|
449
|
|
450 if (NILP (f->device))
|
|
451 return Qnil;
|
|
452
|
|
453 return MAYBE_LISP_DEVMETH (XDEVICE (f->device),
|
|
454 font_instance_properties, (f));
|
|
455 }
|
|
456
|
|
457 DEFUN ("list-fonts", Flist_fonts, 1, 2, 0, /*
|
|
458 Return a list of font names matching the given pattern.
|
|
459 DEVICE specifies which device to search for names, and defaults to the
|
|
460 currently selected device.
|
|
461 */
|
|
462 (pattern, device))
|
|
463 {
|
|
464 CHECK_STRING (pattern);
|
793
|
465 device = wrap_device (decode_device (device));
|
428
|
466
|
|
467 return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device));
|
|
468 }
|
|
469
|
|
470
|
|
471 /****************************************************************************
|
|
472 Color Object
|
|
473 ***************************************************************************/
|
|
474 DEFINE_SPECIFIER_TYPE (color);
|
|
475 /* Qcolor defined in general.c */
|
|
476
|
|
477 static void
|
|
478 color_create (Lisp_Object obj)
|
|
479 {
|
440
|
480 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
|
428
|
481
|
|
482 COLOR_SPECIFIER_FACE (color) = Qnil;
|
|
483 COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil;
|
|
484 }
|
|
485
|
|
486 static void
|
|
487 color_mark (Lisp_Object obj)
|
|
488 {
|
440
|
489 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
|
428
|
490
|
|
491 mark_object (COLOR_SPECIFIER_FACE (color));
|
|
492 mark_object (COLOR_SPECIFIER_FACE_PROPERTY (color));
|
|
493 }
|
|
494
|
|
495 /* No equal or hash methods; ignore the face the color is based off
|
|
496 of for `equal' */
|
|
497
|
|
498 static Lisp_Object
|
|
499 color_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
500 Lisp_Object domain, Lisp_Object instantiator,
|
|
501 Lisp_Object depth)
|
|
502 {
|
|
503 /* When called, we're inside of call_with_suspended_errors(),
|
|
504 so we can freely error. */
|
442
|
505 Lisp_Object device = DOMAIN_DEVICE (domain);
|
428
|
506 struct device *d = XDEVICE (device);
|
|
507
|
|
508 if (COLOR_INSTANCEP (instantiator))
|
|
509 {
|
|
510 /* If we are on the same device then we're done. Otherwise change
|
|
511 the instantiator to the name used to generate the pixel and let the
|
|
512 STRINGP case deal with it. */
|
|
513 if (NILP (device) /* Vthe_null_color_instance */
|
|
514 || EQ (device, XCOLOR_INSTANCE (instantiator)->device))
|
|
515 return instantiator;
|
|
516 else
|
|
517 instantiator = Fcolor_instance_name (instantiator);
|
|
518 }
|
|
519
|
|
520 if (STRINGP (instantiator))
|
|
521 {
|
|
522 /* First, look to see if we can retrieve a cached value. */
|
|
523 Lisp_Object instance =
|
|
524 Fgethash (instantiator, d->color_instance_cache, Qunbound);
|
|
525 /* Otherwise, make a new one. */
|
|
526 if (UNBOUNDP (instance))
|
|
527 {
|
|
528 /* make sure we cache the failures, too. */
|
|
529 instance = Fmake_color_instance (instantiator, device, Qt);
|
|
530 Fputhash (instantiator, instance, d->color_instance_cache);
|
|
531 }
|
|
532
|
|
533 return NILP (instance) ? Qunbound : instance;
|
|
534 }
|
|
535 else if (VECTORP (instantiator))
|
|
536 {
|
|
537 switch (XVECTOR_LENGTH (instantiator))
|
|
538 {
|
|
539 case 0:
|
|
540 if (DEVICE_TTY_P (d))
|
|
541 return Vthe_null_color_instance;
|
|
542 else
|
563
|
543 gui_error ("Color instantiator [] only valid on TTY's",
|
428
|
544 device);
|
|
545
|
|
546 case 1:
|
|
547 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier))))
|
563
|
548 gui_error ("Color specifier not attached to a face",
|
428
|
549 instantiator);
|
|
550 return (FACE_PROPERTY_INSTANCE_1
|
|
551 (Fget_face (XVECTOR_DATA (instantiator)[0]),
|
|
552 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)),
|
|
553 domain, ERROR_ME, 0, depth));
|
|
554
|
|
555 case 2:
|
|
556 return (FACE_PROPERTY_INSTANCE_1
|
|
557 (Fget_face (XVECTOR_DATA (instantiator)[0]),
|
|
558 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, 0, depth));
|
|
559
|
|
560 default:
|
|
561 abort ();
|
|
562 }
|
|
563 }
|
|
564 else if (NILP (instantiator))
|
|
565 {
|
|
566 if (DEVICE_TTY_P (d))
|
|
567 return Vthe_null_color_instance;
|
|
568 else
|
563
|
569 gui_error ("Color instantiator [] only valid on TTY's",
|
428
|
570 device);
|
|
571 }
|
|
572 else
|
|
573 abort (); /* The spec validation routines are screwed up. */
|
|
574
|
|
575 return Qunbound;
|
|
576 }
|
|
577
|
|
578 static void
|
|
579 color_validate (Lisp_Object instantiator)
|
|
580 {
|
|
581 if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator))
|
|
582 return;
|
|
583 if (VECTORP (instantiator))
|
|
584 {
|
|
585 if (XVECTOR_LENGTH (instantiator) > 2)
|
563
|
586 sferror ("Inheritance vector must be of size 0 - 2",
|
428
|
587 instantiator);
|
|
588 else if (XVECTOR_LENGTH (instantiator) > 0)
|
|
589 {
|
|
590 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
|
|
591
|
|
592 Fget_face (face);
|
|
593 if (XVECTOR_LENGTH (instantiator) == 2)
|
|
594 {
|
|
595 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
|
|
596 if (!EQ (field, Qforeground) && !EQ (field, Qbackground))
|
563
|
597 invalid_constant
|
428
|
598 ("Inheritance field must be `foreground' or `background'",
|
|
599 field);
|
|
600 }
|
|
601 }
|
|
602 }
|
|
603 else
|
563
|
604 invalid_argument ("Invalid color instantiator", instantiator);
|
428
|
605 }
|
|
606
|
|
607 static void
|
|
608 color_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
609 {
|
|
610 Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier));
|
|
611 Lisp_Object property =
|
|
612 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier));
|
|
613 if (!NILP (face))
|
448
|
614 {
|
|
615 face_property_was_changed (face, property, locale);
|
|
616 if (BUFFERP (locale))
|
|
617 XBUFFER (locale)->buffer_local_face_property = 1;
|
|
618 }
|
428
|
619 }
|
|
620
|
|
621 void
|
|
622 set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
|
|
623 {
|
440
|
624 Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
|
428
|
625
|
|
626 COLOR_SPECIFIER_FACE (color) = face;
|
|
627 COLOR_SPECIFIER_FACE_PROPERTY (color) = property;
|
|
628 }
|
|
629
|
|
630 DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /*
|
|
631 Return t if OBJECT is a color specifier.
|
|
632
|
442
|
633 See `make-color-specifier' for a description of possible color instantiators.
|
428
|
634 */
|
|
635 (object))
|
|
636 {
|
|
637 return COLOR_SPECIFIERP (object) ? Qt : Qnil;
|
|
638 }
|
|
639
|
|
640
|
|
641 /****************************************************************************
|
|
642 Font Object
|
|
643 ***************************************************************************/
|
|
644 DEFINE_SPECIFIER_TYPE (font);
|
|
645 /* Qfont defined in general.c */
|
|
646
|
|
647 static void
|
|
648 font_create (Lisp_Object obj)
|
|
649 {
|
440
|
650 Lisp_Specifier *font = XFONT_SPECIFIER (obj);
|
428
|
651
|
|
652 FONT_SPECIFIER_FACE (font) = Qnil;
|
|
653 FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil;
|
|
654 }
|
|
655
|
|
656 static void
|
|
657 font_mark (Lisp_Object obj)
|
|
658 {
|
440
|
659 Lisp_Specifier *font = XFONT_SPECIFIER (obj);
|
428
|
660
|
|
661 mark_object (FONT_SPECIFIER_FACE (font));
|
|
662 mark_object (FONT_SPECIFIER_FACE_PROPERTY (font));
|
|
663 }
|
|
664
|
|
665 /* No equal or hash methods; ignore the face the font is based off
|
|
666 of for `equal' */
|
|
667
|
|
668 #ifdef MULE
|
|
669
|
872
|
670 /* Given a truename font spec (i.e. the font spec should have its registry
|
|
671 field filled in), does it support displaying characters from CHARSET? */
|
|
672
|
|
673 static int
|
428
|
674 font_spec_matches_charset (struct device *d, Lisp_Object charset,
|
867
|
675 const Ibyte *nonreloc, Lisp_Object reloc,
|
872
|
676 Bytecount offset, Bytecount length,
|
|
677 int stage)
|
428
|
678 {
|
|
679 return DEVMETH_OR_GIVEN (d, font_spec_matches_charset,
|
872
|
680 (d, charset, nonreloc, reloc, offset, length,
|
|
681 stage),
|
428
|
682 1);
|
|
683 }
|
|
684
|
|
685 static void
|
|
686 font_validate_matchspec (Lisp_Object matchspec)
|
|
687 {
|
872
|
688 CHECK_CONS (matchspec);
|
|
689 Fget_charset (XCAR (matchspec));
|
428
|
690 }
|
|
691
|
|
692 #endif /* MULE */
|
|
693
|
872
|
694 void
|
|
695 initialize_charset_font_caches (struct device *d)
|
|
696 {
|
|
697 /* Note that the following tables are bi-level. */
|
|
698 d->charset_font_cache_stage_1 =
|
|
699 make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
|
700 d->charset_font_cache_stage_2 =
|
|
701 make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
|
702 }
|
|
703
|
|
704 void
|
|
705 invalidate_charset_font_caches (Lisp_Object charset)
|
|
706 {
|
|
707 /* Invalidate font cache entries for charset on all devices. */
|
|
708 Lisp_Object devcons, concons, hash_table;
|
|
709 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
710 {
|
|
711 struct device *d = XDEVICE (XCAR (devcons));
|
|
712 hash_table = Fgethash (charset, d->charset_font_cache_stage_1,
|
|
713 Qunbound);
|
|
714 if (!UNBOUNDP (hash_table))
|
|
715 Fclrhash (hash_table);
|
|
716 hash_table = Fgethash (charset, d->charset_font_cache_stage_2,
|
|
717 Qunbound);
|
|
718 if (!UNBOUNDP (hash_table))
|
|
719 Fclrhash (hash_table);
|
|
720 }
|
|
721 }
|
428
|
722
|
|
723 static Lisp_Object
|
|
724 font_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
725 Lisp_Object domain, Lisp_Object instantiator,
|
|
726 Lisp_Object depth)
|
|
727 {
|
|
728 /* When called, we're inside of call_with_suspended_errors(),
|
|
729 so we can freely error. */
|
442
|
730 Lisp_Object device = DOMAIN_DEVICE (domain);
|
428
|
731 struct device *d = XDEVICE (device);
|
|
732 Lisp_Object instance;
|
872
|
733 Lisp_Object charset = Qnil;
|
|
734 int stage = 0;
|
428
|
735
|
|
736 #ifdef MULE
|
|
737 if (!UNBOUNDP (matchspec))
|
872
|
738 {
|
|
739 charset = Fget_charset (XCAR (matchspec));
|
|
740 stage = NILP (XCDR (matchspec)) ? 0 : 1;
|
|
741 }
|
428
|
742 #endif
|
|
743
|
|
744 if (FONT_INSTANCEP (instantiator))
|
|
745 {
|
|
746 if (NILP (device)
|
|
747 || EQ (device, XFONT_INSTANCE (instantiator)->device))
|
|
748 {
|
|
749 #ifdef MULE
|
872
|
750 if (font_spec_matches_charset (d, charset, 0,
|
428
|
751 Ffont_instance_truename
|
|
752 (instantiator),
|
872
|
753 0, -1, stage))
|
428
|
754 return instantiator;
|
|
755 #else
|
|
756 return instantiator;
|
|
757 #endif
|
|
758 }
|
|
759 instantiator = Ffont_instance_name (instantiator);
|
|
760 }
|
|
761
|
|
762 if (STRINGP (instantiator))
|
|
763 {
|
872
|
764 Lisp_Object cache = stage ? d->charset_font_cache_stage_2 :
|
|
765 d->charset_font_cache_stage_1;
|
|
766
|
428
|
767 #ifdef MULE
|
872
|
768 if (!NILP (charset))
|
428
|
769 {
|
|
770 /* The instantiator is a font spec that could match many
|
|
771 different fonts. We need to find one of those fonts
|
|
772 whose registry matches the registry of the charset in
|
|
773 MATCHSPEC. This is potentially a very slow operation,
|
|
774 as it involves doing an XListFonts() or equivalent to
|
|
775 iterate over all possible fonts, and a regexp match
|
|
776 on each one. So we cache the results. */
|
|
777 Lisp_Object matching_font = Qunbound;
|
872
|
778 Lisp_Object hash_table = Fgethash (charset, cache, Qunbound);
|
428
|
779 if (UNBOUNDP (hash_table))
|
|
780 {
|
|
781 /* need to make a sub hash table. */
|
|
782 hash_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK,
|
|
783 HASH_TABLE_EQUAL);
|
872
|
784 Fputhash (charset, hash_table, cache);
|
428
|
785 }
|
|
786 else
|
|
787 matching_font = Fgethash (instantiator, hash_table, Qunbound);
|
|
788
|
|
789 if (UNBOUNDP (matching_font))
|
|
790 {
|
|
791 /* make sure we cache the failures, too. */
|
|
792 matching_font =
|
|
793 DEVMETH_OR_GIVEN (d, find_charset_font,
|
872
|
794 (device, instantiator, charset, stage),
|
428
|
795 instantiator);
|
|
796 Fputhash (instantiator, matching_font, hash_table);
|
|
797 }
|
|
798 if (NILP (matching_font))
|
|
799 return Qunbound;
|
|
800 instantiator = matching_font;
|
|
801 }
|
|
802 #endif /* MULE */
|
|
803
|
|
804 /* First, look to see if we can retrieve a cached value. */
|
872
|
805 instance = Fgethash (instantiator, cache, Qunbound);
|
428
|
806 /* Otherwise, make a new one. */
|
|
807 if (UNBOUNDP (instance))
|
|
808 {
|
|
809 /* make sure we cache the failures, too. */
|
|
810 instance = Fmake_font_instance (instantiator, device, Qt);
|
872
|
811 Fputhash (instantiator, instance, cache);
|
428
|
812 }
|
|
813
|
|
814 return NILP (instance) ? Qunbound : instance;
|
|
815 }
|
|
816 else if (VECTORP (instantiator))
|
|
817 {
|
|
818 assert (XVECTOR_LENGTH (instantiator) == 1);
|
|
819 return (face_property_matching_instance
|
|
820 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
|
872
|
821 charset, domain, ERROR_ME, 0, depth));
|
428
|
822 }
|
|
823 else if (NILP (instantiator))
|
|
824 return Qunbound;
|
|
825 else
|
|
826 abort (); /* Eh? */
|
|
827
|
|
828 return Qunbound;
|
|
829 }
|
|
830
|
|
831 static void
|
|
832 font_validate (Lisp_Object instantiator)
|
|
833 {
|
|
834 if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator))
|
|
835 return;
|
|
836 if (VECTORP (instantiator))
|
|
837 {
|
|
838 if (XVECTOR_LENGTH (instantiator) != 1)
|
|
839 {
|
563
|
840 sferror
|
428
|
841 ("Vector length must be one for font inheritance", instantiator);
|
|
842 }
|
|
843 Fget_face (XVECTOR_DATA (instantiator)[0]);
|
|
844 }
|
|
845 else
|
563
|
846 invalid_argument ("Must be string, vector, or font-instance",
|
428
|
847 instantiator);
|
|
848 }
|
|
849
|
|
850 static void
|
|
851 font_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
852 {
|
|
853 Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier));
|
|
854 Lisp_Object property =
|
|
855 FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier));
|
|
856 if (!NILP (face))
|
448
|
857 {
|
|
858 face_property_was_changed (face, property, locale);
|
|
859 if (BUFFERP (locale))
|
|
860 XBUFFER (locale)->buffer_local_face_property = 1;
|
|
861 }
|
428
|
862 }
|
|
863
|
|
864 void
|
|
865 set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
|
|
866 {
|
440
|
867 Lisp_Specifier *font = XFONT_SPECIFIER (obj);
|
428
|
868
|
|
869 FONT_SPECIFIER_FACE (font) = face;
|
|
870 FONT_SPECIFIER_FACE_PROPERTY (font) = property;
|
|
871 }
|
|
872
|
|
873 DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /*
|
|
874 Return non-nil if OBJECT is a font specifier.
|
|
875
|
442
|
876 See `make-font-specifier' for a description of possible font instantiators.
|
428
|
877 */
|
|
878 (object))
|
|
879 {
|
|
880 return FONT_SPECIFIERP (object) ? Qt : Qnil;
|
|
881 }
|
|
882
|
|
883
|
|
884 /*****************************************************************************
|
|
885 Face Boolean Object
|
|
886 ****************************************************************************/
|
|
887 DEFINE_SPECIFIER_TYPE (face_boolean);
|
|
888 Lisp_Object Qface_boolean;
|
|
889
|
|
890 static void
|
|
891 face_boolean_create (Lisp_Object obj)
|
|
892 {
|
440
|
893 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
|
428
|
894
|
|
895 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil;
|
|
896 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil;
|
|
897 }
|
|
898
|
|
899 static void
|
|
900 face_boolean_mark (Lisp_Object obj)
|
|
901 {
|
440
|
902 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
|
428
|
903
|
|
904 mark_object (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean));
|
|
905 mark_object (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean));
|
|
906 }
|
|
907
|
|
908 /* No equal or hash methods; ignore the face the face-boolean is based off
|
|
909 of for `equal' */
|
|
910
|
|
911 static Lisp_Object
|
|
912 face_boolean_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
913 Lisp_Object domain, Lisp_Object instantiator,
|
|
914 Lisp_Object depth)
|
|
915 {
|
|
916 /* When called, we're inside of call_with_suspended_errors(),
|
|
917 so we can freely error. */
|
|
918 if (NILP (instantiator) || EQ (instantiator, Qt))
|
|
919 return instantiator;
|
|
920 else if (VECTORP (instantiator))
|
|
921 {
|
|
922 Lisp_Object retval;
|
|
923 Lisp_Object prop;
|
|
924 int instantiator_len = XVECTOR_LENGTH (instantiator);
|
|
925
|
|
926 assert (instantiator_len >= 1 && instantiator_len <= 3);
|
|
927 if (instantiator_len > 1)
|
|
928 prop = XVECTOR_DATA (instantiator)[1];
|
|
929 else
|
|
930 {
|
|
931 if (NILP (FACE_BOOLEAN_SPECIFIER_FACE
|
|
932 (XFACE_BOOLEAN_SPECIFIER (specifier))))
|
563
|
933 gui_error
|
428
|
934 ("Face-boolean specifier not attached to a face", instantiator);
|
|
935 prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY
|
|
936 (XFACE_BOOLEAN_SPECIFIER (specifier));
|
|
937 }
|
|
938
|
|
939 retval = (FACE_PROPERTY_INSTANCE_1
|
|
940 (Fget_face (XVECTOR_DATA (instantiator)[0]),
|
|
941 prop, domain, ERROR_ME, 0, depth));
|
|
942
|
|
943 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2]))
|
|
944 retval = NILP (retval) ? Qt : Qnil;
|
|
945
|
|
946 return retval;
|
|
947 }
|
|
948 else
|
|
949 abort (); /* Eh? */
|
|
950
|
|
951 return Qunbound;
|
|
952 }
|
|
953
|
|
954 static void
|
|
955 face_boolean_validate (Lisp_Object instantiator)
|
|
956 {
|
|
957 if (NILP (instantiator) || EQ (instantiator, Qt))
|
|
958 return;
|
|
959 else if (VECTORP (instantiator) &&
|
|
960 (XVECTOR_LENGTH (instantiator) >= 1 &&
|
|
961 XVECTOR_LENGTH (instantiator) <= 3))
|
|
962 {
|
|
963 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
|
|
964
|
|
965 Fget_face (face);
|
|
966
|
|
967 if (XVECTOR_LENGTH (instantiator) > 1)
|
|
968 {
|
|
969 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
|
|
970 if (!EQ (field, Qunderline)
|
|
971 && !EQ (field, Qstrikethru)
|
|
972 && !EQ (field, Qhighlight)
|
|
973 && !EQ (field, Qdim)
|
|
974 && !EQ (field, Qblinking)
|
|
975 && !EQ (field, Qreverse))
|
563
|
976 invalid_constant ("Invalid face-boolean inheritance field",
|
428
|
977 field);
|
|
978 }
|
|
979 }
|
|
980 else if (VECTORP (instantiator))
|
563
|
981 sferror ("Wrong length for face-boolean inheritance spec",
|
428
|
982 instantiator);
|
|
983 else
|
563
|
984 invalid_argument ("Face-boolean instantiator must be nil, t, or vector",
|
428
|
985 instantiator);
|
|
986 }
|
|
987
|
|
988 static void
|
|
989 face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
990 {
|
|
991 Lisp_Object face =
|
|
992 FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier));
|
|
993 Lisp_Object property =
|
|
994 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier));
|
|
995 if (!NILP (face))
|
448
|
996 {
|
|
997 face_property_was_changed (face, property, locale);
|
|
998 if (BUFFERP (locale))
|
|
999 XBUFFER (locale)->buffer_local_face_property = 1;
|
|
1000 }
|
428
|
1001 }
|
|
1002
|
|
1003 void
|
|
1004 set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face,
|
|
1005 Lisp_Object property)
|
|
1006 {
|
440
|
1007 Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
|
428
|
1008
|
|
1009 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face;
|
|
1010 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property;
|
|
1011 }
|
|
1012
|
|
1013 DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /*
|
|
1014 Return non-nil if OBJECT is a face-boolean specifier.
|
|
1015
|
442
|
1016 See `make-face-boolean-specifier' for a description of possible
|
|
1017 face-boolean instantiators.
|
428
|
1018 */
|
|
1019 (object))
|
|
1020 {
|
|
1021 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil;
|
|
1022 }
|
|
1023
|
|
1024
|
|
1025 /************************************************************************/
|
|
1026 /* initialization */
|
|
1027 /************************************************************************/
|
|
1028
|
|
1029 void
|
|
1030 syms_of_objects (void)
|
|
1031 {
|
442
|
1032 INIT_LRECORD_IMPLEMENTATION (color_instance);
|
|
1033 INIT_LRECORD_IMPLEMENTATION (font_instance);
|
|
1034
|
428
|
1035 DEFSUBR (Fcolor_specifier_p);
|
|
1036 DEFSUBR (Ffont_specifier_p);
|
|
1037 DEFSUBR (Fface_boolean_specifier_p);
|
|
1038
|
563
|
1039 DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep);
|
428
|
1040 DEFSUBR (Fmake_color_instance);
|
|
1041 DEFSUBR (Fcolor_instance_p);
|
|
1042 DEFSUBR (Fcolor_instance_name);
|
|
1043 DEFSUBR (Fcolor_instance_rgb_components);
|
|
1044 DEFSUBR (Fvalid_color_name_p);
|
|
1045
|
563
|
1046 DEFSYMBOL_MULTIWORD_PREDICATE (Qfont_instancep);
|
428
|
1047 DEFSUBR (Fmake_font_instance);
|
|
1048 DEFSUBR (Ffont_instance_p);
|
|
1049 DEFSUBR (Ffont_instance_name);
|
|
1050 DEFSUBR (Ffont_instance_ascent);
|
|
1051 DEFSUBR (Ffont_instance_descent);
|
|
1052 DEFSUBR (Ffont_instance_width);
|
|
1053 DEFSUBR (Ffont_instance_proportional_p);
|
|
1054 DEFSUBR (Ffont_instance_truename);
|
|
1055 DEFSUBR (Ffont_instance_properties);
|
|
1056 DEFSUBR (Flist_fonts);
|
|
1057
|
|
1058 /* Qcolor, Qfont defined in general.c */
|
563
|
1059 DEFSYMBOL (Qface_boolean);
|
428
|
1060 }
|
|
1061
|
|
1062 static const struct lrecord_description color_specifier_description[] = {
|
440
|
1063 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct color_specifier, face) },
|
|
1064 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct color_specifier, face_property) },
|
428
|
1065 { XD_END }
|
|
1066 };
|
|
1067
|
|
1068 static const struct lrecord_description font_specifier_description[] = {
|
440
|
1069 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct font_specifier, face) },
|
|
1070 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct font_specifier, face_property) },
|
428
|
1071 { XD_END }
|
|
1072 };
|
|
1073
|
|
1074 static const struct lrecord_description face_boolean_specifier_description[] = {
|
440
|
1075 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct face_boolean_specifier, face) },
|
|
1076 { XD_LISP_OBJECT, specifier_data_offset + offsetof (struct face_boolean_specifier, face_property) },
|
428
|
1077 { XD_END }
|
|
1078 };
|
|
1079
|
|
1080 void
|
|
1081 specifier_type_create_objects (void)
|
|
1082 {
|
|
1083 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p");
|
|
1084 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p");
|
|
1085 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean",
|
|
1086 "face-boolean-specifier-p");
|
|
1087
|
|
1088 SPECIFIER_HAS_METHOD (color, instantiate);
|
|
1089 SPECIFIER_HAS_METHOD (font, instantiate);
|
|
1090 SPECIFIER_HAS_METHOD (face_boolean, instantiate);
|
|
1091
|
|
1092 SPECIFIER_HAS_METHOD (color, validate);
|
|
1093 SPECIFIER_HAS_METHOD (font, validate);
|
|
1094 SPECIFIER_HAS_METHOD (face_boolean, validate);
|
|
1095
|
|
1096 SPECIFIER_HAS_METHOD (color, create);
|
|
1097 SPECIFIER_HAS_METHOD (font, create);
|
|
1098 SPECIFIER_HAS_METHOD (face_boolean, create);
|
|
1099
|
|
1100 SPECIFIER_HAS_METHOD (color, mark);
|
|
1101 SPECIFIER_HAS_METHOD (font, mark);
|
|
1102 SPECIFIER_HAS_METHOD (face_boolean, mark);
|
|
1103
|
|
1104 SPECIFIER_HAS_METHOD (color, after_change);
|
|
1105 SPECIFIER_HAS_METHOD (font, after_change);
|
|
1106 SPECIFIER_HAS_METHOD (face_boolean, after_change);
|
|
1107
|
|
1108 #ifdef MULE
|
|
1109 SPECIFIER_HAS_METHOD (font, validate_matchspec);
|
|
1110 #endif
|
|
1111 }
|
|
1112
|
|
1113 void
|
|
1114 reinit_specifier_type_create_objects (void)
|
|
1115 {
|
|
1116 REINITIALIZE_SPECIFIER_TYPE (color);
|
|
1117 REINITIALIZE_SPECIFIER_TYPE (font);
|
|
1118 REINITIALIZE_SPECIFIER_TYPE (face_boolean);
|
|
1119 }
|
|
1120
|
|
1121 void
|
|
1122 reinit_vars_of_objects (void)
|
|
1123 {
|
|
1124 staticpro_nodump (&Vthe_null_color_instance);
|
|
1125 {
|
440
|
1126 Lisp_Color_Instance *c =
|
|
1127 alloc_lcrecord_type (Lisp_Color_Instance, &lrecord_color_instance);
|
428
|
1128 c->name = Qnil;
|
|
1129 c->device = Qnil;
|
|
1130 c->data = 0;
|
|
1131
|
793
|
1132 Vthe_null_color_instance = wrap_color_instance (c);
|
428
|
1133 }
|
|
1134
|
|
1135 staticpro_nodump (&Vthe_null_font_instance);
|
|
1136 {
|
440
|
1137 Lisp_Font_Instance *f =
|
|
1138 alloc_lcrecord_type (Lisp_Font_Instance, &lrecord_font_instance);
|
428
|
1139 f->name = Qnil;
|
872
|
1140 f->truename = Qnil;
|
428
|
1141 f->device = Qnil;
|
|
1142 f->data = 0;
|
|
1143
|
|
1144 f->ascent = f->height = 0;
|
|
1145 f->descent = 0;
|
|
1146 f->width = 0;
|
|
1147 f->proportional_p = 0;
|
|
1148
|
793
|
1149 Vthe_null_font_instance = wrap_font_instance (f);
|
428
|
1150 }
|
|
1151 }
|
|
1152
|
|
1153 void
|
|
1154 vars_of_objects (void)
|
|
1155 {
|
|
1156 reinit_vars_of_objects ();
|
|
1157 }
|