0
|
1 /* Generic Objects and Functions.
|
|
2 Copyright (C) 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
4 Copyright (C) 1995, 1996 Ben Wing.
|
|
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
|
|
28 #include "device.h"
|
|
29 #include "elhash.h"
|
|
30 #include "faces.h"
|
|
31 #include "frame.h"
|
|
32 #include "objects.h"
|
|
33 #include "specifier.h"
|
|
34 #include "window.h"
|
|
35
|
|
36 /* Objects that are substituted when an instantiation fails.
|
|
37 If we leave in the Qunbound value, we will probably get crashes. */
|
|
38 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance;
|
|
39
|
|
40 /* Authors: Ben Wing, Chuck Thompson */
|
|
41
|
|
42 void
|
|
43 finalose (void *ptr)
|
|
44 {
|
173
|
45 Lisp_Object obj;
|
185
|
46 XSETOBJ (obj, Lisp_Type_Record, ptr);
|
0
|
47
|
|
48 signal_simple_error
|
|
49 ("Can't dump an emacs containing window system objects", obj);
|
|
50 }
|
|
51
|
|
52
|
|
53 /****************************************************************************
|
|
54 * Color-Instance Object *
|
|
55 ****************************************************************************/
|
|
56
|
|
57 Lisp_Object Qcolor_instancep;
|
|
58 static Lisp_Object mark_color_instance (Lisp_Object, void (*) (Lisp_Object));
|
|
59 static void print_color_instance (Lisp_Object, Lisp_Object, int);
|
|
60 static void finalize_color_instance (void *, int);
|
|
61 static int color_instance_equal (Lisp_Object, Lisp_Object, int depth);
|
|
62 static unsigned long color_instance_hash (Lisp_Object obj, int depth);
|
|
63 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
|
|
64 mark_color_instance, print_color_instance,
|
|
65 finalize_color_instance, color_instance_equal,
|
|
66 color_instance_hash,
|
|
67 struct Lisp_Color_Instance);
|
|
68
|
|
69 static Lisp_Object
|
|
70 mark_color_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
71 {
|
|
72 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
|
|
73 ((markobj) (c->name));
|
|
74 if (!NILP (c->device)) /* Vthe_null_color_instance */
|
|
75 MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c, markobj));
|
|
76
|
173
|
77 return c->device;
|
0
|
78 }
|
|
79
|
|
80 static void
|
|
81 print_color_instance (Lisp_Object obj, Lisp_Object printcharfun,
|
|
82 int escapeflag)
|
|
83 {
|
|
84 char buf[100];
|
|
85 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
|
|
86 if (print_readably)
|
|
87 error ("printing unreadable object #<color-instance 0x%x>",
|
|
88 c->header.uid);
|
|
89 write_c_string ("#<color-instance ", printcharfun);
|
|
90 print_internal (c->name, printcharfun, 0);
|
|
91 write_c_string (" on ", printcharfun);
|
|
92 print_internal (c->device, printcharfun, 0);
|
|
93 if (!NILP (c->device)) /* Vthe_null_color_instance */
|
|
94 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance,
|
|
95 (c, printcharfun, escapeflag));
|
|
96 sprintf (buf, " 0x%x>", c->header.uid);
|
|
97 write_c_string (buf, printcharfun);
|
|
98 }
|
|
99
|
|
100 static void
|
|
101 finalize_color_instance (void *header, int for_disksave)
|
|
102 {
|
|
103 struct Lisp_Color_Instance *c = (struct Lisp_Color_Instance *) header;
|
|
104
|
|
105 if (!NILP (c->device))
|
|
106 {
|
|
107 if (for_disksave) finalose (c);
|
|
108 MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c));
|
|
109 }
|
|
110 }
|
|
111
|
|
112 static int
|
|
113 color_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
|
|
114 {
|
|
115 struct Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (o1);
|
|
116 struct Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (o2);
|
|
117 struct device *d1 = DEVICEP (c1->device) ? XDEVICE (c1->device) : 0;
|
|
118 struct device *d2 = DEVICEP (c2->device) ? XDEVICE (c2->device) : 0;
|
|
119
|
|
120 if (d1 != d2)
|
|
121 return 0;
|
|
122 if (!d1 || !HAS_DEVMETH_P (d1, color_instance_equal))
|
|
123 return EQ (o1, o2);
|
|
124 return DEVMETH (d1, color_instance_equal, (c1, c2, depth));
|
|
125 }
|
|
126
|
|
127 static unsigned long
|
|
128 color_instance_hash (Lisp_Object obj, int depth)
|
|
129 {
|
|
130 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
|
|
131 struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0;
|
|
132
|
|
133 return HASH2 ((unsigned long) d,
|
|
134 !d ? LISP_HASH (obj)
|
|
135 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth),
|
|
136 LISP_HASH (obj)));
|
|
137 }
|
|
138
|
20
|
139 DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /*
|
0
|
140 Creates a new `color-instance' object of the specified color.
|
|
141 DEVICE specifies the device this object applies to and defaults to the
|
|
142 selected device. An error is signalled if the color is unknown or cannot
|
|
143 be allocated; however, if NOERROR is non-nil, nil is simply returned in
|
|
144 this case. (And if NOERROR is other than t, a warning may be issued.)
|
|
145
|
|
146 The returned object is a normal, first-class lisp object. The way you
|
|
147 `deallocate' the color is the way you deallocate any other lisp object:
|
|
148 you drop all pointers to it and allow it to be garbage collected. When
|
|
149 these objects are GCed, the underlying window-system data (e.g. X object)
|
|
150 is deallocated as well.
|
20
|
151 */
|
|
152 (name, device, no_error))
|
0
|
153 {
|
|
154 struct Lisp_Color_Instance *c;
|
|
155 Lisp_Object val;
|
|
156 int retval = 0;
|
|
157
|
|
158 CHECK_STRING (name);
|
|
159 XSETDEVICE (device, decode_device (device));
|
|
160
|
185
|
161 c = alloc_lcrecord_type (struct Lisp_Color_Instance, lrecord_color_instance);
|
0
|
162 c->name = name;
|
|
163 c->device = device;
|
|
164
|
|
165 c->data = 0;
|
|
166
|
|
167 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance,
|
|
168 (c, name, device,
|
|
169 decode_error_behavior_flag (no_error)));
|
|
170
|
|
171 if (!retval)
|
|
172 return Qnil;
|
|
173
|
|
174 XSETCOLOR_INSTANCE (val, c);
|
|
175 return val;
|
|
176 }
|
|
177
|
20
|
178 DEFUN ("color-instance-p", Fcolor_instance_p, 1, 1, 0, /*
|
0
|
179 Return non-nil if OBJECT is a color instance.
|
20
|
180 */
|
|
181 (object))
|
0
|
182 {
|
173
|
183 return COLOR_INSTANCEP (object) ? Qt : Qnil;
|
0
|
184 }
|
|
185
|
20
|
186 DEFUN ("color-instance-name", Fcolor_instance_name, 1, 1, 0, /*
|
0
|
187 Return the name used to allocate COLOR-INSTANCE.
|
20
|
188 */
|
|
189 (color_instance))
|
0
|
190 {
|
|
191 CHECK_COLOR_INSTANCE (color_instance);
|
173
|
192 return XCOLOR_INSTANCE (color_instance)->name;
|
0
|
193 }
|
|
194
|
20
|
195 DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components, 1, 1, 0, /*
|
0
|
196 Return a three element list containing the red, green, and blue
|
|
197 color components of COLOR-INSTANCE, or nil if unknown.
|
227
|
198 Component values range from 0-65535.
|
20
|
199 */
|
|
200 (color_instance))
|
0
|
201 {
|
|
202 struct Lisp_Color_Instance *c;
|
|
203
|
|
204 CHECK_COLOR_INSTANCE (color_instance);
|
|
205 c = XCOLOR_INSTANCE (color_instance);
|
|
206
|
|
207 if (NILP (c->device))
|
|
208 return Qnil;
|
|
209 else
|
|
210 return MAYBE_LISP_DEVMETH (XDEVICE (c->device),
|
|
211 color_instance_rgb_components,
|
|
212 (c));
|
|
213 }
|
|
214
|
20
|
215 DEFUN ("valid-color-name-p", Fvalid_color_name_p, 1, 2, 0, /*
|
0
|
216 Return true if COLOR names a valid color for the current device.
|
|
217
|
|
218 Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or
|
|
219 whatever the equivalent is on your system.
|
|
220
|
|
221 Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence.
|
|
222 In addition to being a color this may be one of a number of attributes
|
|
223 such as `blink'.
|
20
|
224 */
|
|
225 (color, device))
|
0
|
226 {
|
|
227 struct device *d = decode_device (device);
|
|
228
|
|
229 CHECK_STRING (color);
|
|
230 return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil;
|
|
231 }
|
|
232
|
|
233
|
|
234 /***************************************************************************
|
|
235 * Font-Instance Object *
|
|
236 ***************************************************************************/
|
|
237
|
|
238 Lisp_Object Qfont_instancep;
|
|
239 static Lisp_Object mark_font_instance (Lisp_Object, void (*) (Lisp_Object));
|
|
240 static void print_font_instance (Lisp_Object, Lisp_Object, int);
|
|
241 static void finalize_font_instance (void *, int);
|
|
242 static int font_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth);
|
|
243 static unsigned long font_instance_hash (Lisp_Object obj, int depth);
|
|
244 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
|
|
245 mark_font_instance, print_font_instance,
|
|
246 finalize_font_instance, font_instance_equal,
|
|
247 font_instance_hash, struct Lisp_Font_Instance);
|
|
248
|
|
249 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont,
|
|
250 Error_behavior errb);
|
|
251
|
|
252 static Lisp_Object
|
|
253 mark_font_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
254 {
|
|
255 struct Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
|
|
256
|
|
257 ((markobj) (f->name));
|
|
258 if (!NILP (f->device)) /* Vthe_null_font_instance */
|
|
259 MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f, markobj));
|
|
260
|
|
261 return f->device;
|
|
262 }
|
|
263
|
|
264 static void
|
|
265 print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
266 {
|
|
267 char buf[200];
|
|
268 struct Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
|
|
269 if (print_readably)
|
|
270 error ("printing unreadable object #<font-instance 0x%x>", f->header.uid);
|
|
271 write_c_string ("#<font-instance ", printcharfun);
|
|
272 print_internal (f->name, printcharfun, 1);
|
|
273 write_c_string (" on ", printcharfun);
|
|
274 print_internal (f->device, printcharfun, 0);
|
|
275 MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance,
|
|
276 (f, printcharfun, escapeflag));
|
|
277 sprintf (buf, " 0x%x>", f->header.uid);
|
|
278 write_c_string (buf, printcharfun);
|
|
279 }
|
|
280
|
|
281 static void
|
|
282 finalize_font_instance (void *header, int for_disksave)
|
|
283 {
|
|
284 struct Lisp_Font_Instance *f = (struct Lisp_Font_Instance *) header;
|
|
285
|
|
286 if (!NILP (f->device))
|
|
287 {
|
|
288 if (for_disksave) finalose (f);
|
|
289 MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f));
|
|
290 }
|
|
291 }
|
|
292
|
|
293 /* Fonts are equal if they resolve to the same name.
|
|
294 Since we call `font-truename' to do this, and since font-truename is lazy,
|
|
295 this means the `equal' could cause XListFonts to be run the first time.
|
|
296 */
|
|
297 static int
|
|
298 font_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
|
|
299 {
|
|
300 /* #### should this be moved into a device method? */
|
173
|
301 return internal_equal (font_instance_truename_internal (o1, ERROR_ME_NOT),
|
|
302 font_instance_truename_internal (o2, ERROR_ME_NOT),
|
|
303 depth + 1);
|
0
|
304 }
|
|
305
|
|
306 static unsigned long
|
|
307 font_instance_hash (Lisp_Object obj, int depth)
|
|
308 {
|
|
309 return internal_hash (font_instance_truename_internal (obj, ERROR_ME_NOT),
|
|
310 depth + 1);
|
|
311 }
|
|
312
|
20
|
313 DEFUN ("make-font-instance", Fmake_font_instance, 1, 3, 0, /*
|
0
|
314 Creates a new `font-instance' object of the specified name.
|
|
315 DEVICE specifies the device this object applies to and defaults to the
|
|
316 selected device. An error is signalled if the font is unknown or cannot
|
|
317 be allocated; however, if NOERROR is non-nil, nil is simply returned in
|
|
318 this case.
|
|
319
|
|
320 The returned object is a normal, first-class lisp object. The way you
|
|
321 `deallocate' the font is the way you deallocate any other lisp object:
|
|
322 you drop all pointers to it and allow it to be garbage collected. When
|
|
323 these objects are GCed, the underlying X data is deallocated as well.
|
20
|
324 */
|
|
325 (name, device, no_error))
|
0
|
326 {
|
|
327 struct Lisp_Font_Instance *f;
|
|
328 Lisp_Object val;
|
|
329 int retval = 0;
|
|
330 Error_behavior errb = decode_error_behavior_flag (no_error);
|
|
331
|
|
332 if (ERRB_EQ (errb, ERROR_ME))
|
|
333 CHECK_STRING (name);
|
|
334 else if (!STRINGP (name))
|
|
335 return Qnil;
|
|
336
|
|
337 XSETDEVICE (device, decode_device (device));
|
|
338
|
185
|
339 f = alloc_lcrecord_type (struct Lisp_Font_Instance, lrecord_font_instance);
|
0
|
340 f->name = name;
|
|
341 f->device = device;
|
|
342
|
|
343 f->data = 0;
|
|
344
|
|
345 /* Stick some default values here ... */
|
|
346 f->ascent = f->height = 1;
|
|
347 f->descent = 0;
|
|
348 f->width = 1;
|
|
349 f->proportional_p = 0;
|
173
|
350
|
0
|
351 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance,
|
|
352 (f, name, device, errb));
|
|
353
|
|
354 if (!retval)
|
|
355 return Qnil;
|
|
356
|
|
357 XSETFONT_INSTANCE (val, f);
|
|
358 return val;
|
|
359 }
|
|
360
|
20
|
361 DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /*
|
0
|
362 Return non-nil if OBJECT is a font instance.
|
20
|
363 */
|
|
364 (object))
|
0
|
365 {
|
173
|
366 return FONT_INSTANCEP (object) ? Qt : Qnil;
|
0
|
367 }
|
|
368
|
20
|
369 DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /*
|
0
|
370 Return the name used to allocate FONT-INSTANCE.
|
20
|
371 */
|
|
372 (font_instance))
|
0
|
373 {
|
|
374 CHECK_FONT_INSTANCE (font_instance);
|
173
|
375 return XFONT_INSTANCE (font_instance)->name;
|
0
|
376 }
|
|
377
|
20
|
378 DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /*
|
0
|
379 Return the ascent in pixels of FONT-INSTANCE.
|
|
380 The returned value is the maximum ascent for all characters in the font,
|
|
381 where a character's ascent is the number of pixels above (and including)
|
|
382 the baseline.
|
20
|
383 */
|
|
384 (font_instance))
|
0
|
385 {
|
|
386 CHECK_FONT_INSTANCE (font_instance);
|
|
387 return make_int (XFONT_INSTANCE (font_instance)->ascent);
|
|
388 }
|
|
389
|
20
|
390 DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /*
|
0
|
391 Return the descent in pixels of FONT-INSTANCE.
|
|
392 The returned value is the maximum descent for all characters in the font,
|
|
393 where a character's descent is the number of pixels below the baseline.
|
|
394 (Many characters to do not have any descent. Typical characters with a
|
|
395 descent are lowercase p and lowercase g.)
|
20
|
396 */
|
|
397 (font_instance))
|
0
|
398 {
|
|
399 CHECK_FONT_INSTANCE (font_instance);
|
|
400 return make_int (XFONT_INSTANCE (font_instance)->descent);
|
|
401 }
|
|
402
|
20
|
403 DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /*
|
0
|
404 Return the width in pixels of FONT-INSTANCE.
|
|
405 The returned value is the average width for all characters in the font.
|
20
|
406 */
|
|
407 (font_instance))
|
0
|
408 {
|
|
409 CHECK_FONT_INSTANCE (font_instance);
|
|
410 return make_int (XFONT_INSTANCE (font_instance)->width);
|
|
411 }
|
|
412
|
20
|
413 DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /*
|
0
|
414 Return whether FONT-INSTANCE is proportional.
|
|
415 This means that different characters in the font have different widths.
|
20
|
416 */
|
|
417 (font_instance))
|
0
|
418 {
|
|
419 CHECK_FONT_INSTANCE (font_instance);
|
173
|
420 return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil;
|
0
|
421 }
|
|
422
|
|
423 static Lisp_Object
|
|
424 font_instance_truename_internal (Lisp_Object font_instance,
|
|
425 Error_behavior errb)
|
|
426 {
|
|
427 struct Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance);
|
|
428 return DEVMETH_OR_GIVEN (XDEVICE (f->device), font_instance_truename,
|
|
429 (f, errb), f->name);
|
|
430 }
|
|
431
|
20
|
432 DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /*
|
0
|
433 Return the canonical name of FONT-INSTANCE.
|
|
434 Font names are patterns which may match any number of fonts, of which
|
|
435 the first found is used. This returns an unambiguous name for that font
|
|
436 (but not necessarily its only unambiguous name).
|
20
|
437 */
|
|
438 (font_instance))
|
0
|
439 {
|
|
440 CHECK_FONT_INSTANCE (font_instance);
|
|
441 return font_instance_truename_internal (font_instance, ERROR_ME);
|
|
442 }
|
|
443
|
20
|
444 DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /*
|
0
|
445 Return the properties (an alist or nil) of FONT-INSTANCE.
|
20
|
446 */
|
|
447 (font_instance))
|
0
|
448 {
|
|
449 struct Lisp_Font_Instance *f;
|
|
450
|
|
451 CHECK_FONT_INSTANCE (font_instance);
|
|
452 f = XFONT_INSTANCE (font_instance);
|
|
453
|
|
454 return MAYBE_LISP_DEVMETH (XDEVICE (f->device),
|
|
455 font_instance_properties, (f));
|
|
456 }
|
|
457
|
20
|
458 DEFUN ("list-fonts", Flist_fonts, 1, 2, 0, /*
|
0
|
459 Return a list of font names matching the given pattern.
|
|
460 DEVICE specifies which device to search for names, and defaults to the
|
|
461 currently selected device.
|
20
|
462 */
|
|
463 (pattern, device))
|
0
|
464 {
|
|
465 CHECK_STRING (pattern);
|
|
466 XSETDEVICE (device, decode_device (device));
|
|
467
|
|
468 return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device));
|
|
469 }
|
|
470
|
|
471
|
|
472 /****************************************************************************
|
|
473 Color Object
|
|
474 ***************************************************************************/
|
|
475 DEFINE_SPECIFIER_TYPE (color);
|
|
476 /* Qcolor defined in general.c */
|
|
477
|
|
478 static void
|
|
479 color_create (Lisp_Object obj)
|
|
480 {
|
|
481 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
|
|
482
|
|
483 COLOR_SPECIFIER_FACE (color) = Qnil;
|
|
484 COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil;
|
|
485 }
|
|
486
|
|
487 static void
|
|
488 color_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
489 {
|
|
490 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
|
|
491
|
|
492 ((markobj) (COLOR_SPECIFIER_FACE (color)));
|
|
493 ((markobj) (COLOR_SPECIFIER_FACE_PROPERTY (color)));
|
|
494 }
|
|
495
|
|
496 /* No equal or hash methods; ignore the face the color is based off
|
|
497 of for `equal' */
|
|
498
|
|
499 static Lisp_Object
|
|
500 color_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
501 Lisp_Object domain, Lisp_Object instantiator,
|
|
502 Lisp_Object depth)
|
|
503 {
|
|
504 /* When called, we're inside of call_with_suspended_errors(),
|
|
505 so we can freely error. */
|
|
506 Lisp_Object device = DFW_DEVICE (domain);
|
|
507 struct device *d = XDEVICE (device);
|
|
508 Lisp_Object instance;
|
|
509
|
|
510 if (COLOR_INSTANCEP (instantiator))
|
|
511 {
|
|
512 /* If we are on the same device then we're done. Otherwise change
|
|
513 the instantiator to the name used to generate the pixel and let the
|
|
514 STRINGP case deal with it. */
|
|
515 if (NILP (device) /* Vthe_null_color_instance */
|
|
516 || EQ (device, XCOLOR_INSTANCE (instantiator)->device))
|
|
517 return instantiator;
|
|
518 else
|
|
519 instantiator = Fcolor_instance_name (instantiator);
|
|
520 }
|
|
521
|
|
522 if (STRINGP (instantiator))
|
|
523 {
|
|
524 /* First, look to see if we can retrieve a cached value. */
|
|
525 instance = Fgethash (instantiator, d->color_instance_cache, Qunbound);
|
|
526 /* Otherwise, make a new one. */
|
|
527 if (UNBOUNDP (instance))
|
|
528 {
|
|
529 /* make sure we cache the failures, too. */
|
|
530 instance = Fmake_color_instance (instantiator, device, Qt);
|
|
531 Fputhash (instantiator, instance, d->color_instance_cache);
|
|
532 }
|
|
533
|
173
|
534 return NILP (instance) ? Qunbound : instance;
|
0
|
535 }
|
|
536 else if (VECTORP (instantiator))
|
|
537 {
|
173
|
538 switch (XVECTOR_LENGTH (instantiator))
|
0
|
539 {
|
|
540 case 0:
|
|
541 if (DEVICE_TTY_P (d))
|
|
542 return Vthe_null_color_instance;
|
|
543 else
|
|
544 signal_simple_error ("Color instantiator [] only valid on TTY's",
|
|
545 device);
|
|
546
|
|
547 case 1:
|
|
548 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier))))
|
|
549 signal_simple_error ("Color specifier not attached to a face",
|
|
550 instantiator);
|
|
551 return (FACE_PROPERTY_INSTANCE_1
|
173
|
552 (Fget_face (XVECTOR_DATA (instantiator)[0]),
|
|
553 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)),
|
|
554 domain, ERROR_ME, 0, depth));
|
0
|
555
|
|
556 case 2:
|
|
557 return (FACE_PROPERTY_INSTANCE_1
|
173
|
558 (Fget_face (XVECTOR_DATA (instantiator)[0]),
|
|
559 XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, 0, depth));
|
0
|
560
|
|
561 default:
|
|
562 abort ();
|
|
563 }
|
|
564 }
|
|
565 else if (NILP (instantiator))
|
|
566 {
|
|
567 if (DEVICE_TTY_P (d))
|
|
568 return Vthe_null_color_instance;
|
|
569 else
|
|
570 signal_simple_error ("Color instantiator [] only valid on TTY's",
|
|
571 device);
|
|
572 }
|
|
573 else
|
|
574 abort (); /* The spec validation routines are screwed up. */
|
|
575
|
|
576 return Qunbound;
|
|
577 }
|
|
578
|
|
579 static void
|
|
580 color_validate (Lisp_Object instantiator)
|
|
581 {
|
|
582 if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator))
|
|
583 return;
|
|
584 if (VECTORP (instantiator))
|
|
585 {
|
173
|
586 if (XVECTOR_LENGTH (instantiator) > 2)
|
0
|
587 signal_simple_error ("Inheritance vector must be of size 0 - 2",
|
|
588 instantiator);
|
173
|
589 else if (XVECTOR_LENGTH (instantiator) > 0)
|
0
|
590 {
|
173
|
591 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
|
|
592
|
0
|
593 Fget_face (face);
|
173
|
594 if (XVECTOR_LENGTH (instantiator) == 2)
|
0
|
595 {
|
173
|
596 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
|
0
|
597 if (!EQ (field, Qforeground) && !EQ (field, Qbackground))
|
|
598 signal_simple_error
|
|
599 ("Inheritance field must be `foreground' or `background'",
|
|
600 field);
|
|
601 }
|
|
602 }
|
|
603 }
|
|
604 else
|
|
605 signal_simple_error ("Invalid color instantiator", instantiator);
|
|
606 }
|
|
607
|
|
608 static void
|
|
609 color_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
610 {
|
|
611 Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier));
|
|
612 Lisp_Object property =
|
|
613 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier));
|
|
614 if (!NILP (face))
|
|
615 face_property_was_changed (face, property, locale);
|
|
616 }
|
|
617
|
|
618 void
|
|
619 set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
|
|
620 {
|
|
621 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
|
|
622
|
|
623 COLOR_SPECIFIER_FACE (color) = face;
|
|
624 COLOR_SPECIFIER_FACE_PROPERTY (color) = property;
|
|
625 }
|
|
626
|
20
|
627 DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /*
|
0
|
628 Return non-nil if OBJECT is a color specifier.
|
|
629
|
|
630 Valid instantiators for color specifiers are:
|
|
631
|
185
|
632 -- a string naming a color (e.g. under X this might be "lightseagreen2"
|
|
633 or "#F534B2")
|
0
|
634 -- a color instance (use that instance directly if the device matches,
|
|
635 or use the string that generated it)
|
|
636 -- a vector of no elements (only on TTY's; this means to set no color
|
185
|
637 at all, thus using the "natural" color of the terminal's text)
|
0
|
638 -- a vector of one or two elements: a face to inherit from, and
|
|
639 optionally a symbol naming which property of that face to inherit,
|
|
640 either `foreground' or `background' (if omitted, defaults to the same
|
|
641 property that this color specifier is used for; if this specifier is
|
|
642 not part of a face, the instantiator would not be valid)
|
20
|
643 */
|
|
644 (object))
|
0
|
645 {
|
173
|
646 return COLOR_SPECIFIERP (object) ? Qt : Qnil;
|
0
|
647 }
|
|
648
|
|
649
|
|
650 /****************************************************************************
|
|
651 Font Object
|
|
652 ***************************************************************************/
|
|
653 DEFINE_SPECIFIER_TYPE (font);
|
|
654 /* Qfont defined in general.c */
|
|
655
|
|
656 static void
|
|
657 font_create (Lisp_Object obj)
|
|
658 {
|
|
659 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
|
|
660
|
|
661 FONT_SPECIFIER_FACE (font) = Qnil;
|
|
662 FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil;
|
|
663 }
|
|
664
|
|
665 static void
|
|
666 font_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
667 {
|
|
668 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
|
|
669
|
|
670 ((markobj) (FONT_SPECIFIER_FACE (font)));
|
|
671 ((markobj) (FONT_SPECIFIER_FACE_PROPERTY (font)));
|
|
672 }
|
|
673
|
|
674 /* No equal or hash methods; ignore the face the font is based off
|
|
675 of for `equal' */
|
70
|
676
|
|
677 #ifdef MULE
|
|
678
|
|
679 int
|
|
680 font_spec_matches_charset (struct device *d, Lisp_Object charset,
|
|
681 CONST Bufbyte *nonreloc, Lisp_Object reloc,
|
|
682 Bytecount offset, Bytecount length)
|
|
683 {
|
|
684 return DEVMETH_OR_GIVEN (d, font_spec_matches_charset,
|
|
685 (d, charset, nonreloc, reloc, offset, length),
|
|
686 1);
|
|
687 }
|
|
688
|
|
689 static void
|
|
690 font_validate_matchspec (Lisp_Object matchspec)
|
|
691 {
|
|
692 Fget_charset (matchspec);
|
|
693 }
|
|
694
|
|
695 #endif /* MULE */
|
|
696
|
|
697
|
0
|
698 static Lisp_Object
|
|
699 font_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
700 Lisp_Object domain, Lisp_Object instantiator,
|
|
701 Lisp_Object depth)
|
|
702 {
|
|
703 /* When called, we're inside of call_with_suspended_errors(),
|
|
704 so we can freely error. */
|
|
705 Lisp_Object device = DFW_DEVICE (domain);
|
|
706 struct device *d = XDEVICE (device);
|
|
707 Lisp_Object instance;
|
|
708
|
70
|
709 #ifdef MULE
|
|
710 if (!UNBOUNDP (matchspec))
|
|
711 matchspec = Fget_charset (matchspec);
|
|
712 #endif
|
|
713
|
0
|
714 if (FONT_INSTANCEP (instantiator))
|
|
715 {
|
70
|
716 if (NILP (device)
|
0
|
717 || EQ (device, XFONT_INSTANCE (instantiator)->device))
|
|
718 {
|
70
|
719 #ifdef MULE
|
|
720 if (font_spec_matches_charset (d, matchspec, 0,
|
|
721 Ffont_instance_truename
|
|
722 (instantiator),
|
|
723 0, -1))
|
|
724 return instantiator;
|
|
725 #else
|
0
|
726 return instantiator;
|
70
|
727 #endif
|
0
|
728 }
|
|
729 instantiator = Ffont_instance_name (instantiator);
|
|
730 }
|
173
|
731
|
2
|
732 if (STRINGP (instantiator))
|
0
|
733 {
|
70
|
734 #ifdef MULE
|
|
735 if (!UNBOUNDP (matchspec))
|
|
736 {
|
|
737 /* The instantiator is a font spec that could match many
|
|
738 different fonts. We need to find one of those fonts
|
|
739 whose registry matches the registry of the charset in
|
|
740 MATCHSPEC. This is potentially a very slow operation,
|
|
741 as it involves doing an XListFonts() or equivalent to
|
|
742 iterate over all possible fonts, and a regexp match
|
|
743 on each one. So we cache the results. */
|
|
744 Lisp_Object matching_font = Qunbound;
|
|
745 Lisp_Object hashtab = Fgethash (matchspec, d->charset_font_cache,
|
|
746 Qunbound);
|
|
747 if (UNBOUNDP (hashtab))
|
|
748 {
|
|
749 /* need to make a sub hash table. */
|
|
750 hashtab = make_lisp_hashtable (20, HASHTABLE_KEY_WEAK,
|
|
751 HASHTABLE_EQUAL);
|
|
752 Fputhash (matchspec, hashtab, d->charset_font_cache);
|
|
753 }
|
|
754 else
|
|
755 matching_font = Fgethash (instantiator, hashtab, Qunbound);
|
|
756
|
|
757 if (UNBOUNDP (matching_font))
|
|
758 {
|
|
759 /* make sure we cache the failures, too. */
|
|
760 matching_font =
|
|
761 DEVMETH_OR_GIVEN (d, find_charset_font,
|
|
762 (device, instantiator, matchspec),
|
|
763 instantiator);
|
|
764 Fputhash (instantiator, matching_font, hashtab);
|
|
765 }
|
|
766 if (NILP (matching_font))
|
|
767 return Qunbound;
|
|
768 instantiator = matching_font;
|
|
769 }
|
|
770 #endif /* MULE */
|
|
771
|
0
|
772 /* First, look to see if we can retrieve a cached value. */
|
|
773 instance = Fgethash (instantiator, d->font_instance_cache, Qunbound);
|
|
774 /* Otherwise, make a new one. */
|
|
775 if (UNBOUNDP (instance))
|
|
776 {
|
|
777 /* make sure we cache the failures, too. */
|
|
778 instance = Fmake_font_instance (instantiator, device, Qt);
|
|
779 Fputhash (instantiator, instance, d->font_instance_cache);
|
|
780 }
|
|
781
|
173
|
782 return NILP (instance) ? Qunbound : instance;
|
0
|
783 }
|
|
784 else if (VECTORP (instantiator))
|
|
785 {
|
173
|
786 assert (XVECTOR_LENGTH (instantiator) == 1);
|
0
|
787 return (face_property_matching_instance
|
173
|
788 (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont,
|
0
|
789 matchspec, domain, ERROR_ME, 0, depth));
|
|
790 }
|
|
791 else if (NILP (instantiator))
|
|
792 return Qunbound;
|
|
793 else
|
|
794 abort (); /* Eh? */
|
|
795
|
|
796 return Qunbound;
|
|
797 }
|
|
798
|
|
799 static void
|
|
800 font_validate (Lisp_Object instantiator)
|
|
801 {
|
|
802 if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator))
|
|
803 return;
|
|
804 if (VECTORP (instantiator))
|
|
805 {
|
173
|
806 if (XVECTOR_LENGTH (instantiator) != 1)
|
0
|
807 {
|
|
808 signal_simple_error
|
|
809 ("Vector length must be one for font inheritance", instantiator);
|
|
810 }
|
173
|
811 Fget_face (XVECTOR_DATA (instantiator)[0]);
|
0
|
812 }
|
|
813 else
|
|
814 signal_simple_error ("Must be string, vector, or font-instance",
|
|
815 instantiator);
|
|
816 }
|
|
817
|
|
818 static void
|
|
819 font_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
820 {
|
|
821 Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier));
|
|
822 Lisp_Object property =
|
|
823 FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier));
|
|
824 if (!NILP (face))
|
|
825 face_property_was_changed (face, property, locale);
|
|
826 }
|
|
827
|
|
828 void
|
|
829 set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
|
|
830 {
|
|
831 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
|
|
832
|
|
833 FONT_SPECIFIER_FACE (font) = face;
|
|
834 FONT_SPECIFIER_FACE_PROPERTY (font) = property;
|
|
835 }
|
|
836
|
20
|
837 DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /*
|
0
|
838 Return non-nil if OBJECT is a font specifier.
|
|
839
|
|
840 Valid instantiators for font specifiers are:
|
|
841
|
|
842 -- a string naming a font (e.g. under X this might be
|
185
|
843 "-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*" for a 14-point
|
0
|
844 upright medium-weight Courier font)
|
|
845 -- a font instance (use that instance directly if the device matches,
|
|
846 or use the string that generated it)
|
|
847 -- a vector of no elements (only on TTY's; this means to set no font
|
185
|
848 at all, thus using the "natural" font of the terminal's text)
|
0
|
849 -- a vector of one element (a face to inherit from)
|
20
|
850 */
|
|
851 (object))
|
0
|
852 {
|
173
|
853 return FONT_SPECIFIERP (object) ? Qt : Qnil;
|
0
|
854 }
|
|
855
|
|
856
|
|
857 /*****************************************************************************
|
|
858 Face Boolean Object
|
|
859 ****************************************************************************/
|
|
860 DEFINE_SPECIFIER_TYPE (face_boolean);
|
|
861 Lisp_Object Qface_boolean;
|
|
862
|
|
863 static void
|
|
864 face_boolean_create (Lisp_Object obj)
|
|
865 {
|
|
866 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
|
|
867
|
|
868 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil;
|
|
869 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil;
|
|
870 }
|
|
871
|
|
872 static void
|
|
873 face_boolean_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
874 {
|
|
875 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
|
|
876
|
|
877 ((markobj) (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean)));
|
|
878 ((markobj) (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean)));
|
|
879 }
|
|
880
|
|
881 /* No equal or hash methods; ignore the face the face-boolean is based off
|
|
882 of for `equal' */
|
|
883
|
|
884 static Lisp_Object
|
|
885 face_boolean_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
|
|
886 Lisp_Object domain, Lisp_Object instantiator,
|
|
887 Lisp_Object depth)
|
|
888 {
|
|
889 /* When called, we're inside of call_with_suspended_errors(),
|
|
890 so we can freely error. */
|
|
891 if (NILP (instantiator) || EQ (instantiator, Qt))
|
|
892 return instantiator;
|
|
893 else if (VECTORP (instantiator))
|
|
894 {
|
|
895 Lisp_Object retval;
|
|
896 Lisp_Object prop;
|
173
|
897 int instantiator_len = XVECTOR_LENGTH (instantiator);
|
0
|
898
|
173
|
899 assert (instantiator_len >= 1 && instantiator_len <= 3);
|
|
900 if (instantiator_len > 1)
|
|
901 prop = XVECTOR_DATA (instantiator)[1];
|
0
|
902 else
|
|
903 {
|
|
904 if (NILP (FACE_BOOLEAN_SPECIFIER_FACE
|
|
905 (XFACE_BOOLEAN_SPECIFIER (specifier))))
|
|
906 signal_simple_error
|
|
907 ("Face-boolean specifier not attached to a face", instantiator);
|
|
908 prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY
|
|
909 (XFACE_BOOLEAN_SPECIFIER (specifier));
|
|
910 }
|
|
911
|
|
912 retval = (FACE_PROPERTY_INSTANCE_1
|
173
|
913 (Fget_face (XVECTOR_DATA (instantiator)[0]),
|
0
|
914 prop, domain, ERROR_ME, 0, depth));
|
|
915
|
173
|
916 if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2]))
|
|
917 retval = NILP (retval) ? Qt : Qnil;
|
0
|
918
|
|
919 return retval;
|
|
920 }
|
|
921 else
|
|
922 abort (); /* Eh? */
|
|
923
|
|
924 return Qunbound;
|
|
925 }
|
|
926
|
|
927 static void
|
|
928 face_boolean_validate (Lisp_Object instantiator)
|
|
929 {
|
|
930 if (NILP (instantiator) || EQ (instantiator, Qt))
|
|
931 return;
|
|
932 else if (VECTORP (instantiator) &&
|
173
|
933 (XVECTOR_LENGTH (instantiator) >= 1 &&
|
|
934 XVECTOR_LENGTH (instantiator) <= 3))
|
0
|
935 {
|
173
|
936 Lisp_Object face = XVECTOR_DATA (instantiator)[0];
|
|
937
|
0
|
938 Fget_face (face);
|
|
939
|
173
|
940 if (XVECTOR_LENGTH (instantiator) > 1)
|
0
|
941 {
|
173
|
942 Lisp_Object field = XVECTOR_DATA (instantiator)[1];
|
0
|
943 if (!EQ (field, Qunderline)
|
|
944 && !EQ (field, Qstrikethru)
|
|
945 && !EQ (field, Qhighlight)
|
|
946 && !EQ (field, Qdim)
|
|
947 && !EQ (field, Qblinking)
|
|
948 && !EQ (field, Qreverse))
|
|
949 signal_simple_error ("Invalid face-boolean inheritance field",
|
|
950 field);
|
|
951 }
|
|
952 }
|
|
953 else if (VECTORP (instantiator))
|
|
954 signal_simple_error ("Wrong length for face-boolean inheritance spec",
|
|
955 instantiator);
|
|
956 else
|
|
957 signal_simple_error ("Face-boolean instantiator must be nil, t, or vector",
|
|
958 instantiator);
|
|
959 }
|
|
960
|
|
961 static void
|
|
962 face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
963 {
|
|
964 Lisp_Object face =
|
|
965 FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier));
|
|
966 Lisp_Object property =
|
|
967 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier));
|
|
968 if (!NILP (face))
|
|
969 face_property_was_changed (face, property, locale);
|
|
970 }
|
|
971
|
|
972 void
|
|
973 set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face,
|
|
974 Lisp_Object property)
|
|
975 {
|
|
976 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
|
|
977
|
|
978 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face;
|
|
979 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property;
|
|
980 }
|
|
981
|
20
|
982 DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /*
|
0
|
983 Return non-nil if OBJECT is a face-boolean specifier.
|
|
984
|
|
985 Valid instantiators for face-boolean specifiers are
|
|
986
|
|
987 -- t or nil
|
|
988 -- a vector of two or three elements: a face to inherit from,
|
|
989 optionally a symbol naming the property of that face to inherit from
|
|
990 (if omitted, defaults to the same property that this face-boolean
|
|
991 specifier is used for; if this specifier is not part of a face,
|
|
992 the instantiator would not be valid), and optionally a value which,
|
|
993 if non-nil, means to invert the sense of the inherited property.
|
20
|
994 */
|
|
995 (object))
|
0
|
996 {
|
173
|
997 return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil;
|
0
|
998 }
|
|
999
|
|
1000
|
|
1001 /************************************************************************/
|
|
1002 /* initialization */
|
|
1003 /************************************************************************/
|
|
1004
|
|
1005 void
|
|
1006 syms_of_objects (void)
|
|
1007 {
|
20
|
1008 DEFSUBR (Fcolor_specifier_p);
|
|
1009 DEFSUBR (Ffont_specifier_p);
|
|
1010 DEFSUBR (Fface_boolean_specifier_p);
|
0
|
1011
|
|
1012 defsymbol (&Qcolor_instancep, "color-instance-p");
|
20
|
1013 DEFSUBR (Fmake_color_instance);
|
|
1014 DEFSUBR (Fcolor_instance_p);
|
|
1015 DEFSUBR (Fcolor_instance_name);
|
|
1016 DEFSUBR (Fcolor_instance_rgb_components);
|
|
1017 DEFSUBR (Fvalid_color_name_p);
|
0
|
1018
|
|
1019 defsymbol (&Qfont_instancep, "font-instance-p");
|
20
|
1020 DEFSUBR (Fmake_font_instance);
|
|
1021 DEFSUBR (Ffont_instance_p);
|
|
1022 DEFSUBR (Ffont_instance_name);
|
|
1023 DEFSUBR (Ffont_instance_ascent);
|
|
1024 DEFSUBR (Ffont_instance_descent);
|
|
1025 DEFSUBR (Ffont_instance_width);
|
|
1026 DEFSUBR (Ffont_instance_proportional_p);
|
|
1027 DEFSUBR (Ffont_instance_truename);
|
|
1028 DEFSUBR (Ffont_instance_properties);
|
|
1029 DEFSUBR (Flist_fonts);
|
0
|
1030
|
|
1031 /* Qcolor, Qfont defined in general.c */
|
|
1032 defsymbol (&Qface_boolean, "face-boolean");
|
|
1033 }
|
|
1034
|
|
1035 void
|
|
1036 specifier_type_create_objects (void)
|
|
1037 {
|
|
1038 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p");
|
|
1039 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p");
|
|
1040 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean",
|
|
1041 "face-boolean-specifier-p");
|
|
1042
|
|
1043 SPECIFIER_HAS_METHOD (color, instantiate);
|
|
1044 SPECIFIER_HAS_METHOD (font, instantiate);
|
|
1045 SPECIFIER_HAS_METHOD (face_boolean, instantiate);
|
|
1046
|
|
1047 SPECIFIER_HAS_METHOD (color, validate);
|
|
1048 SPECIFIER_HAS_METHOD (font, validate);
|
|
1049 SPECIFIER_HAS_METHOD (face_boolean, validate);
|
|
1050
|
|
1051 SPECIFIER_HAS_METHOD (color, create);
|
|
1052 SPECIFIER_HAS_METHOD (font, create);
|
|
1053 SPECIFIER_HAS_METHOD (face_boolean, create);
|
|
1054
|
|
1055 SPECIFIER_HAS_METHOD (color, mark);
|
|
1056 SPECIFIER_HAS_METHOD (font, mark);
|
|
1057 SPECIFIER_HAS_METHOD (face_boolean, mark);
|
|
1058
|
|
1059 SPECIFIER_HAS_METHOD (color, after_change);
|
|
1060 SPECIFIER_HAS_METHOD (font, after_change);
|
|
1061 SPECIFIER_HAS_METHOD (face_boolean, after_change);
|
70
|
1062
|
|
1063 #ifdef MULE
|
|
1064 SPECIFIER_HAS_METHOD (font, validate_matchspec);
|
|
1065 #endif
|
0
|
1066 }
|
|
1067
|
|
1068 void
|
|
1069 vars_of_objects (void)
|
|
1070 {
|
|
1071 staticpro (&Vthe_null_color_instance);
|
|
1072 {
|
185
|
1073 struct Lisp_Color_Instance *c =
|
|
1074 alloc_lcrecord_type (struct Lisp_Color_Instance, lrecord_color_instance);
|
0
|
1075 c->name = Qnil;
|
|
1076 c->device = Qnil;
|
|
1077 c->data = 0;
|
|
1078
|
|
1079 XSETCOLOR_INSTANCE (Vthe_null_color_instance, c);
|
|
1080 }
|
173
|
1081
|
0
|
1082 staticpro (&Vthe_null_font_instance);
|
|
1083 {
|
185
|
1084 struct Lisp_Font_Instance *f =
|
|
1085 alloc_lcrecord_type (struct Lisp_Font_Instance, lrecord_font_instance);
|
0
|
1086 f->name = Qnil;
|
|
1087 f->device = Qnil;
|
|
1088 f->data = 0;
|
|
1089
|
|
1090 f->ascent = f->height = 0;
|
|
1091 f->descent = 0;
|
|
1092 f->width = 0;
|
|
1093 f->proportional_p = 0;
|
173
|
1094
|
0
|
1095 XSETFONT_INSTANCE (Vthe_null_font_instance, f);
|
|
1096 }
|
|
1097 }
|