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