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