428
|
1 /* "Face" primitives
|
|
2 Copyright (C) 1994 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
793
|
4 Copyright (C) 1995, 1996, 2001, 2002 Ben Wing.
|
428
|
5 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
6
|
|
7 This file is part of XEmacs.
|
|
8
|
|
9 XEmacs is free software; you can redistribute it and/or modify it
|
|
10 under the terms of the GNU General Public License as published by the
|
|
11 Free Software Foundation; either version 2, or (at your option) any
|
|
12 later version.
|
|
13
|
|
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
17 for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with XEmacs; see the file COPYING. If not, write to
|
|
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 Boston, MA 02111-1307, USA. */
|
|
23
|
|
24 /* Synched up with: Not in FSF. */
|
|
25
|
|
26 /* Written by Chuck Thompson and Ben Wing,
|
|
27 based loosely on old face code by Jamie Zawinski. */
|
|
28
|
|
29 #include <config.h>
|
|
30 #include "lisp.h"
|
|
31
|
|
32 #include "buffer.h"
|
|
33 #include "device.h"
|
|
34 #include "elhash.h"
|
|
35 #include "extents.h"
|
|
36 #include "faces.h"
|
|
37 #include "frame.h"
|
|
38 #include "glyphs.h"
|
|
39 #include "objects.h"
|
|
40 #include "specifier.h"
|
|
41 #include "window.h"
|
|
42
|
|
43 Lisp_Object Qfacep;
|
|
44 Lisp_Object Qforeground, Qbackground, Qdisplay_table;
|
|
45 Lisp_Object Qbackground_pixmap, Qunderline, Qdim;
|
|
46 Lisp_Object Qblinking, Qstrikethru;
|
|
47
|
|
48 Lisp_Object Qinit_face_from_resources;
|
|
49 Lisp_Object Qinit_frame_faces;
|
|
50 Lisp_Object Qinit_device_faces;
|
|
51 Lisp_Object Qinit_global_faces;
|
|
52
|
|
53 /* These faces are used directly internally. We use these variables
|
|
54 to be able to reference them directly and save the overhead of
|
|
55 calling Ffind_face. */
|
|
56 Lisp_Object Vdefault_face, Vmodeline_face, Vgui_element_face;
|
|
57 Lisp_Object Vleft_margin_face, Vright_margin_face, Vtext_cursor_face;
|
|
58 Lisp_Object Vpointer_face, Vvertical_divider_face, Vtoolbar_face, Vwidget_face;
|
|
59
|
440
|
60 /* Qdefault, Qhighlight, Qleft_margin, Qright_margin defined in general.c */
|
|
61 Lisp_Object Qmodeline, Qgui_element, Qtext_cursor, Qvertical_divider;
|
428
|
62
|
|
63 /* In the old implementation Vface_list was a list of the face names,
|
|
64 not the faces themselves. We now distinguish between permanent and
|
|
65 temporary faces. Permanent faces are kept in a regular hash table,
|
|
66 temporary faces in a weak hash table. */
|
|
67 Lisp_Object Vpermanent_faces_cache;
|
|
68 Lisp_Object Vtemporary_faces_cache;
|
|
69
|
|
70 Lisp_Object Vbuilt_in_face_specifiers;
|
|
71
|
|
72
|
|
73
|
|
74 static Lisp_Object
|
|
75 mark_face (Lisp_Object obj)
|
|
76 {
|
440
|
77 Lisp_Face *face = XFACE (obj);
|
428
|
78
|
|
79 mark_object (face->name);
|
|
80 mark_object (face->doc_string);
|
|
81
|
|
82 mark_object (face->foreground);
|
|
83 mark_object (face->background);
|
|
84 mark_object (face->font);
|
|
85 mark_object (face->display_table);
|
|
86 mark_object (face->background_pixmap);
|
|
87 mark_object (face->underline);
|
|
88 mark_object (face->strikethru);
|
|
89 mark_object (face->highlight);
|
|
90 mark_object (face->dim);
|
|
91 mark_object (face->blinking);
|
|
92 mark_object (face->reverse);
|
|
93
|
|
94 mark_object (face->charsets_warned_about);
|
|
95
|
|
96 return face->plist;
|
|
97 }
|
|
98
|
|
99 static void
|
|
100 print_face (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
101 {
|
440
|
102 Lisp_Face *face = XFACE (obj);
|
428
|
103
|
|
104 if (print_readably)
|
|
105 {
|
|
106 write_c_string ("#s(face name ", printcharfun);
|
|
107 print_internal (face->name, printcharfun, 1);
|
|
108 write_c_string (")", printcharfun);
|
|
109 }
|
|
110 else
|
|
111 {
|
|
112 write_c_string ("#<face ", printcharfun);
|
|
113 print_internal (face->name, printcharfun, 1);
|
|
114 if (!NILP (face->doc_string))
|
|
115 {
|
|
116 write_c_string (" ", printcharfun);
|
|
117 print_internal (face->doc_string, printcharfun, 1);
|
|
118 }
|
|
119 write_c_string (">", printcharfun);
|
|
120 }
|
|
121 }
|
|
122
|
|
123 /* Faces are equal if all of their display attributes are equal. We
|
|
124 don't compare names or doc-strings, because that would make equal
|
|
125 be eq.
|
|
126
|
|
127 This isn't concerned with "unspecified" attributes, that's what
|
|
128 #'face-differs-from-default-p is for. */
|
|
129 static int
|
|
130 face_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
|
|
131 {
|
440
|
132 Lisp_Face *f1 = XFACE (obj1);
|
|
133 Lisp_Face *f2 = XFACE (obj2);
|
428
|
134
|
|
135 depth++;
|
|
136
|
|
137 return
|
|
138 (internal_equal (f1->foreground, f2->foreground, depth) &&
|
|
139 internal_equal (f1->background, f2->background, depth) &&
|
|
140 internal_equal (f1->font, f2->font, depth) &&
|
|
141 internal_equal (f1->display_table, f2->display_table, depth) &&
|
|
142 internal_equal (f1->background_pixmap, f2->background_pixmap, depth) &&
|
|
143 internal_equal (f1->underline, f2->underline, depth) &&
|
|
144 internal_equal (f1->strikethru, f2->strikethru, depth) &&
|
|
145 internal_equal (f1->highlight, f2->highlight, depth) &&
|
|
146 internal_equal (f1->dim, f2->dim, depth) &&
|
|
147 internal_equal (f1->blinking, f2->blinking, depth) &&
|
|
148 internal_equal (f1->reverse, f2->reverse, depth) &&
|
|
149
|
|
150 ! plists_differ (f1->plist, f2->plist, 0, 0, depth + 1));
|
|
151 }
|
|
152
|
665
|
153 static Hashcode
|
428
|
154 face_hash (Lisp_Object obj, int depth)
|
|
155 {
|
440
|
156 Lisp_Face *f = XFACE (obj);
|
428
|
157
|
|
158 depth++;
|
|
159
|
|
160 /* No need to hash all of the elements; that would take too long.
|
|
161 Just hash the most common ones. */
|
|
162 return HASH3 (internal_hash (f->foreground, depth),
|
|
163 internal_hash (f->background, depth),
|
|
164 internal_hash (f->font, depth));
|
|
165 }
|
|
166
|
|
167 static Lisp_Object
|
|
168 face_getprop (Lisp_Object obj, Lisp_Object prop)
|
|
169 {
|
440
|
170 Lisp_Face *f = XFACE (obj);
|
428
|
171
|
|
172 return
|
|
173 (EQ (prop, Qforeground) ? f->foreground :
|
|
174 EQ (prop, Qbackground) ? f->background :
|
|
175 EQ (prop, Qfont) ? f->font :
|
|
176 EQ (prop, Qdisplay_table) ? f->display_table :
|
|
177 EQ (prop, Qbackground_pixmap) ? f->background_pixmap :
|
|
178 EQ (prop, Qunderline) ? f->underline :
|
|
179 EQ (prop, Qstrikethru) ? f->strikethru :
|
|
180 EQ (prop, Qhighlight) ? f->highlight :
|
|
181 EQ (prop, Qdim) ? f->dim :
|
|
182 EQ (prop, Qblinking) ? f->blinking :
|
|
183 EQ (prop, Qreverse) ? f->reverse :
|
|
184 EQ (prop, Qdoc_string) ? f->doc_string :
|
|
185 external_plist_get (&f->plist, prop, 0, ERROR_ME));
|
|
186 }
|
|
187
|
|
188 static int
|
|
189 face_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value)
|
|
190 {
|
440
|
191 Lisp_Face *f = XFACE (obj);
|
428
|
192
|
|
193 if (EQ (prop, Qforeground) ||
|
|
194 EQ (prop, Qbackground) ||
|
|
195 EQ (prop, Qfont) ||
|
|
196 EQ (prop, Qdisplay_table) ||
|
|
197 EQ (prop, Qbackground_pixmap) ||
|
|
198 EQ (prop, Qunderline) ||
|
|
199 EQ (prop, Qstrikethru) ||
|
|
200 EQ (prop, Qhighlight) ||
|
|
201 EQ (prop, Qdim) ||
|
|
202 EQ (prop, Qblinking) ||
|
|
203 EQ (prop, Qreverse))
|
|
204 return 0;
|
|
205
|
|
206 if (EQ (prop, Qdoc_string))
|
|
207 {
|
|
208 if (!NILP (value))
|
|
209 CHECK_STRING (value);
|
|
210 f->doc_string = value;
|
|
211 return 1;
|
|
212 }
|
|
213
|
|
214 external_plist_put (&f->plist, prop, value, 0, ERROR_ME);
|
|
215 return 1;
|
|
216 }
|
|
217
|
|
218 static int
|
|
219 face_remprop (Lisp_Object obj, Lisp_Object prop)
|
|
220 {
|
440
|
221 Lisp_Face *f = XFACE (obj);
|
428
|
222
|
|
223 if (EQ (prop, Qforeground) ||
|
|
224 EQ (prop, Qbackground) ||
|
|
225 EQ (prop, Qfont) ||
|
|
226 EQ (prop, Qdisplay_table) ||
|
|
227 EQ (prop, Qbackground_pixmap) ||
|
|
228 EQ (prop, Qunderline) ||
|
|
229 EQ (prop, Qstrikethru) ||
|
|
230 EQ (prop, Qhighlight) ||
|
|
231 EQ (prop, Qdim) ||
|
|
232 EQ (prop, Qblinking) ||
|
|
233 EQ (prop, Qreverse))
|
|
234 return -1;
|
|
235
|
|
236 if (EQ (prop, Qdoc_string))
|
|
237 {
|
|
238 f->doc_string = Qnil;
|
|
239 return 1;
|
|
240 }
|
|
241
|
|
242 return external_remprop (&f->plist, prop, 0, ERROR_ME);
|
|
243 }
|
|
244
|
|
245 static Lisp_Object
|
|
246 face_plist (Lisp_Object obj)
|
|
247 {
|
440
|
248 Lisp_Face *face = XFACE (obj);
|
428
|
249 Lisp_Object result = face->plist;
|
|
250
|
|
251 result = cons3 (Qreverse, face->reverse, result);
|
|
252 result = cons3 (Qblinking, face->blinking, result);
|
|
253 result = cons3 (Qdim, face->dim, result);
|
|
254 result = cons3 (Qhighlight, face->highlight, result);
|
|
255 result = cons3 (Qstrikethru, face->strikethru, result);
|
|
256 result = cons3 (Qunderline, face->underline, result);
|
|
257 result = cons3 (Qbackground_pixmap, face->background_pixmap, result);
|
|
258 result = cons3 (Qdisplay_table, face->display_table, result);
|
|
259 result = cons3 (Qfont, face->font, result);
|
|
260 result = cons3 (Qbackground, face->background, result);
|
|
261 result = cons3 (Qforeground, face->foreground, result);
|
|
262
|
|
263 return result;
|
|
264 }
|
|
265
|
|
266 static const struct lrecord_description face_description[] = {
|
440
|
267 { XD_LISP_OBJECT, offsetof (Lisp_Face, name) },
|
|
268 { XD_LISP_OBJECT, offsetof (Lisp_Face, doc_string) },
|
|
269 { XD_LISP_OBJECT, offsetof (Lisp_Face, foreground) },
|
|
270 { XD_LISP_OBJECT, offsetof (Lisp_Face, background) },
|
|
271 { XD_LISP_OBJECT, offsetof (Lisp_Face, font) },
|
|
272 { XD_LISP_OBJECT, offsetof (Lisp_Face, display_table) },
|
|
273 { XD_LISP_OBJECT, offsetof (Lisp_Face, background_pixmap) },
|
|
274 { XD_LISP_OBJECT, offsetof (Lisp_Face, underline) },
|
|
275 { XD_LISP_OBJECT, offsetof (Lisp_Face, strikethru) },
|
|
276 { XD_LISP_OBJECT, offsetof (Lisp_Face, highlight) },
|
|
277 { XD_LISP_OBJECT, offsetof (Lisp_Face, dim) },
|
|
278 { XD_LISP_OBJECT, offsetof (Lisp_Face, blinking) },
|
|
279 { XD_LISP_OBJECT, offsetof (Lisp_Face, reverse) },
|
|
280 { XD_LISP_OBJECT, offsetof (Lisp_Face, plist) },
|
|
281 { XD_LISP_OBJECT, offsetof (Lisp_Face, charsets_warned_about) },
|
428
|
282 { XD_END }
|
|
283 };
|
|
284
|
|
285 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS ("face", face,
|
|
286 mark_face, print_face, 0, face_equal,
|
|
287 face_hash, face_description, face_getprop,
|
|
288 face_putprop, face_remprop,
|
440
|
289 face_plist, Lisp_Face);
|
428
|
290
|
|
291 /************************************************************************/
|
|
292 /* face read syntax */
|
|
293 /************************************************************************/
|
|
294
|
|
295 static int
|
|
296 face_name_validate (Lisp_Object keyword, Lisp_Object value,
|
578
|
297 Error_Behavior errb)
|
428
|
298 {
|
|
299 if (ERRB_EQ (errb, ERROR_ME))
|
|
300 {
|
|
301 CHECK_SYMBOL (value);
|
|
302 return 1;
|
|
303 }
|
|
304
|
|
305 return SYMBOLP (value);
|
|
306 }
|
|
307
|
|
308 static int
|
578
|
309 face_validate (Lisp_Object data, Error_Behavior errb)
|
428
|
310 {
|
|
311 int name_seen = 0;
|
|
312 Lisp_Object valw = Qnil;
|
|
313
|
|
314 data = Fcdr (data); /* skip over Qface */
|
|
315 while (!NILP (data))
|
|
316 {
|
|
317 Lisp_Object keyw = Fcar (data);
|
|
318
|
|
319 data = Fcdr (data);
|
|
320 valw = Fcar (data);
|
|
321 data = Fcdr (data);
|
|
322 if (EQ (keyw, Qname))
|
|
323 name_seen = 1;
|
|
324 else
|
|
325 abort ();
|
|
326 }
|
|
327
|
|
328 if (!name_seen)
|
|
329 {
|
563
|
330 maybe_sferror ("No face name given", Qunbound, Qface, errb);
|
428
|
331 return 0;
|
|
332 }
|
|
333
|
|
334 if (NILP (Ffind_face (valw)))
|
|
335 {
|
563
|
336 maybe_invalid_argument ("No such face", valw, Qface, errb);
|
428
|
337 return 0;
|
|
338 }
|
|
339
|
|
340 return 1;
|
|
341 }
|
|
342
|
|
343 static Lisp_Object
|
|
344 face_instantiate (Lisp_Object data)
|
|
345 {
|
|
346 return Fget_face (Fcar (Fcdr (data)));
|
|
347 }
|
|
348
|
|
349
|
|
350 /****************************************************************************
|
|
351 * utility functions *
|
|
352 ****************************************************************************/
|
|
353
|
|
354 static void
|
440
|
355 reset_face (Lisp_Face *f)
|
428
|
356 {
|
|
357 f->name = Qnil;
|
|
358 f->doc_string = Qnil;
|
|
359 f->dirty = 0;
|
|
360 f->foreground = Qnil;
|
|
361 f->background = Qnil;
|
|
362 f->font = Qnil;
|
|
363 f->display_table = Qnil;
|
|
364 f->background_pixmap = Qnil;
|
|
365 f->underline = Qnil;
|
|
366 f->strikethru = Qnil;
|
|
367 f->highlight = Qnil;
|
|
368 f->dim = Qnil;
|
|
369 f->blinking = Qnil;
|
|
370 f->reverse = Qnil;
|
|
371 f->plist = Qnil;
|
|
372 f->charsets_warned_about = Qnil;
|
|
373 }
|
|
374
|
440
|
375 static Lisp_Face *
|
428
|
376 allocate_face (void)
|
|
377 {
|
440
|
378 Lisp_Face *result = alloc_lcrecord_type (Lisp_Face, &lrecord_face);
|
428
|
379
|
|
380 reset_face (result);
|
|
381 return result;
|
|
382 }
|
|
383
|
|
384
|
|
385 /* We store the faces in hash tables with the names as the key and the
|
|
386 actual face object as the value. Occasionally we need to use them
|
|
387 in a list format. These routines provide us with that. */
|
|
388 struct face_list_closure
|
|
389 {
|
|
390 Lisp_Object *face_list;
|
|
391 };
|
|
392
|
|
393 static int
|
|
394 add_face_to_list_mapper (Lisp_Object key, Lisp_Object value,
|
|
395 void *face_list_closure)
|
|
396 {
|
|
397 /* This function can GC */
|
|
398 struct face_list_closure *fcl =
|
|
399 (struct face_list_closure *) face_list_closure;
|
|
400
|
|
401 *(fcl->face_list) = Fcons (XFACE (value)->name, (*fcl->face_list));
|
|
402 return 0;
|
|
403 }
|
|
404
|
|
405 static Lisp_Object
|
|
406 faces_list_internal (Lisp_Object list)
|
|
407 {
|
|
408 Lisp_Object face_list = Qnil;
|
|
409 struct gcpro gcpro1;
|
|
410 struct face_list_closure face_list_closure;
|
|
411
|
|
412 GCPRO1 (face_list);
|
|
413 face_list_closure.face_list = &face_list;
|
|
414 elisp_maphash (add_face_to_list_mapper, list, &face_list_closure);
|
|
415 UNGCPRO;
|
|
416
|
|
417 return face_list;
|
|
418 }
|
|
419
|
|
420 static Lisp_Object
|
|
421 permanent_faces_list (void)
|
|
422 {
|
|
423 return faces_list_internal (Vpermanent_faces_cache);
|
|
424 }
|
|
425
|
|
426 static Lisp_Object
|
|
427 temporary_faces_list (void)
|
|
428 {
|
|
429 return faces_list_internal (Vtemporary_faces_cache);
|
|
430 }
|
|
431
|
|
432
|
|
433 static int
|
|
434 mark_face_as_clean_mapper (Lisp_Object key, Lisp_Object value,
|
|
435 void *flag_closure)
|
|
436 {
|
|
437 /* This function can GC */
|
|
438 int *flag = (int *) flag_closure;
|
|
439 XFACE (value)->dirty = *flag;
|
|
440 return 0;
|
|
441 }
|
|
442
|
|
443 static void
|
|
444 mark_all_faces_internal (int flag)
|
|
445 {
|
|
446 elisp_maphash (mark_face_as_clean_mapper, Vpermanent_faces_cache, &flag);
|
|
447 elisp_maphash (mark_face_as_clean_mapper, Vtemporary_faces_cache, &flag);
|
|
448 }
|
|
449
|
|
450 void
|
|
451 mark_all_faces_as_clean (void)
|
|
452 {
|
|
453 mark_all_faces_internal (0);
|
|
454 }
|
|
455
|
|
456 /* Currently unused (see the comment in face_property_was_changed()). */
|
|
457 #if 0
|
|
458 /* #### OBSOLETE ME, PLEASE. Maybe. Maybe this is just as good as
|
|
459 any other solution. */
|
|
460 struct face_inheritance_closure
|
|
461 {
|
|
462 Lisp_Object face;
|
|
463 Lisp_Object property;
|
|
464 };
|
|
465
|
|
466 static void
|
|
467 update_inheritance_mapper_internal (Lisp_Object cur_face,
|
|
468 Lisp_Object inh_face,
|
|
469 Lisp_Object property)
|
|
470 {
|
|
471 /* #### fix this function */
|
|
472 Lisp_Object elt = Qnil;
|
|
473 struct gcpro gcpro1;
|
|
474
|
|
475 GCPRO1 (elt);
|
|
476
|
|
477 for (elt = FACE_PROPERTY_SPEC_LIST (cur_face, property, Qall);
|
|
478 !NILP (elt);
|
|
479 elt = XCDR (elt))
|
|
480 {
|
|
481 Lisp_Object values = XCDR (XCAR (elt));
|
|
482
|
|
483 for (; !NILP (values); values = XCDR (values))
|
|
484 {
|
|
485 Lisp_Object value = XCDR (XCAR (values));
|
|
486 if (VECTORP (value) && XVECTOR_LENGTH (value))
|
|
487 {
|
|
488 if (EQ (Ffind_face (XVECTOR_DATA (value)[0]), inh_face))
|
|
489 Fset_specifier_dirty_flag
|
|
490 (FACE_PROPERTY_SPECIFIER (inh_face, property));
|
|
491 }
|
|
492 }
|
|
493 }
|
|
494
|
|
495 UNGCPRO;
|
|
496 }
|
|
497
|
|
498 static int
|
442
|
499 update_face_inheritance_mapper (const void *hash_key, void *hash_contents,
|
428
|
500 void *face_inheritance_closure)
|
|
501 {
|
|
502 Lisp_Object key, contents;
|
|
503 struct face_inheritance_closure *fcl =
|
|
504 (struct face_inheritance_closure *) face_inheritance_closure;
|
|
505
|
|
506 CVOID_TO_LISP (key, hash_key);
|
|
507 VOID_TO_LISP (contents, hash_contents);
|
|
508
|
|
509 if (EQ (fcl->property, Qfont))
|
|
510 {
|
|
511 update_inheritance_mapper_internal (contents, fcl->face, Qfont);
|
|
512 }
|
|
513 else if (EQ (fcl->property, Qforeground) ||
|
|
514 EQ (fcl->property, Qbackground))
|
|
515 {
|
|
516 update_inheritance_mapper_internal (contents, fcl->face, Qforeground);
|
|
517 update_inheritance_mapper_internal (contents, fcl->face, Qbackground);
|
|
518 }
|
|
519 else if (EQ (fcl->property, Qunderline) ||
|
|
520 EQ (fcl->property, Qstrikethru) ||
|
|
521 EQ (fcl->property, Qhighlight) ||
|
|
522 EQ (fcl->property, Qdim) ||
|
|
523 EQ (fcl->property, Qblinking) ||
|
|
524 EQ (fcl->property, Qreverse))
|
|
525 {
|
|
526 update_inheritance_mapper_internal (contents, fcl->face, Qunderline);
|
|
527 update_inheritance_mapper_internal (contents, fcl->face, Qstrikethru);
|
|
528 update_inheritance_mapper_internal (contents, fcl->face, Qhighlight);
|
|
529 update_inheritance_mapper_internal (contents, fcl->face, Qdim);
|
|
530 update_inheritance_mapper_internal (contents, fcl->face, Qblinking);
|
|
531 update_inheritance_mapper_internal (contents, fcl->face, Qreverse);
|
|
532 }
|
|
533 return 0;
|
|
534 }
|
|
535
|
|
536 static void
|
|
537 update_faces_inheritance (Lisp_Object face, Lisp_Object property)
|
|
538 {
|
|
539 struct face_inheritance_closure face_inheritance_closure;
|
|
540 struct gcpro gcpro1, gcpro2;
|
|
541
|
|
542 GCPRO2 (face, property);
|
|
543 face_inheritance_closure.face = face;
|
|
544 face_inheritance_closure.property = property;
|
|
545
|
|
546 elisp_maphash (update_face_inheritance_mapper, Vpermanent_faces_cache,
|
|
547 &face_inheritance_closure);
|
|
548 elisp_maphash (update_face_inheritance_mapper, Vtemporary_faces_cache,
|
|
549 &face_inheritance_closure);
|
|
550
|
|
551 UNGCPRO;
|
|
552 }
|
|
553 #endif /* 0 */
|
|
554
|
|
555 Lisp_Object
|
|
556 face_property_matching_instance (Lisp_Object face, Lisp_Object property,
|
|
557 Lisp_Object charset, Lisp_Object domain,
|
578
|
558 Error_Behavior errb, int no_fallback,
|
428
|
559 Lisp_Object depth)
|
|
560 {
|
771
|
561 Lisp_Object retval;
|
|
562
|
|
563 retval = specifier_instance_no_quit (Fget (face, property, Qnil), charset,
|
|
564 domain, errb, no_fallback, depth);
|
428
|
565
|
|
566 if (UNBOUNDP (retval) && !no_fallback)
|
|
567 {
|
|
568 if (EQ (property, Qfont))
|
|
569 {
|
|
570 if (NILP (memq_no_quit (charset,
|
|
571 XFACE (face)->charsets_warned_about)))
|
|
572 {
|
|
573 #ifdef MULE
|
793
|
574 if (!UNBOUNDP (charset))
|
428
|
575 warn_when_safe
|
793
|
576 (Qfont, Qnotice,
|
|
577 "Unable to instantiate font for charset %s, face %s",
|
|
578 XSTRING_DATA (symbol_name
|
|
579 (XSYMBOL (XCHARSET_NAME (charset)))),
|
|
580 XSTRING_DATA (symbol_name
|
|
581 (XSYMBOL (XFACE (face)->name))));
|
428
|
582 else
|
|
583 #endif
|
793
|
584 warn_when_safe (Qfont, Qnotice,
|
428
|
585 "Unable to instantiate font for face %s",
|
793
|
586 XSTRING_DATA (symbol_name
|
428
|
587 (XSYMBOL (XFACE (face)->name))));
|
|
588 XFACE (face)->charsets_warned_about =
|
|
589 Fcons (charset, XFACE (face)->charsets_warned_about);
|
|
590 }
|
|
591 retval = Vthe_null_font_instance;
|
|
592 }
|
|
593 }
|
|
594
|
|
595 return retval;
|
|
596 }
|
|
597
|
|
598
|
|
599 DEFUN ("facep", Ffacep, 1, 1, 0, /*
|
444
|
600 Return t if OBJECT is a face.
|
428
|
601 */
|
|
602 (object))
|
|
603 {
|
|
604 return FACEP (object) ? Qt : Qnil;
|
|
605 }
|
|
606
|
|
607 DEFUN ("find-face", Ffind_face, 1, 1, 0, /*
|
|
608 Retrieve the face of the given name.
|
|
609 If FACE-OR-NAME is a face object, it is simply returned.
|
|
610 Otherwise, FACE-OR-NAME should be a symbol. If there is no such face,
|
|
611 nil is returned. Otherwise the associated face object is returned.
|
|
612 */
|
|
613 (face_or_name))
|
|
614 {
|
|
615 Lisp_Object retval;
|
|
616
|
|
617 if (FACEP (face_or_name))
|
|
618 return face_or_name;
|
|
619 CHECK_SYMBOL (face_or_name);
|
|
620
|
|
621 /* Check if the name represents a permanent face. */
|
|
622 retval = Fgethash (face_or_name, Vpermanent_faces_cache, Qnil);
|
|
623 if (!NILP (retval))
|
|
624 return retval;
|
|
625
|
|
626 /* Check if the name represents a temporary face. */
|
|
627 return Fgethash (face_or_name, Vtemporary_faces_cache, Qnil);
|
|
628 }
|
|
629
|
|
630 DEFUN ("get-face", Fget_face, 1, 1, 0, /*
|
|
631 Retrieve the face of the given name.
|
|
632 Same as `find-face' except an error is signalled if there is no such
|
|
633 face instead of returning nil.
|
|
634 */
|
|
635 (name))
|
|
636 {
|
|
637 Lisp_Object face = Ffind_face (name);
|
|
638
|
|
639 if (NILP (face))
|
563
|
640 invalid_argument ("No such face", name);
|
428
|
641 return face;
|
|
642 }
|
|
643
|
|
644 DEFUN ("face-name", Fface_name, 1, 1, 0, /*
|
|
645 Return the name of the given face.
|
|
646 */
|
|
647 (face))
|
|
648 {
|
|
649 return XFACE (Fget_face (face))->name;
|
|
650 }
|
|
651
|
|
652 DEFUN ("built-in-face-specifiers", Fbuilt_in_face_specifiers, 0, 0, 0, /*
|
|
653 Return a list of all built-in face specifier properties.
|
|
654 Don't modify this list!
|
|
655 */
|
|
656 ())
|
|
657 {
|
|
658 return Vbuilt_in_face_specifiers;
|
|
659 }
|
|
660
|
|
661 /* These values are retrieved so often that we make a special
|
|
662 function.
|
|
663 */
|
|
664
|
|
665 void
|
|
666 default_face_font_info (Lisp_Object domain, int *ascent, int *descent,
|
|
667 int *height, int *width, int *proportional_p)
|
|
668 {
|
|
669 Lisp_Object font_instance;
|
|
670
|
|
671 if (noninteractive)
|
|
672 {
|
|
673 if (ascent)
|
|
674 *ascent = 1;
|
|
675 if (descent)
|
|
676 *descent = 0;
|
|
677 if (height)
|
|
678 *height = 1;
|
|
679 if (width)
|
|
680 *width = 1;
|
|
681 if (proportional_p)
|
|
682 *proportional_p = 0;
|
|
683 return;
|
|
684 }
|
|
685
|
|
686 /* We use ASCII here. This is probably reasonable because the
|
|
687 people calling this function are using the resulting values to
|
|
688 come up with overall sizes for windows and frames. */
|
|
689 if (WINDOWP (domain))
|
|
690 {
|
|
691 struct face_cachel *cachel;
|
|
692 struct window *w = XWINDOW (domain);
|
|
693
|
|
694 /* #### It's possible for this function to get called when the
|
|
695 face cachels have not been initialized. I don't know why. */
|
|
696 if (!Dynarr_length (w->face_cachels))
|
|
697 reset_face_cachels (w);
|
|
698 cachel = WINDOW_FACE_CACHEL (w, DEFAULT_INDEX);
|
|
699 font_instance = FACE_CACHEL_FONT (cachel, Vcharset_ascii);
|
|
700 }
|
|
701 else
|
|
702 {
|
|
703 font_instance = FACE_FONT (Vdefault_face, domain, Vcharset_ascii);
|
|
704 }
|
|
705
|
|
706 if (height)
|
|
707 *height = XFONT_INSTANCE (font_instance)->height;
|
|
708 if (width)
|
|
709 *width = XFONT_INSTANCE (font_instance)->width;
|
|
710 if (ascent)
|
|
711 *ascent = XFONT_INSTANCE (font_instance)->ascent;
|
|
712 if (descent)
|
|
713 *descent = XFONT_INSTANCE (font_instance)->descent;
|
|
714 if (proportional_p)
|
|
715 *proportional_p = XFONT_INSTANCE (font_instance)->proportional_p;
|
|
716 }
|
|
717
|
|
718 void
|
|
719 default_face_height_and_width (Lisp_Object domain,
|
|
720 int *height, int *width)
|
|
721 {
|
|
722 default_face_font_info (domain, 0, 0, height, width, 0);
|
|
723 }
|
|
724
|
|
725 void
|
|
726 default_face_height_and_width_1 (Lisp_Object domain,
|
|
727 int *height, int *width)
|
|
728 {
|
|
729 if (window_system_pixelated_geometry (domain))
|
|
730 {
|
|
731 if (height)
|
|
732 *height = 1;
|
|
733 if (width)
|
|
734 *width = 1;
|
|
735 }
|
|
736 else
|
|
737 default_face_height_and_width (domain, height, width);
|
|
738 }
|
|
739
|
|
740 DEFUN ("face-list", Fface_list, 0, 1, 0, /*
|
|
741 Return a list of the names of all defined faces.
|
|
742 If TEMPORARY is nil, only the permanent faces are included.
|
|
743 If it is t, only the temporary faces are included. If it is any
|
|
744 other non-nil value both permanent and temporary are included.
|
|
745 */
|
|
746 (temporary))
|
|
747 {
|
|
748 Lisp_Object face_list = Qnil;
|
|
749
|
|
750 /* Added the permanent faces, if requested. */
|
|
751 if (NILP (temporary) || !EQ (Qt, temporary))
|
|
752 face_list = permanent_faces_list ();
|
|
753
|
|
754 if (!NILP (temporary))
|
|
755 {
|
|
756 struct gcpro gcpro1;
|
|
757 GCPRO1 (face_list);
|
|
758 face_list = nconc2 (face_list, temporary_faces_list ());
|
|
759 UNGCPRO;
|
|
760 }
|
|
761
|
|
762 return face_list;
|
|
763 }
|
|
764
|
|
765 DEFUN ("make-face", Fmake_face, 1, 3, 0, /*
|
444
|
766 Define a new face with name NAME (a symbol), described by DOC-STRING.
|
|
767 You can modify the font, color, etc. of a face with the set-face-* functions.
|
428
|
768 If the face already exists, it is unmodified.
|
|
769 If TEMPORARY is non-nil, this face will cease to exist if not in use.
|
|
770 */
|
|
771 (name, doc_string, temporary))
|
|
772 {
|
|
773 /* This function can GC if initialized is non-zero */
|
440
|
774 Lisp_Face *f;
|
428
|
775 Lisp_Object face;
|
|
776
|
|
777 CHECK_SYMBOL (name);
|
|
778 if (!NILP (doc_string))
|
|
779 CHECK_STRING (doc_string);
|
|
780
|
|
781 face = Ffind_face (name);
|
|
782 if (!NILP (face))
|
|
783 return face;
|
|
784
|
|
785 f = allocate_face ();
|
793
|
786 face = wrap_face (f);
|
428
|
787
|
|
788 f->name = name;
|
|
789 f->doc_string = doc_string;
|
|
790 f->foreground = Fmake_specifier (Qcolor);
|
|
791 set_color_attached_to (f->foreground, face, Qforeground);
|
|
792 f->background = Fmake_specifier (Qcolor);
|
|
793 set_color_attached_to (f->background, face, Qbackground);
|
|
794 f->font = Fmake_specifier (Qfont);
|
|
795 set_font_attached_to (f->font, face, Qfont);
|
|
796 f->background_pixmap = Fmake_specifier (Qimage);
|
|
797 set_image_attached_to (f->background_pixmap, face, Qbackground_pixmap);
|
|
798 f->display_table = Fmake_specifier (Qdisplay_table);
|
|
799 f->underline = Fmake_specifier (Qface_boolean);
|
|
800 set_face_boolean_attached_to (f->underline, face, Qunderline);
|
|
801 f->strikethru = Fmake_specifier (Qface_boolean);
|
|
802 set_face_boolean_attached_to (f->strikethru, face, Qstrikethru);
|
|
803 f->highlight = Fmake_specifier (Qface_boolean);
|
|
804 set_face_boolean_attached_to (f->highlight, face, Qhighlight);
|
|
805 f->dim = Fmake_specifier (Qface_boolean);
|
|
806 set_face_boolean_attached_to (f->dim, face, Qdim);
|
|
807 f->blinking = Fmake_specifier (Qface_boolean);
|
|
808 set_face_boolean_attached_to (f->blinking, face, Qblinking);
|
|
809 f->reverse = Fmake_specifier (Qface_boolean);
|
|
810 set_face_boolean_attached_to (f->reverse, face, Qreverse);
|
|
811 if (!NILP (Vdefault_face))
|
|
812 {
|
|
813 /* If the default face has already been created, set it as
|
|
814 the default fallback specifier for all the specifiers we
|
|
815 just created. This implements the standard "all faces
|
|
816 inherit from default" behavior. */
|
|
817 set_specifier_fallback (f->foreground,
|
|
818 Fget (Vdefault_face, Qforeground, Qunbound));
|
|
819 set_specifier_fallback (f->background,
|
|
820 Fget (Vdefault_face, Qbackground, Qunbound));
|
|
821 set_specifier_fallback (f->font,
|
|
822 Fget (Vdefault_face, Qfont, Qunbound));
|
|
823 set_specifier_fallback (f->background_pixmap,
|
|
824 Fget (Vdefault_face, Qbackground_pixmap,
|
|
825 Qunbound));
|
|
826 set_specifier_fallback (f->display_table,
|
|
827 Fget (Vdefault_face, Qdisplay_table, Qunbound));
|
|
828 set_specifier_fallback (f->underline,
|
|
829 Fget (Vdefault_face, Qunderline, Qunbound));
|
|
830 set_specifier_fallback (f->strikethru,
|
|
831 Fget (Vdefault_face, Qstrikethru, Qunbound));
|
|
832 set_specifier_fallback (f->highlight,
|
|
833 Fget (Vdefault_face, Qhighlight, Qunbound));
|
|
834 set_specifier_fallback (f->dim,
|
|
835 Fget (Vdefault_face, Qdim, Qunbound));
|
|
836 set_specifier_fallback (f->blinking,
|
|
837 Fget (Vdefault_face, Qblinking, Qunbound));
|
|
838 set_specifier_fallback (f->reverse,
|
|
839 Fget (Vdefault_face, Qreverse, Qunbound));
|
|
840 }
|
|
841
|
|
842 /* Add the face to the appropriate list. */
|
|
843 if (NILP (temporary))
|
|
844 Fputhash (name, face, Vpermanent_faces_cache);
|
|
845 else
|
|
846 Fputhash (name, face, Vtemporary_faces_cache);
|
|
847
|
|
848 /* Note that it's OK if we dump faces.
|
|
849 When we start up again when we're not noninteractive,
|
|
850 `init-global-faces' is called and it resources all
|
|
851 existing faces. */
|
|
852 if (initialized && !noninteractive)
|
|
853 {
|
|
854 struct gcpro gcpro1, gcpro2;
|
|
855
|
|
856 GCPRO2 (name, face);
|
|
857 call1 (Qinit_face_from_resources, name);
|
|
858 UNGCPRO;
|
|
859 }
|
|
860
|
|
861 return face;
|
|
862 }
|
|
863
|
|
864
|
|
865 /*****************************************************************************
|
|
866 initialization code
|
|
867 ****************************************************************************/
|
|
868
|
|
869 void
|
|
870 init_global_faces (struct device *d)
|
|
871 {
|
|
872 /* When making the initial terminal device, there is no Lisp code
|
|
873 loaded, so we can't do this. */
|
|
874 if (initialized && !noninteractive)
|
|
875 {
|
|
876 call_critical_lisp_code (d, Qinit_global_faces, Qnil);
|
|
877 }
|
|
878 }
|
|
879
|
|
880 void
|
|
881 init_device_faces (struct device *d)
|
|
882 {
|
|
883 /* This function can call lisp */
|
|
884
|
|
885 /* When making the initial terminal device, there is no Lisp code
|
|
886 loaded, so we can't do this. */
|
|
887 if (initialized)
|
|
888 {
|
793
|
889 Lisp_Object tdevice = wrap_device (d);
|
|
890
|
428
|
891 call_critical_lisp_code (d, Qinit_device_faces, tdevice);
|
|
892 }
|
|
893 }
|
|
894
|
|
895 void
|
|
896 init_frame_faces (struct frame *frm)
|
|
897 {
|
|
898 /* When making the initial terminal device, there is no Lisp code
|
|
899 loaded, so we can't do this. */
|
|
900 if (initialized)
|
|
901 {
|
793
|
902 Lisp_Object tframe = wrap_frame (frm);
|
|
903
|
428
|
904
|
|
905 /* DO NOT change the selected frame here. If the debugger goes off
|
|
906 it will try and display on the frame being created, but it is not
|
|
907 ready for that yet and a horrible death will occur. Any random
|
|
908 code depending on the selected-frame as an implicit arg should be
|
|
909 tracked down and shot. For the benefit of the one known,
|
|
910 xpm-color-symbols, make-frame sets the variable
|
|
911 Vframe_being_created to the frame it is making and sets it to nil
|
|
912 when done. Internal functions that this could trigger which are
|
|
913 currently depending on selected-frame should use this instead. It
|
|
914 is not currently visible at the lisp level. */
|
|
915 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (frm)),
|
|
916 Qinit_frame_faces, tframe);
|
|
917 }
|
|
918 }
|
|
919
|
|
920
|
|
921 /****************************************************************************
|
|
922 * face cache element functions *
|
|
923 ****************************************************************************/
|
|
924
|
|
925 /*
|
|
926
|
|
927 #### Here is a description of how the face cache elements ought
|
|
928 to be redone. It is *NOT* how they work currently:
|
|
929
|
|
930 However, when I started to go about implementing this, I realized
|
|
931 that there are all sorts of subtle problems with cache coherency
|
|
932 that are coming up. As it turns out, these problems don't
|
|
933 manifest themselves now due to the brute-force "kill 'em all"
|
|
934 approach to cache invalidation when faces change; but if this
|
|
935 is ever made smarter, these problems are going to come up, and
|
|
936 some of them are very non-obvious.
|
|
937
|
|
938 I'm thinking of redoing the cache code a bit to avoid these
|
|
939 coherency problems. The bulk of the problems will arise because
|
|
940 the current display structures have simple indices into the
|
|
941 face cache, but the cache can be changed at various times,
|
|
942 which could make the current display structures incorrect.
|
|
943 I guess the dirty and updated flags are an attempt to fix
|
|
944 this, but this approach doesn't really work.
|
|
945
|
|
946 Here's an approach that should keep things clean and unconfused:
|
|
947
|
|
948 1) Imagine a "virtual face cache" that can grow arbitrarily
|
|
949 big and for which the only thing allowed is to add new
|
|
950 elements. Existing elements cannot be removed or changed.
|
|
951 This way, any pointers in the existing redisplay structure
|
|
952 into the cache never get screwed up. (This is important
|
|
953 because even if a cache element is out of date, if there's
|
|
954 a pointer to it then its contents still accurately describe
|
|
955 the way the text currently looks on the screen.)
|
|
956 2) Each element in the virtual cache either describes exactly
|
|
957 one face, or describes the merger of a number of faces
|
|
958 by some process. In order to simplify things, for mergers
|
|
959 we do not record which faces or ordering was used, but
|
|
960 simply that this cache element is the result of merging.
|
|
961 Unlike the current implementation, it's important that a
|
|
962 single cache element not be used to both describe a
|
|
963 single face and describe a merger, even if all the property
|
|
964 values are the same.
|
|
965 3) Each cache element can be clean or dirty. "Dirty" means
|
|
966 that the face that the element points to has been changed;
|
|
967 this gets set at the time the face is changed. This
|
|
968 way, when looking up a value in the cache, you can determine
|
|
969 whether it's out of date or not. For merged faces it
|
|
970 does not matter -- we don't record the faces or priority
|
|
971 used to create the merger, so it's impossible to look up
|
|
972 one of these faces. We have to recompute it each time.
|
|
973 Luckily, this is fine -- doing the merge is much
|
|
974 less expensive than recomputing the properties of a
|
|
975 single face.
|
|
976 4) For each cache element, we keep a hash value. (In order
|
|
977 to hash the boolean properties, we convert each of them
|
|
978 into a different large prime number so that the hashing works
|
|
979 well.) This allows us, when comparing runes, to properly
|
|
980 determine whether the face for that rune has changed.
|
|
981 This will be especially important for TTY's, where there
|
|
982 aren't that many faces and minimizing redraw is very
|
|
983 important.
|
|
984 5) We can't actually keep an infinite cache, but that doesn't
|
|
985 really matter that much. The only elements we care about
|
|
986 are those that are used by either the current or desired
|
|
987 display structs. Therefore, we keep a per-window
|
|
988 redisplay iteration number, and mark each element with
|
|
989 that number as we use it. Just after outputting the
|
|
990 window and synching the redisplay structs, we go through
|
|
991 the cache and invalidate all elements that are not clean
|
|
992 elements referring to a particular face and that do not
|
|
993 have an iteration number equal to the current one. We
|
|
994 keep them in a chain, and use them to allocate new
|
|
995 elements when possible instead of increasing the Dynarr.
|
|
996
|
|
997 */
|
|
998
|
|
999 /* mark for GC a dynarr of face cachels. */
|
|
1000
|
|
1001 void
|
|
1002 mark_face_cachels (face_cachel_dynarr *elements)
|
|
1003 {
|
|
1004 int elt;
|
|
1005
|
|
1006 if (!elements)
|
|
1007 return;
|
|
1008
|
|
1009 for (elt = 0; elt < Dynarr_length (elements); elt++)
|
|
1010 {
|
|
1011 struct face_cachel *cachel = Dynarr_atp (elements, elt);
|
|
1012
|
|
1013 {
|
|
1014 int i;
|
|
1015
|
|
1016 for (i = 0; i < NUM_LEADING_BYTES; i++)
|
|
1017 if (!NILP (cachel->font[i]) && !UNBOUNDP (cachel->font[i]))
|
|
1018 mark_object (cachel->font[i]);
|
|
1019 }
|
|
1020 mark_object (cachel->face);
|
|
1021 mark_object (cachel->foreground);
|
|
1022 mark_object (cachel->background);
|
|
1023 mark_object (cachel->display_table);
|
|
1024 mark_object (cachel->background_pixmap);
|
|
1025 }
|
|
1026 }
|
|
1027
|
|
1028 /* ensure that the given cachel contains an updated font value for
|
|
1029 the given charset. Return the updated font value. */
|
|
1030
|
|
1031 Lisp_Object
|
|
1032 ensure_face_cachel_contains_charset (struct face_cachel *cachel,
|
|
1033 Lisp_Object domain, Lisp_Object charset)
|
|
1034 {
|
|
1035 Lisp_Object new_val;
|
|
1036 Lisp_Object face = cachel->face;
|
|
1037 int bound = 1;
|
|
1038 int offs = XCHARSET_LEADING_BYTE (charset) - MIN_LEADING_BYTE;
|
|
1039
|
|
1040 if (!UNBOUNDP (cachel->font[offs])
|
|
1041 && cachel->font_updated[offs])
|
|
1042 return cachel->font[offs];
|
|
1043
|
|
1044 if (UNBOUNDP (face))
|
|
1045 {
|
|
1046 /* a merged face. */
|
|
1047 int i;
|
|
1048 struct window *w = XWINDOW (domain);
|
|
1049
|
|
1050 new_val = Qunbound;
|
|
1051 cachel->font_specified[offs] = 0;
|
|
1052 for (i = 0; i < cachel->nfaces; i++)
|
|
1053 {
|
|
1054 struct face_cachel *oth;
|
|
1055
|
|
1056 oth = Dynarr_atp (w->face_cachels,
|
|
1057 FACE_CACHEL_FINDEX_UNSAFE (cachel, i));
|
|
1058 /* Tout le monde aime la recursion */
|
|
1059 ensure_face_cachel_contains_charset (oth, domain, charset);
|
|
1060
|
|
1061 if (oth->font_specified[offs])
|
|
1062 {
|
|
1063 new_val = oth->font[offs];
|
|
1064 cachel->font_specified[offs] = 1;
|
|
1065 break;
|
|
1066 }
|
|
1067 }
|
|
1068
|
|
1069 if (!cachel->font_specified[offs])
|
|
1070 /* need to do the default face. */
|
|
1071 {
|
|
1072 struct face_cachel *oth =
|
|
1073 Dynarr_atp (w->face_cachels, DEFAULT_INDEX);
|
|
1074 ensure_face_cachel_contains_charset (oth, domain, charset);
|
|
1075
|
|
1076 new_val = oth->font[offs];
|
|
1077 }
|
|
1078
|
|
1079 if (!UNBOUNDP (cachel->font[offs]) && !EQ (cachel->font[offs], new_val))
|
|
1080 cachel->dirty = 1;
|
|
1081 cachel->font_updated[offs] = 1;
|
|
1082 cachel->font[offs] = new_val;
|
|
1083 return new_val;
|
|
1084 }
|
|
1085
|
|
1086 new_val = face_property_matching_instance (face, Qfont, charset, domain,
|
793
|
1087 /* #### look into error flag */
|
|
1088 ERROR_ME_DEBUG_WARN, 1, Qzero);
|
428
|
1089 if (UNBOUNDP (new_val))
|
|
1090 {
|
|
1091 bound = 0;
|
|
1092 new_val = face_property_matching_instance (face, Qfont,
|
|
1093 charset, domain,
|
793
|
1094 /* #### look into error
|
|
1095 flag */
|
|
1096 ERROR_ME_DEBUG_WARN, 0,
|
|
1097 Qzero);
|
428
|
1098 }
|
|
1099 if (!UNBOUNDP (cachel->font[offs]) && !EQ (new_val, cachel->font[offs]))
|
|
1100 cachel->dirty = 1;
|
|
1101 cachel->font_updated[offs] = 1;
|
|
1102 cachel->font[offs] = new_val;
|
|
1103 cachel->font_specified[offs] = (bound || EQ (face, Vdefault_face));
|
|
1104 return new_val;
|
|
1105 }
|
|
1106
|
|
1107 /* Ensure that the given cachel contains updated fonts for all
|
|
1108 the charsets specified. */
|
|
1109
|
|
1110 void
|
|
1111 ensure_face_cachel_complete (struct face_cachel *cachel,
|
|
1112 Lisp_Object domain, unsigned char *charsets)
|
|
1113 {
|
|
1114 int i;
|
|
1115
|
|
1116 for (i = 0; i < NUM_LEADING_BYTES; i++)
|
|
1117 if (charsets[i])
|
|
1118 {
|
|
1119 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (i + MIN_LEADING_BYTE);
|
|
1120 assert (CHARSETP (charset));
|
|
1121 ensure_face_cachel_contains_charset (cachel, domain, charset);
|
|
1122 }
|
|
1123 }
|
|
1124
|
|
1125 void
|
|
1126 face_cachel_charset_font_metric_info (struct face_cachel *cachel,
|
|
1127 unsigned char *charsets,
|
|
1128 struct font_metric_info *fm)
|
|
1129 {
|
|
1130 int i;
|
|
1131
|
|
1132 fm->width = 1;
|
|
1133 fm->height = fm->ascent = 1;
|
|
1134 fm->descent = 0;
|
|
1135 fm->proportional_p = 0;
|
|
1136
|
|
1137 for (i = 0; i < NUM_LEADING_BYTES; i++)
|
|
1138 {
|
|
1139 if (charsets[i])
|
|
1140 {
|
|
1141 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (i + MIN_LEADING_BYTE);
|
|
1142 Lisp_Object font_instance = FACE_CACHEL_FONT (cachel, charset);
|
440
|
1143 Lisp_Font_Instance *fi = XFONT_INSTANCE (font_instance);
|
428
|
1144
|
|
1145 assert (CHARSETP (charset));
|
|
1146 assert (FONT_INSTANCEP (font_instance));
|
|
1147
|
|
1148 if (fm->ascent < (int) fi->ascent) fm->ascent = (int) fi->ascent;
|
|
1149 if (fm->descent < (int) fi->descent) fm->descent = (int) fi->descent;
|
|
1150 fm->height = fm->ascent + fm->descent;
|
|
1151 if (fi->proportional_p)
|
|
1152 fm->proportional_p = 1;
|
|
1153 if (EQ (charset, Vcharset_ascii))
|
|
1154 fm->width = fi->width;
|
|
1155 }
|
|
1156 }
|
|
1157 }
|
|
1158
|
|
1159 #define FROB(field) \
|
|
1160 do { \
|
|
1161 Lisp_Object new_val = \
|
|
1162 FACE_PROPERTY_INSTANCE (face, Q##field, domain, 1, Qzero); \
|
|
1163 int bound = 1; \
|
|
1164 if (UNBOUNDP (new_val)) \
|
|
1165 { \
|
|
1166 bound = 0; \
|
|
1167 new_val = FACE_PROPERTY_INSTANCE (face, Q##field, domain, 0, Qzero); \
|
|
1168 } \
|
|
1169 if (!EQ (new_val, cachel->field)) \
|
|
1170 { \
|
|
1171 cachel->field = new_val; \
|
|
1172 cachel->dirty = 1; \
|
|
1173 } \
|
|
1174 cachel->field##_specified = (bound || default_face); \
|
|
1175 } while (0)
|
|
1176
|
446
|
1177 /*
|
|
1178 * A face's background pixmap will override the face's
|
|
1179 * background color. But the background pixmap of the
|
|
1180 * default face should not override the background color of
|
|
1181 * a face if the background color has been specified or
|
|
1182 * inherited.
|
|
1183 *
|
|
1184 * To accomplish this we remove the background pixmap of the
|
|
1185 * cachel and mark it as having been specified so that cachel
|
|
1186 * merging won't override it later.
|
|
1187 */
|
|
1188 #define MAYBE_UNFROB_BACKGROUND_PIXMAP \
|
|
1189 do \
|
|
1190 { \
|
|
1191 if (! default_face \
|
|
1192 && cachel->background_specified \
|
|
1193 && ! cachel->background_pixmap_specified) \
|
|
1194 { \
|
|
1195 cachel->background_pixmap = Qunbound; \
|
|
1196 cachel->background_pixmap_specified = 1; \
|
|
1197 } \
|
|
1198 } while (0)
|
|
1199
|
|
1200
|
|
1201 /* Add a cachel for the given face to the given window's cache. */
|
|
1202
|
|
1203 static void
|
|
1204 add_face_cachel (struct window *w, Lisp_Object face)
|
|
1205 {
|
|
1206 int must_finish_frobbing = ! WINDOW_FACE_CACHEL (w, DEFAULT_INDEX);
|
|
1207 struct face_cachel new_cachel;
|
|
1208 Lisp_Object domain;
|
|
1209
|
|
1210 reset_face_cachel (&new_cachel);
|
793
|
1211 domain = wrap_window (w);
|
446
|
1212 update_face_cachel_data (&new_cachel, domain, face);
|
|
1213 Dynarr_add (w->face_cachels, new_cachel);
|
|
1214
|
|
1215 /* The face's background pixmap have not yet been frobbed (see comment
|
|
1216 int update_face_cachel_data), so we have to do it now */
|
|
1217 if (must_finish_frobbing)
|
|
1218 {
|
|
1219 int default_face = EQ (face, Vdefault_face);
|
|
1220 struct face_cachel *cachel
|
|
1221 = Dynarr_atp (w->face_cachels, Dynarr_length (w->face_cachels) - 1);
|
|
1222
|
|
1223 FROB (background_pixmap);
|
|
1224 MAYBE_UNFROB_BACKGROUND_PIXMAP;
|
|
1225 }
|
|
1226 }
|
|
1227
|
|
1228 /* Called when the updated flag has been cleared on a cachel.
|
|
1229 This function returns 1 if the caller must finish the update (see comment
|
|
1230 below), 0 otherwise.
|
|
1231 */
|
|
1232
|
|
1233 void
|
|
1234 update_face_cachel_data (struct face_cachel *cachel,
|
|
1235 Lisp_Object domain,
|
|
1236 Lisp_Object face)
|
|
1237 {
|
|
1238 if (XFACE (face)->dirty || UNBOUNDP (cachel->face))
|
|
1239 {
|
|
1240 int default_face = EQ (face, Vdefault_face);
|
|
1241 cachel->face = face;
|
|
1242
|
|
1243 /* We normally only set the _specified flags if the value was
|
|
1244 actually bound. The exception is for the default face where
|
|
1245 we always set it since it is the ultimate fallback. */
|
|
1246
|
428
|
1247 FROB (foreground);
|
|
1248 FROB (background);
|
|
1249 FROB (display_table);
|
446
|
1250
|
|
1251 /* #### WARNING: the background pixmap property of faces is currently
|
|
1252 the only one dealing with images. The problem we have here is that
|
|
1253 frobbing the background pixmap might lead to image instantiation
|
|
1254 which in turn might require that the cache we're building be up to
|
|
1255 date, hence a crash. Here's a typical scenario of this:
|
|
1256
|
|
1257 - a new window is created and it's face cache elements are
|
|
1258 initialized through a call to reset_face_cachels[1]. At that point,
|
|
1259 the cache for the default and modeline faces (normaly taken care of
|
|
1260 by redisplay itself) are null.
|
|
1261 - the default face has a background pixmap which needs to be
|
|
1262 instantiated right here, as a consequence of cache initialization.
|
|
1263 - the background pixmap image happens to be instantiated as a string
|
|
1264 (this happens on tty's for instance).
|
|
1265 - In order to do this, we need to compute the string geometry.
|
|
1266 - In order to do this, we might have to access the window's default
|
|
1267 face cache. But this is the cache we're building right now, it is
|
|
1268 null.
|
|
1269 - BARF !!!!!
|
428
|
1270
|
446
|
1271 To sum up, this means that it is in general unsafe to instantiate
|
|
1272 images before face cache updating is complete (appart from image
|
|
1273 related face attributes). The solution we use below is to actually
|
|
1274 detect whether we're building the window's face_cachels for the first
|
|
1275 time, and simply NOT frob the background pixmap in that case. If
|
|
1276 other image-related face attributes are ever implemented, they should
|
|
1277 be protected the same way right here.
|
|
1278
|
|
1279 One note:
|
|
1280 * See comment in `default_face_font_info' in face.c. Who wrote it ?
|
|
1281 Maybe we have the begining of an answer here ?
|
|
1282
|
|
1283 Footnotes:
|
|
1284 [1] See comment at the top of `allocate_window' in window.c.
|
|
1285
|
|
1286 -- didier
|
|
1287 */
|
|
1288 if (! WINDOWP (domain)
|
|
1289 || WINDOW_FACE_CACHEL (DOMAIN_XWINDOW (domain), DEFAULT_INDEX))
|
428
|
1290 {
|
446
|
1291 FROB (background_pixmap);
|
|
1292 MAYBE_UNFROB_BACKGROUND_PIXMAP;
|
428
|
1293 }
|
|
1294 #undef FROB
|
446
|
1295 #undef MAYBE_UNFROB_BACKGROUND_PIXMAP
|
428
|
1296
|
|
1297 ensure_face_cachel_contains_charset (cachel, domain, Vcharset_ascii);
|
|
1298
|
|
1299 #define FROB(field) \
|
|
1300 do { \
|
|
1301 Lisp_Object new_val = \
|
|
1302 FACE_PROPERTY_INSTANCE (face, Q##field, domain, 1, Qzero); \
|
|
1303 int bound = 1; \
|
|
1304 unsigned int new_val_int; \
|
|
1305 if (UNBOUNDP (new_val)) \
|
|
1306 { \
|
|
1307 bound = 0; \
|
|
1308 new_val = FACE_PROPERTY_INSTANCE (face, Q##field, domain, 0, Qzero); \
|
|
1309 } \
|
|
1310 new_val_int = EQ (new_val, Qt); \
|
|
1311 if (cachel->field != new_val_int) \
|
|
1312 { \
|
|
1313 cachel->field = new_val_int; \
|
|
1314 cachel->dirty = 1; \
|
|
1315 } \
|
|
1316 cachel->field##_specified = bound; \
|
|
1317 } while (0)
|
|
1318
|
|
1319 FROB (underline);
|
|
1320 FROB (strikethru);
|
|
1321 FROB (highlight);
|
|
1322 FROB (dim);
|
|
1323 FROB (reverse);
|
|
1324 FROB (blinking);
|
|
1325 #undef FROB
|
|
1326 }
|
|
1327
|
|
1328 cachel->updated = 1;
|
|
1329 }
|
|
1330
|
|
1331 /* Merge the cachel identified by FINDEX in window W into the given
|
|
1332 cachel. */
|
|
1333
|
|
1334 static void
|
|
1335 merge_face_cachel_data (struct window *w, face_index findex,
|
|
1336 struct face_cachel *cachel)
|
|
1337 {
|
|
1338 #define FINDEX_FIELD(field) \
|
|
1339 Dynarr_atp (w->face_cachels, findex)->field
|
|
1340
|
|
1341 #define FROB(field) \
|
|
1342 do { \
|
|
1343 if (!cachel->field##_specified && FINDEX_FIELD (field##_specified)) \
|
|
1344 { \
|
|
1345 cachel->field = FINDEX_FIELD (field); \
|
|
1346 cachel->field##_specified = 1; \
|
|
1347 cachel->dirty = 1; \
|
|
1348 } \
|
|
1349 } while (0)
|
|
1350
|
|
1351 FROB (foreground);
|
|
1352 FROB (background);
|
|
1353 FROB (display_table);
|
|
1354 FROB (background_pixmap);
|
|
1355 FROB (underline);
|
|
1356 FROB (strikethru);
|
|
1357 FROB (highlight);
|
|
1358 FROB (dim);
|
|
1359 FROB (reverse);
|
|
1360 FROB (blinking);
|
|
1361 /* And do ASCII, of course. */
|
|
1362 {
|
|
1363 int offs = LEADING_BYTE_ASCII - MIN_LEADING_BYTE;
|
|
1364
|
|
1365 if (!cachel->font_specified[offs] && FINDEX_FIELD (font_specified[offs]))
|
|
1366 {
|
|
1367 cachel->font[offs] = FINDEX_FIELD (font[offs]);
|
|
1368 cachel->font_specified[offs] = 1;
|
|
1369 cachel->dirty = 1;
|
|
1370 }
|
|
1371 }
|
|
1372
|
|
1373 #undef FROB
|
|
1374 #undef FINDEX_FIELD
|
|
1375
|
|
1376 cachel->updated = 1;
|
|
1377 }
|
|
1378
|
|
1379 /* Initialize a cachel. */
|
|
1380
|
|
1381 void
|
|
1382 reset_face_cachel (struct face_cachel *cachel)
|
|
1383 {
|
|
1384 xzero (*cachel);
|
|
1385 cachel->face = Qunbound;
|
|
1386 cachel->nfaces = 0;
|
|
1387 cachel->merged_faces = 0;
|
|
1388 cachel->foreground = Qunbound;
|
|
1389 cachel->background = Qunbound;
|
|
1390 {
|
|
1391 int i;
|
|
1392
|
|
1393 for (i = 0; i < NUM_LEADING_BYTES; i++)
|
|
1394 cachel->font[i] = Qunbound;
|
|
1395 }
|
|
1396 cachel->display_table = Qunbound;
|
|
1397 cachel->background_pixmap = Qunbound;
|
|
1398 }
|
|
1399
|
|
1400 /* Retrieve the index to a cachel for window W that corresponds to
|
|
1401 the specified face. If necessary, add a new element to the
|
|
1402 cache. */
|
|
1403
|
|
1404 face_index
|
|
1405 get_builtin_face_cache_index (struct window *w, Lisp_Object face)
|
|
1406 {
|
|
1407 int elt;
|
|
1408
|
|
1409 if (noninteractive)
|
|
1410 return 0;
|
|
1411
|
|
1412 for (elt = 0; elt < Dynarr_length (w->face_cachels); elt++)
|
|
1413 {
|
|
1414 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, elt);
|
|
1415
|
|
1416 if (EQ (cachel->face, face))
|
|
1417 {
|
793
|
1418 Lisp_Object window = wrap_window (w);
|
|
1419
|
428
|
1420 if (!cachel->updated)
|
|
1421 update_face_cachel_data (cachel, window, face);
|
|
1422 return elt;
|
|
1423 }
|
|
1424 }
|
|
1425
|
|
1426 /* If we didn't find the face, add it and then return its index. */
|
|
1427 add_face_cachel (w, face);
|
|
1428 return elt;
|
|
1429 }
|
|
1430
|
|
1431 void
|
|
1432 reset_face_cachels (struct window *w)
|
|
1433 {
|
|
1434 /* #### Not initialized in batch mode for the stream device. */
|
|
1435 if (w->face_cachels)
|
|
1436 {
|
|
1437 int i;
|
|
1438
|
|
1439 for (i = 0; i < Dynarr_length (w->face_cachels); i++)
|
|
1440 {
|
|
1441 struct face_cachel *cachel = Dynarr_atp (w->face_cachels, i);
|
|
1442 if (cachel->merged_faces)
|
|
1443 Dynarr_free (cachel->merged_faces);
|
|
1444 }
|
|
1445 Dynarr_reset (w->face_cachels);
|
|
1446 get_builtin_face_cache_index (w, Vdefault_face);
|
|
1447 get_builtin_face_cache_index (w, Vmodeline_face);
|
|
1448 XFRAME (w->frame)->window_face_cache_reset = 1;
|
|
1449 }
|
|
1450 }
|
|
1451
|
|
1452 void
|
|
1453 mark_face_cachels_as_clean (struct window *w)
|
|
1454 {
|
|
1455 int elt;
|
|
1456
|
|
1457 for (elt = 0; elt < Dynarr_length (w->face_cachels); elt++)
|
|
1458 Dynarr_atp (w->face_cachels, elt)->dirty = 0;
|
|
1459 }
|
|
1460
|
|
1461 void
|
|
1462 mark_face_cachels_as_not_updated (struct window *w)
|
|
1463 {
|
|
1464 int elt;
|
|
1465
|
|
1466 for (elt = 0; elt < Dynarr_length (w->face_cachels); elt++)
|
|
1467 {
|
|
1468 struct face_cachel *cachel = Dynarr_atp (w->face_cachels, elt);
|
|
1469 int i;
|
|
1470
|
|
1471 cachel->updated = 0;
|
|
1472 for (i = 0; i < NUM_LEADING_BYTES; i++)
|
|
1473 cachel->font_updated[i] = 0;
|
|
1474 }
|
|
1475 }
|
|
1476
|
|
1477 #ifdef MEMORY_USAGE_STATS
|
|
1478
|
|
1479 int
|
|
1480 compute_face_cachel_usage (face_cachel_dynarr *face_cachels,
|
|
1481 struct overhead_stats *ovstats)
|
|
1482 {
|
|
1483 int total = 0;
|
|
1484
|
|
1485 if (face_cachels)
|
|
1486 {
|
|
1487 int i;
|
|
1488
|
|
1489 total += Dynarr_memory_usage (face_cachels, ovstats);
|
|
1490 for (i = 0; i < Dynarr_length (face_cachels); i++)
|
|
1491 {
|
|
1492 int_dynarr *merged = Dynarr_at (face_cachels, i).merged_faces;
|
|
1493 if (merged)
|
|
1494 total += Dynarr_memory_usage (merged, ovstats);
|
|
1495 }
|
|
1496 }
|
|
1497
|
|
1498 return total;
|
|
1499 }
|
|
1500
|
|
1501 #endif /* MEMORY_USAGE_STATS */
|
|
1502
|
|
1503
|
|
1504 /*****************************************************************************
|
|
1505 * merged face functions *
|
|
1506 *****************************************************************************/
|
|
1507
|
|
1508 /* Compare two merged face cachels to determine whether we have to add
|
|
1509 a new entry to the face cache.
|
|
1510
|
|
1511 Note that we do not compare the attributes, but just the faces the
|
|
1512 cachels are based on. If they are the same, then the cachels certainly
|
|
1513 ought to have the same attributes, except in the case where fonts
|
|
1514 for different charsets have been determined in the two -- and in that
|
|
1515 case this difference is fine. */
|
|
1516
|
|
1517 static int
|
|
1518 compare_merged_face_cachels (struct face_cachel *cachel1,
|
|
1519 struct face_cachel *cachel2)
|
|
1520 {
|
|
1521 int i;
|
|
1522
|
|
1523 if (!EQ (cachel1->face, cachel2->face)
|
|
1524 || cachel1->nfaces != cachel2->nfaces)
|
|
1525 return 0;
|
|
1526
|
|
1527 for (i = 0; i < cachel1->nfaces; i++)
|
|
1528 if (FACE_CACHEL_FINDEX_UNSAFE (cachel1, i)
|
|
1529 != FACE_CACHEL_FINDEX_UNSAFE (cachel2, i))
|
|
1530 return 0;
|
|
1531
|
|
1532 return 1;
|
|
1533 }
|
|
1534
|
|
1535 /* Retrieve the index to a cachel for window W that corresponds to
|
|
1536 the specified cachel. If necessary, add a new element to the
|
|
1537 cache. This is similar to get_builtin_face_cache_index() but
|
|
1538 is intended for merged cachels rather than for cachels representing
|
|
1539 just a face.
|
|
1540
|
|
1541 Note that a merged cachel for just one face is not the same as
|
|
1542 the simple cachel for that face, because it is also merged with
|
|
1543 the default face. */
|
|
1544
|
|
1545 static face_index
|
|
1546 get_merged_face_cache_index (struct window *w,
|
|
1547 struct face_cachel *merged_cachel)
|
|
1548 {
|
|
1549 int elt;
|
|
1550 int cache_size = Dynarr_length (w->face_cachels);
|
|
1551
|
|
1552 for (elt = 0; elt < cache_size; elt++)
|
|
1553 {
|
|
1554 struct face_cachel *cachel =
|
|
1555 Dynarr_atp (w->face_cachels, elt);
|
|
1556
|
|
1557 if (compare_merged_face_cachels (cachel, merged_cachel))
|
|
1558 return elt;
|
|
1559 }
|
|
1560
|
|
1561 /* We didn't find it so add this instance to the cache. */
|
|
1562 merged_cachel->updated = 1;
|
|
1563 merged_cachel->dirty = 1;
|
|
1564 Dynarr_add (w->face_cachels, *merged_cachel);
|
|
1565 return cache_size;
|
|
1566 }
|
|
1567
|
|
1568 face_index
|
|
1569 get_extent_fragment_face_cache_index (struct window *w,
|
|
1570 struct extent_fragment *ef)
|
|
1571 {
|
|
1572 struct face_cachel cachel;
|
|
1573 int len = Dynarr_length (ef->extents);
|
|
1574 face_index findex = 0;
|
|
1575
|
|
1576 /* Optimize the default case. */
|
|
1577 if (len == 0)
|
|
1578 return DEFAULT_INDEX;
|
|
1579 else
|
|
1580 {
|
|
1581 int i;
|
|
1582
|
|
1583 /* Merge the faces of the extents together in order. */
|
|
1584
|
|
1585 reset_face_cachel (&cachel);
|
|
1586
|
|
1587 for (i = len - 1; i >= 0; i--)
|
|
1588 {
|
|
1589 EXTENT current = Dynarr_at (ef->extents, i);
|
|
1590 int has_findex = 0;
|
|
1591 Lisp_Object face = extent_face (current);
|
|
1592
|
|
1593 if (FACEP (face))
|
|
1594 {
|
|
1595 findex = get_builtin_face_cache_index (w, face);
|
|
1596 has_findex = 1;
|
|
1597 merge_face_cachel_data (w, findex, &cachel);
|
|
1598 }
|
|
1599 /* remember, we're called from within redisplay
|
|
1600 so we can't error. */
|
|
1601 else while (CONSP (face))
|
|
1602 {
|
|
1603 Lisp_Object one_face = XCAR (face);
|
|
1604 if (FACEP (one_face))
|
|
1605 {
|
|
1606 findex = get_builtin_face_cache_index (w, one_face);
|
|
1607 merge_face_cachel_data (w, findex, &cachel);
|
|
1608
|
|
1609 /* code duplication here but there's no clean
|
|
1610 way to avoid it. */
|
|
1611 if (cachel.nfaces >= NUM_STATIC_CACHEL_FACES)
|
|
1612 {
|
|
1613 if (!cachel.merged_faces)
|
|
1614 cachel.merged_faces = Dynarr_new (int);
|
|
1615 Dynarr_add (cachel.merged_faces, findex);
|
|
1616 }
|
|
1617 else
|
|
1618 cachel.merged_faces_static[cachel.nfaces] = findex;
|
|
1619 cachel.nfaces++;
|
|
1620 }
|
|
1621 face = XCDR (face);
|
|
1622 }
|
|
1623
|
|
1624 if (has_findex)
|
|
1625 {
|
|
1626 if (cachel.nfaces >= NUM_STATIC_CACHEL_FACES)
|
|
1627 {
|
|
1628 if (!cachel.merged_faces)
|
|
1629 cachel.merged_faces = Dynarr_new (int);
|
|
1630 Dynarr_add (cachel.merged_faces, findex);
|
|
1631 }
|
|
1632 else
|
|
1633 cachel.merged_faces_static[cachel.nfaces] = findex;
|
|
1634 cachel.nfaces++;
|
|
1635 }
|
|
1636 }
|
|
1637
|
|
1638 /* Now finally merge in the default face. */
|
|
1639 findex = get_builtin_face_cache_index (w, Vdefault_face);
|
|
1640 merge_face_cachel_data (w, findex, &cachel);
|
|
1641
|
444
|
1642 findex = get_merged_face_cache_index (w, &cachel);
|
|
1643 if (cachel.merged_faces &&
|
|
1644 /* merged_faces did not get stored and available via return value */
|
|
1645 Dynarr_at (w->face_cachels, findex).merged_faces !=
|
|
1646 cachel.merged_faces)
|
|
1647 {
|
|
1648 Dynarr_free (cachel.merged_faces);
|
|
1649 cachel.merged_faces = 0;
|
|
1650 }
|
|
1651 return findex;
|
428
|
1652 }
|
|
1653 }
|
|
1654
|
|
1655
|
|
1656 /*****************************************************************************
|
|
1657 interface functions
|
|
1658 ****************************************************************************/
|
|
1659
|
|
1660 static void
|
|
1661 update_EmacsFrame (Lisp_Object frame, Lisp_Object name)
|
|
1662 {
|
|
1663 struct frame *frm = XFRAME (frame);
|
|
1664
|
|
1665 if (EQ (name, Qfont))
|
|
1666 MARK_FRAME_SIZE_SLIPPED (frm);
|
|
1667
|
|
1668 MAYBE_FRAMEMETH (frm, update_frame_external_traits, (frm, name));
|
|
1669 }
|
|
1670
|
|
1671 static void
|
|
1672 update_EmacsFrames (Lisp_Object locale, Lisp_Object name)
|
|
1673 {
|
|
1674 if (FRAMEP (locale))
|
|
1675 {
|
|
1676 update_EmacsFrame (locale, name);
|
|
1677 }
|
|
1678 else if (DEVICEP (locale))
|
|
1679 {
|
|
1680 Lisp_Object frmcons;
|
|
1681
|
|
1682 DEVICE_FRAME_LOOP (frmcons, XDEVICE (locale))
|
|
1683 update_EmacsFrame (XCAR (frmcons), name);
|
|
1684 }
|
|
1685 else if (EQ (locale, Qglobal) || EQ (locale, Qfallback))
|
|
1686 {
|
|
1687 Lisp_Object frmcons, devcons, concons;
|
|
1688
|
|
1689 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
|
|
1690 update_EmacsFrame (XCAR (frmcons), name);
|
|
1691 }
|
|
1692 }
|
|
1693
|
|
1694 void
|
|
1695 update_frame_face_values (struct frame *f)
|
|
1696 {
|
793
|
1697 Lisp_Object frm = wrap_frame (f);
|
428
|
1698
|
|
1699 update_EmacsFrame (frm, Qforeground);
|
|
1700 update_EmacsFrame (frm, Qbackground);
|
|
1701 update_EmacsFrame (frm, Qfont);
|
|
1702 }
|
|
1703
|
|
1704 void
|
|
1705 face_property_was_changed (Lisp_Object face, Lisp_Object property,
|
|
1706 Lisp_Object locale)
|
|
1707 {
|
|
1708 int default_face = EQ (face, Vdefault_face);
|
|
1709
|
|
1710 /* If the locale could affect the frame value, then call
|
|
1711 update_EmacsFrames just in case. */
|
|
1712 if (default_face &&
|
|
1713 (EQ (property, Qforeground) ||
|
|
1714 EQ (property, Qbackground) ||
|
|
1715 EQ (property, Qfont)))
|
|
1716 update_EmacsFrames (locale, property);
|
|
1717
|
|
1718 if (WINDOWP (locale))
|
|
1719 {
|
|
1720 MARK_FRAME_FACES_CHANGED (XFRAME (XWINDOW (locale)->frame));
|
|
1721 }
|
|
1722 else if (FRAMEP (locale))
|
|
1723 {
|
|
1724 MARK_FRAME_FACES_CHANGED (XFRAME (locale));
|
|
1725 }
|
|
1726 else if (DEVICEP (locale))
|
|
1727 {
|
|
1728 MARK_DEVICE_FRAMES_FACES_CHANGED (XDEVICE (locale));
|
|
1729 }
|
|
1730 else
|
|
1731 {
|
|
1732 Lisp_Object devcons, concons;
|
|
1733 DEVICE_LOOP_NO_BREAK (devcons, concons)
|
|
1734 MARK_DEVICE_FRAMES_FACES_CHANGED (XDEVICE (XCAR (devcons)));
|
|
1735 }
|
|
1736
|
|
1737 /*
|
|
1738 * This call to update_faces_inheritance isn't needed and makes
|
|
1739 * creating and modifying faces _very_ slow. The point of
|
|
1740 * update_face_inheritances is to find all faces that inherit
|
|
1741 * directly from this face property and set the specifier "dirty"
|
|
1742 * flag on the corresponding specifier. This forces recaching of
|
|
1743 * cached specifier values in frame and window struct slots. But
|
|
1744 * currently no face properties are cached in frame and window
|
|
1745 * struct slots, so calling this function does nothing useful!
|
|
1746 *
|
|
1747 * Further, since update_faces_inheritance maps over the whole
|
|
1748 * face table every time it is called, it gets terribly slow when
|
|
1749 * there are many faces. Creating 500 faces on a 50Mhz 486 took
|
|
1750 * 433 seconds when update_faces_inheritance was called. With the
|
|
1751 * call commented out, creating those same 500 faces took 0.72
|
|
1752 * seconds.
|
|
1753 */
|
|
1754 /* update_faces_inheritance (face, property);*/
|
|
1755 XFACE (face)->dirty = 1;
|
|
1756 }
|
|
1757
|
|
1758 DEFUN ("copy-face", Fcopy_face, 2, 6, 0, /*
|
|
1759 Define and return a new face which is a copy of an existing one,
|
|
1760 or makes an already-existing face be exactly like another.
|
|
1761 LOCALE, TAG-SET, EXACT-P, and HOW-TO-ADD are as in `copy-specifier'.
|
|
1762 */
|
|
1763 (old_face, new_name, locale, tag_set, exact_p, how_to_add))
|
|
1764 {
|
440
|
1765 Lisp_Face *fold, *fnew;
|
428
|
1766 Lisp_Object new_face = Qnil;
|
|
1767 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
|
|
1768
|
|
1769 old_face = Fget_face (old_face);
|
|
1770
|
|
1771 /* We GCPRO old_face because it might be temporary, and GCing could
|
|
1772 occur in various places below. */
|
|
1773 GCPRO4 (tag_set, locale, old_face, new_face);
|
|
1774 /* check validity of how_to_add now. */
|
|
1775 decode_how_to_add_specification (how_to_add);
|
|
1776 /* and of tag_set. */
|
|
1777 tag_set = decode_specifier_tag_set (tag_set);
|
|
1778 /* and of locale. */
|
|
1779 locale = decode_locale_list (locale);
|
|
1780
|
|
1781 new_face = Ffind_face (new_name);
|
|
1782 if (NILP (new_face))
|
|
1783 {
|
|
1784 Lisp_Object temp;
|
|
1785
|
|
1786 CHECK_SYMBOL (new_name);
|
|
1787
|
|
1788 /* Create the new face with the same status as the old face. */
|
|
1789 temp = (NILP (Fgethash (old_face, Vtemporary_faces_cache, Qnil))
|
|
1790 ? Qnil
|
|
1791 : Qt);
|
|
1792
|
|
1793 new_face = Fmake_face (new_name, Qnil, temp);
|
|
1794 }
|
|
1795
|
|
1796 fold = XFACE (old_face);
|
|
1797 fnew = XFACE (new_face);
|
|
1798
|
|
1799 #define COPY_PROPERTY(property) \
|
|
1800 Fcopy_specifier (fold->property, fnew->property, \
|
|
1801 locale, tag_set, exact_p, how_to_add);
|
|
1802
|
|
1803 COPY_PROPERTY (foreground);
|
|
1804 COPY_PROPERTY (background);
|
|
1805 COPY_PROPERTY (font);
|
|
1806 COPY_PROPERTY (display_table);
|
|
1807 COPY_PROPERTY (background_pixmap);
|
|
1808 COPY_PROPERTY (underline);
|
|
1809 COPY_PROPERTY (strikethru);
|
|
1810 COPY_PROPERTY (highlight);
|
|
1811 COPY_PROPERTY (dim);
|
|
1812 COPY_PROPERTY (blinking);
|
|
1813 COPY_PROPERTY (reverse);
|
|
1814 #undef COPY_PROPERTY
|
|
1815 /* #### should it copy the individual specifiers, if they exist? */
|
|
1816 fnew->plist = Fcopy_sequence (fold->plist);
|
|
1817
|
|
1818 UNGCPRO;
|
|
1819
|
|
1820 return new_name;
|
|
1821 }
|
|
1822
|
|
1823
|
|
1824 void
|
|
1825 syms_of_faces (void)
|
|
1826 {
|
442
|
1827 INIT_LRECORD_IMPLEMENTATION (face);
|
|
1828
|
440
|
1829 /* Qdefault, Qwidget, Qleft_margin, Qright_margin defined in general.c */
|
563
|
1830 DEFSYMBOL (Qmodeline);
|
|
1831 DEFSYMBOL (Qgui_element);
|
|
1832 DEFSYMBOL (Qtext_cursor);
|
|
1833 DEFSYMBOL (Qvertical_divider);
|
428
|
1834
|
|
1835 DEFSUBR (Ffacep);
|
|
1836 DEFSUBR (Ffind_face);
|
|
1837 DEFSUBR (Fget_face);
|
|
1838 DEFSUBR (Fface_name);
|
|
1839 DEFSUBR (Fbuilt_in_face_specifiers);
|
|
1840 DEFSUBR (Fface_list);
|
|
1841 DEFSUBR (Fmake_face);
|
|
1842 DEFSUBR (Fcopy_face);
|
|
1843
|
563
|
1844 DEFSYMBOL (Qfacep);
|
|
1845 DEFSYMBOL (Qforeground);
|
|
1846 DEFSYMBOL (Qbackground);
|
428
|
1847 /* Qfont defined in general.c */
|
563
|
1848 DEFSYMBOL (Qdisplay_table);
|
|
1849 DEFSYMBOL (Qbackground_pixmap);
|
|
1850 DEFSYMBOL (Qunderline);
|
|
1851 DEFSYMBOL (Qstrikethru);
|
428
|
1852 /* Qhighlight, Qreverse defined in general.c */
|
563
|
1853 DEFSYMBOL (Qdim);
|
|
1854 DEFSYMBOL (Qblinking);
|
428
|
1855
|
563
|
1856 DEFSYMBOL (Qinit_face_from_resources);
|
|
1857 DEFSYMBOL (Qinit_global_faces);
|
|
1858 DEFSYMBOL (Qinit_device_faces);
|
|
1859 DEFSYMBOL (Qinit_frame_faces);
|
428
|
1860 }
|
|
1861
|
|
1862 void
|
|
1863 structure_type_create_faces (void)
|
|
1864 {
|
|
1865 struct structure_type *st;
|
|
1866
|
|
1867 st = define_structure_type (Qface, face_validate, face_instantiate);
|
|
1868
|
|
1869 define_structure_type_keyword (st, Qname, face_name_validate);
|
|
1870 }
|
|
1871
|
|
1872 void
|
|
1873 vars_of_faces (void)
|
|
1874 {
|
|
1875 staticpro (&Vpermanent_faces_cache);
|
771
|
1876 Vpermanent_faces_cache =
|
|
1877 make_lisp_hash_table (10, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
428
|
1878 staticpro (&Vtemporary_faces_cache);
|
771
|
1879 Vtemporary_faces_cache =
|
|
1880 make_lisp_hash_table (0, HASH_TABLE_WEAK, HASH_TABLE_EQ);
|
428
|
1881
|
|
1882 staticpro (&Vdefault_face);
|
|
1883 Vdefault_face = Qnil;
|
|
1884 staticpro (&Vgui_element_face);
|
|
1885 Vgui_element_face = Qnil;
|
|
1886 staticpro (&Vwidget_face);
|
|
1887 Vwidget_face = Qnil;
|
|
1888 staticpro (&Vmodeline_face);
|
|
1889 Vmodeline_face = Qnil;
|
|
1890 staticpro (&Vtoolbar_face);
|
|
1891 Vtoolbar_face = Qnil;
|
|
1892
|
|
1893 staticpro (&Vvertical_divider_face);
|
|
1894 Vvertical_divider_face = Qnil;
|
|
1895 staticpro (&Vleft_margin_face);
|
|
1896 Vleft_margin_face = Qnil;
|
|
1897 staticpro (&Vright_margin_face);
|
|
1898 Vright_margin_face = Qnil;
|
|
1899 staticpro (&Vtext_cursor_face);
|
|
1900 Vtext_cursor_face = Qnil;
|
|
1901 staticpro (&Vpointer_face);
|
|
1902 Vpointer_face = Qnil;
|
|
1903
|
|
1904 {
|
|
1905 Lisp_Object syms[20];
|
|
1906 int n = 0;
|
|
1907
|
|
1908 syms[n++] = Qforeground;
|
|
1909 syms[n++] = Qbackground;
|
|
1910 syms[n++] = Qfont;
|
|
1911 syms[n++] = Qdisplay_table;
|
|
1912 syms[n++] = Qbackground_pixmap;
|
|
1913 syms[n++] = Qunderline;
|
|
1914 syms[n++] = Qstrikethru;
|
|
1915 syms[n++] = Qhighlight;
|
|
1916 syms[n++] = Qdim;
|
|
1917 syms[n++] = Qblinking;
|
|
1918 syms[n++] = Qreverse;
|
|
1919
|
|
1920 Vbuilt_in_face_specifiers = Flist (n, syms);
|
|
1921 staticpro (&Vbuilt_in_face_specifiers);
|
|
1922 }
|
|
1923 }
|
|
1924
|
|
1925 void
|
|
1926 complex_vars_of_faces (void)
|
|
1927 {
|
|
1928 /* Create the default face now so we know what it is immediately. */
|
|
1929
|
|
1930 Vdefault_face = Qnil; /* so that Fmake_face() doesn't set up a bogus
|
|
1931 default value */
|
771
|
1932 Vdefault_face = Fmake_face (Qdefault, build_msg_string ("default face"),
|
428
|
1933 Qnil);
|
|
1934
|
|
1935 /* Provide some last-resort fallbacks to avoid utter fuckage if
|
|
1936 someone provides invalid values for the global specifications. */
|
|
1937
|
|
1938 {
|
|
1939 Lisp_Object fg_fb = Qnil, bg_fb = Qnil;
|
|
1940
|
462
|
1941 #ifdef HAVE_GTK
|
|
1942 fg_fb = acons (list1 (Qgtk), build_string ("black"), fg_fb);
|
|
1943 bg_fb = acons (list1 (Qgtk), build_string ("white"), bg_fb);
|
|
1944 #endif
|
428
|
1945 #ifdef HAVE_X_WINDOWS
|
|
1946 fg_fb = acons (list1 (Qx), build_string ("black"), fg_fb);
|
|
1947 bg_fb = acons (list1 (Qx), build_string ("white"), bg_fb);
|
|
1948 #endif
|
|
1949 #ifdef HAVE_TTY
|
|
1950 fg_fb = acons (list1 (Qtty), Fvector (0, 0), fg_fb);
|
|
1951 bg_fb = acons (list1 (Qtty), Fvector (0, 0), bg_fb);
|
|
1952 #endif
|
|
1953 #ifdef HAVE_MS_WINDOWS
|
440
|
1954 fg_fb = acons (list1 (Qmsprinter), build_string ("black"), fg_fb);
|
|
1955 bg_fb = acons (list1 (Qmsprinter), build_string ("white"), bg_fb);
|
428
|
1956 fg_fb = acons (list1 (Qmswindows), build_string ("black"), fg_fb);
|
|
1957 bg_fb = acons (list1 (Qmswindows), build_string ("white"), bg_fb);
|
|
1958 #endif
|
|
1959 set_specifier_fallback (Fget (Vdefault_face, Qforeground, Qnil), fg_fb);
|
|
1960 set_specifier_fallback (Fget (Vdefault_face, Qbackground, Qnil), bg_fb);
|
|
1961 }
|
|
1962
|
|
1963 /* #### We may want to have different fallback values if NeXTstep
|
|
1964 support is compiled in. */
|
|
1965 {
|
|
1966 Lisp_Object inst_list = Qnil;
|
462
|
1967
|
|
1968 #if defined(HAVE_X_WINDOWS) || defined(HAVE_GTK)
|
|
1969 /* This is kind of ugly because stephen wanted this to be CPP
|
|
1970 ** identical to the old version, at least for the initial
|
|
1971 ** checkin
|
|
1972 **
|
|
1973 ** WMP March 9, 2001
|
|
1974 */
|
|
1975
|
428
|
1976 /* The same gory list from x-faces.el.
|
|
1977 (#### Perhaps we should remove the stuff from x-faces.el
|
|
1978 and only depend on this stuff here? That should work.)
|
|
1979 */
|
771
|
1980 const Char_ASCII *fonts[] =
|
428
|
1981 {
|
|
1982 "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
|
|
1983 "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
|
|
1984 "-*-courier-*-r-*-*-*-120-*-*-*-*-iso8859-*",
|
|
1985 "-*-*-medium-r-*-*-*-120-*-*-m-*-iso8859-*",
|
|
1986 "-*-*-medium-r-*-*-*-120-*-*-c-*-iso8859-*",
|
|
1987 "-*-*-*-r-*-*-*-120-*-*-m-*-iso8859-*",
|
|
1988 "-*-*-*-r-*-*-*-120-*-*-c-*-iso8859-*",
|
|
1989 "-*-*-*-r-*-*-*-120-*-*-*-*-iso8859-*",
|
|
1990 "-*-*-medium-r-*-*-*-120-*-*-m-*-*-*",
|
|
1991 "-*-*-medium-r-*-*-*-120-*-*-c-*-*-*",
|
|
1992 "-*-*-*-r-*-*-*-120-*-*-m-*-*-*",
|
|
1993 "-*-*-*-r-*-*-*-120-*-*-c-*-*-*",
|
|
1994 "-*-*-*-r-*-*-*-120-*-*-*-*-*-*",
|
|
1995 "-*-*-*-*-*-*-*-120-*-*-*-*-*-*",
|
|
1996 "*"
|
|
1997 };
|
771
|
1998 const Char_ASCII **fontptr;
|
428
|
1999
|
462
|
2000 #ifdef HAVE_X_WINDOWS
|
428
|
2001 for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--)
|
|
2002 inst_list = Fcons (Fcons (list1 (Qx), build_string (*fontptr)),
|
|
2003 inst_list);
|
|
2004 #endif /* HAVE_X_WINDOWS */
|
|
2005
|
462
|
2006 #ifdef HAVE_GTK
|
|
2007 for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--)
|
|
2008 inst_list = Fcons (Fcons (list1 (Qgtk), build_string (*fontptr)),
|
|
2009 inst_list);
|
|
2010 #endif /* HAVE_GTK */
|
|
2011 #endif /* HAVE_X_WINDOWS || HAVE_GTK */
|
|
2012
|
428
|
2013 #ifdef HAVE_TTY
|
|
2014 inst_list = Fcons (Fcons (list1 (Qtty), build_string ("normal")),
|
|
2015 inst_list);
|
|
2016 #endif /* HAVE_TTY */
|
440
|
2017
|
771
|
2018 #ifdef HAVE_MS_WINDOWS
|
|
2019 {
|
|
2020 const Char_ASCII *mswfonts[] =
|
|
2021 {
|
|
2022 "Courier New:Regular:10::Western",
|
|
2023 "Courier:Regular:10::Western",
|
|
2024 "Courier New:Regular:10::",
|
|
2025 "Courier:Regular:10::",
|
|
2026 ":Regular:10::"
|
|
2027 };
|
|
2028 const Char_ASCII **mswfontptr;
|
|
2029
|
|
2030 for (mswfontptr = mswfonts + countof (mswfonts) - 1;
|
|
2031 mswfontptr >= mswfonts; mswfontptr--)
|
|
2032 {
|
|
2033 /* display device */
|
|
2034 inst_list = Fcons (Fcons (list1 (Qmswindows),
|
|
2035 build_string (*mswfontptr)),
|
|
2036 inst_list);
|
|
2037 /* printer device */
|
|
2038 inst_list = Fcons (Fcons (list1 (Qmsprinter),
|
|
2039 build_string (*mswfontptr)),
|
|
2040 inst_list);
|
|
2041 }
|
793
|
2042 /* Use Lucida Console rather than Courier New if it exists -- the
|
|
2043 line spacing is much less, so many more lines fit with the same
|
|
2044 size font. (And it's specifically designed for screens.) */
|
|
2045 inst_list = Fcons (Fcons (list1 (Qmswindows),
|
|
2046 build_string ("Lucida Console:Regular:10::")),
|
|
2047 inst_list);
|
771
|
2048 }
|
428
|
2049 #endif /* HAVE_MS_WINDOWS */
|
771
|
2050
|
428
|
2051 set_specifier_fallback (Fget (Vdefault_face, Qfont, Qnil), inst_list);
|
|
2052 }
|
|
2053
|
|
2054 set_specifier_fallback (Fget (Vdefault_face, Qunderline, Qnil),
|
|
2055 list1 (Fcons (Qnil, Qnil)));
|
|
2056 set_specifier_fallback (Fget (Vdefault_face, Qstrikethru, Qnil),
|
|
2057 list1 (Fcons (Qnil, Qnil)));
|
|
2058 set_specifier_fallback (Fget (Vdefault_face, Qhighlight, Qnil),
|
|
2059 list1 (Fcons (Qnil, Qnil)));
|
|
2060 set_specifier_fallback (Fget (Vdefault_face, Qdim, Qnil),
|
|
2061 list1 (Fcons (Qnil, Qnil)));
|
|
2062 set_specifier_fallback (Fget (Vdefault_face, Qblinking, Qnil),
|
|
2063 list1 (Fcons (Qnil, Qnil)));
|
|
2064 set_specifier_fallback (Fget (Vdefault_face, Qreverse, Qnil),
|
|
2065 list1 (Fcons (Qnil, Qnil)));
|
|
2066
|
|
2067 /* gui-element is the parent face of all gui elements such as
|
|
2068 modeline, vertical divider and toolbar. */
|
|
2069 Vgui_element_face = Fmake_face (Qgui_element,
|
771
|
2070 build_msg_string ("gui element face"),
|
428
|
2071 Qnil);
|
|
2072
|
|
2073 /* Provide some last-resort fallbacks for gui-element face which
|
|
2074 mustn't default to default. */
|
|
2075 {
|
|
2076 Lisp_Object fg_fb = Qnil, bg_fb = Qnil;
|
|
2077
|
462
|
2078 #ifdef HAVE_GTK
|
|
2079 /* We need to put something in there, or error checking gets
|
|
2080 #%!@#ed up before the styles are set, which override the
|
|
2081 fallbacks. */
|
|
2082 fg_fb = acons (list1 (Qgtk), build_string ("black"), fg_fb);
|
|
2083 bg_fb = acons (list1 (Qgtk), build_string ("Gray80"), bg_fb);
|
|
2084 #endif
|
428
|
2085 #ifdef HAVE_X_WINDOWS
|
|
2086 fg_fb = acons (list1 (Qx), build_string ("black"), fg_fb);
|
|
2087 bg_fb = acons (list1 (Qx), build_string ("Gray80"), bg_fb);
|
|
2088 #endif
|
|
2089 #ifdef HAVE_TTY
|
|
2090 fg_fb = acons (list1 (Qtty), Fvector (0, 0), fg_fb);
|
|
2091 bg_fb = acons (list1 (Qtty), Fvector (0, 0), bg_fb);
|
|
2092 #endif
|
|
2093 #ifdef HAVE_MS_WINDOWS
|
440
|
2094 fg_fb = acons (list1 (Qmsprinter), build_string ("black"), fg_fb);
|
|
2095 bg_fb = acons (list1 (Qmsprinter), build_string ("white"), bg_fb);
|
428
|
2096 fg_fb = acons (list1 (Qmswindows), build_string ("black"), fg_fb);
|
|
2097 bg_fb = acons (list1 (Qmswindows), build_string ("Gray75"), bg_fb);
|
|
2098 #endif
|
|
2099 set_specifier_fallback (Fget (Vgui_element_face, Qforeground, Qnil), fg_fb);
|
|
2100 set_specifier_fallback (Fget (Vgui_element_face, Qbackground, Qnil), bg_fb);
|
|
2101 }
|
|
2102
|
|
2103 /* Now create the other faces that redisplay needs to refer to
|
|
2104 directly. We could create them in Lisp but it's simpler this
|
|
2105 way since we need to get them anyway. */
|
|
2106
|
|
2107 /* modeline is gui element. */
|
771
|
2108 Vmodeline_face = Fmake_face (Qmodeline, build_msg_string ("modeline face"),
|
428
|
2109 Qnil);
|
|
2110
|
|
2111 set_specifier_fallback (Fget (Vmodeline_face, Qforeground, Qunbound),
|
|
2112 Fget (Vgui_element_face, Qforeground, Qunbound));
|
|
2113 set_specifier_fallback (Fget (Vmodeline_face, Qbackground, Qunbound),
|
|
2114 Fget (Vgui_element_face, Qbackground, Qunbound));
|
|
2115 set_specifier_fallback (Fget (Vmodeline_face, Qbackground_pixmap, Qnil),
|
|
2116 Fget (Vgui_element_face, Qbackground_pixmap,
|
|
2117 Qunbound));
|
|
2118
|
|
2119 /* toolbar is another gui element */
|
|
2120 Vtoolbar_face = Fmake_face (Qtoolbar,
|
771
|
2121 build_msg_string ("toolbar face"),
|
428
|
2122 Qnil);
|
|
2123 set_specifier_fallback (Fget (Vtoolbar_face, Qforeground, Qunbound),
|
|
2124 Fget (Vgui_element_face, Qforeground, Qunbound));
|
|
2125 set_specifier_fallback (Fget (Vtoolbar_face, Qbackground, Qunbound),
|
|
2126 Fget (Vgui_element_face, Qbackground, Qunbound));
|
|
2127 set_specifier_fallback (Fget (Vtoolbar_face, Qbackground_pixmap, Qnil),
|
|
2128 Fget (Vgui_element_face, Qbackground_pixmap,
|
|
2129 Qunbound));
|
|
2130
|
|
2131 /* vertical divider is another gui element */
|
|
2132 Vvertical_divider_face = Fmake_face (Qvertical_divider,
|
771
|
2133 build_msg_string ("vertical divider face"),
|
428
|
2134 Qnil);
|
|
2135
|
|
2136 set_specifier_fallback (Fget (Vvertical_divider_face, Qforeground, Qunbound),
|
|
2137 Fget (Vgui_element_face, Qforeground, Qunbound));
|
|
2138 set_specifier_fallback (Fget (Vvertical_divider_face, Qbackground, Qunbound),
|
|
2139 Fget (Vgui_element_face, Qbackground, Qunbound));
|
|
2140 set_specifier_fallback (Fget (Vvertical_divider_face, Qbackground_pixmap,
|
|
2141 Qunbound),
|
|
2142 Fget (Vgui_element_face, Qbackground_pixmap,
|
|
2143 Qunbound));
|
|
2144
|
|
2145 /* widget is another gui element */
|
|
2146 Vwidget_face = Fmake_face (Qwidget,
|
771
|
2147 build_msg_string ("widget face"),
|
428
|
2148 Qnil);
|
442
|
2149 set_specifier_fallback (Fget (Vwidget_face, Qfont, Qunbound),
|
|
2150 Fget (Vgui_element_face, Qfont, Qunbound));
|
428
|
2151 set_specifier_fallback (Fget (Vwidget_face, Qforeground, Qunbound),
|
|
2152 Fget (Vgui_element_face, Qforeground, Qunbound));
|
|
2153 set_specifier_fallback (Fget (Vwidget_face, Qbackground, Qunbound),
|
|
2154 Fget (Vgui_element_face, Qbackground, Qunbound));
|
442
|
2155 /* We don't want widgets to have a default background pixmap. */
|
428
|
2156
|
|
2157 Vleft_margin_face = Fmake_face (Qleft_margin,
|
771
|
2158 build_msg_string ("left margin face"),
|
428
|
2159 Qnil);
|
|
2160 Vright_margin_face = Fmake_face (Qright_margin,
|
771
|
2161 build_msg_string ("right margin face"),
|
428
|
2162 Qnil);
|
|
2163 Vtext_cursor_face = Fmake_face (Qtext_cursor,
|
771
|
2164 build_msg_string ("face for text cursor"),
|
428
|
2165 Qnil);
|
|
2166 Vpointer_face =
|
|
2167 Fmake_face (Qpointer,
|
771
|
2168 build_msg_string
|
428
|
2169 ("face for foreground/background colors of mouse pointer"),
|
|
2170 Qnil);
|
|
2171 }
|