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