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