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