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