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