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