comparison src/faces.c @ 183:e121b013d1f0 r20-3b18

Import from CVS: tag r20-3b18
author cvs
date Mon, 13 Aug 2007 09:54:23 +0200
parents bfd6434d15b3
children 3d6bfa290dbd
comparison
equal deleted inserted replaced
182:f07455f06202 183:e121b013d1f0
154 struct Lisp_Face *f1 = XFACE (o1); 154 struct Lisp_Face *f1 = XFACE (o1);
155 struct Lisp_Face *f2 = XFACE (o2); 155 struct Lisp_Face *f2 = XFACE (o2);
156 156
157 depth++; 157 depth++;
158 158
159 if (!internal_equal (f1->foreground, f2->foreground, depth) || 159 return
160 !internal_equal (f1->background, f2->background, depth) || 160 (internal_equal (f1->foreground, f2->foreground, depth) &&
161 !internal_equal (f1->font, f2->font, depth) || 161 internal_equal (f1->background, f2->background, depth) &&
162 !internal_equal (f1->display_table, f2->display_table, depth) || 162 internal_equal (f1->font, f2->font, depth) &&
163 !internal_equal (f1->background_pixmap, f2->background_pixmap, depth) || 163 internal_equal (f1->display_table, f2->display_table, depth) &&
164 !internal_equal (f1->underline, f2->underline, depth) || 164 internal_equal (f1->background_pixmap, f2->background_pixmap, depth) &&
165 !internal_equal (f1->strikethru, f2->strikethru, depth) || 165 internal_equal (f1->underline, f2->underline, depth) &&
166 !internal_equal (f1->highlight, f2->highlight, depth) || 166 internal_equal (f1->strikethru, f2->strikethru, depth) &&
167 !internal_equal (f1->dim, f2->dim, depth) || 167 internal_equal (f1->highlight, f2->highlight, depth) &&
168 !internal_equal (f1->blinking, f2->blinking, depth) || 168 internal_equal (f1->dim, f2->dim, depth) &&
169 !internal_equal (f1->reverse, f2->reverse, depth) || 169 internal_equal (f1->blinking, f2->blinking, depth) &&
170 plists_differ (f1->plist, f2->plist, 0, 0, depth + 1)) 170 internal_equal (f1->reverse, f2->reverse, depth) &&
171 return 0; 171
172 172 ! plists_differ (f1->plist, f2->plist, 0, 0, depth + 1));
173 return 1;
174 } 173 }
175 174
176 static unsigned long 175 static unsigned long
177 face_hash (Lisp_Object obj, int depth) 176 face_hash (Lisp_Object obj, int depth)
178 { 177 {
182 181
183 /* No need to hash all of the elements; that would take too long. 182 /* No need to hash all of the elements; that would take too long.
184 Just hash the most common ones. */ 183 Just hash the most common ones. */
185 return HASH3 (internal_hash (f->foreground, depth), 184 return HASH3 (internal_hash (f->foreground, depth),
186 internal_hash (f->background, depth), 185 internal_hash (f->background, depth),
187 internal_hash (f->font, depth)); 186 internal_hash (f->font, depth));
188 } 187 }
189 188
190 static Lisp_Object 189 static Lisp_Object
191 face_getprop (Lisp_Object obj, Lisp_Object prop) 190 face_getprop (Lisp_Object obj, Lisp_Object prop)
192 { 191 {
193 struct Lisp_Face *f = XFACE (obj); 192 struct Lisp_Face *f = XFACE (obj);
194 193
195 #define FROB(propprop) \ 194 return
196 do { \ 195 ((EQ (prop, Qforeground)) ? f->foreground :
197 if (EQ (prop, Q##propprop)) \ 196 (EQ (prop, Qbackground)) ? f->background :
198 { \ 197 (EQ (prop, Qfont)) ? f->font :
199 return f->propprop; \ 198 (EQ (prop, Qdisplay_table)) ? f->display_table :
200 } \ 199 (EQ (prop, Qbackground_pixmap)) ? f->background_pixmap :
201 } while (0) 200 (EQ (prop, Qunderline)) ? f->underline :
202 201 (EQ (prop, Qstrikethru)) ? f->strikethru :
203 FROB (foreground); 202 (EQ (prop, Qhighlight)) ? f->highlight :
204 FROB (background); 203 (EQ (prop, Qdim)) ? f->dim :
205 FROB (font); 204 (EQ (prop, Qblinking)) ? f->blinking :
206 FROB (display_table); 205 (EQ (prop, Qreverse)) ? f->reverse :
207 FROB (background_pixmap); 206 (EQ (prop, Qdoc_string)) ? f->doc_string :
208 FROB (underline); 207 external_plist_get (&f->plist, prop, 0, ERROR_ME));
209 FROB (strikethru);
210 FROB (highlight);
211 FROB (dim);
212 FROB (blinking);
213 FROB (reverse);
214 FROB (doc_string);
215
216 #undef FROB
217
218 return external_plist_get (&f->plist, prop, 0, ERROR_ME);
219 } 208 }
220 209
221 static int 210 static int
222 face_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value) 211 face_putprop (Lisp_Object obj, Lisp_Object prop, Lisp_Object value)
223 { 212 {
224 struct Lisp_Face *f = XFACE (obj); 213 struct Lisp_Face *f = XFACE (obj);
225 214
226 #define FROB(propprop) \ 215 if (EQ (prop, Qforeground) ||
227 do { \ 216 EQ (prop, Qbackground) ||
228 if (EQ (prop, Q##propprop)) \ 217 EQ (prop, Qfont) ||
229 return 0; \ 218 EQ (prop, Qdisplay_table) ||
230 } while (0) 219 EQ (prop, Qbackground_pixmap) ||
231 220 EQ (prop, Qunderline) ||
232 FROB (foreground); 221 EQ (prop, Qstrikethru) ||
233 FROB (background); 222 EQ (prop, Qhighlight) ||
234 FROB (font); 223 EQ (prop, Qdim) ||
235 FROB (display_table); 224 EQ (prop, Qblinking) ||
236 FROB (background_pixmap); 225 EQ (prop, Qreverse))
237 FROB (underline); 226 return 0;
238 FROB (strikethru);
239 FROB (highlight);
240 FROB (dim);
241 FROB (blinking);
242 FROB (reverse);
243
244 #undef FROB
245 227
246 if (EQ (prop, Qdoc_string)) 228 if (EQ (prop, Qdoc_string))
247 { 229 {
248 if (!NILP (value)) 230 if (!NILP (value))
249 CHECK_STRING (value); 231 CHECK_STRING (value);
258 static int 240 static int
259 face_remprop (Lisp_Object obj, Lisp_Object prop) 241 face_remprop (Lisp_Object obj, Lisp_Object prop)
260 { 242 {
261 struct Lisp_Face *f = XFACE (obj); 243 struct Lisp_Face *f = XFACE (obj);
262 244
263 #define FROB(propprop) \ 245 if (EQ (prop, Qforeground) ||
264 do { \ 246 EQ (prop, Qbackground) ||
265 if (EQ (prop, Q##propprop)) \ 247 EQ (prop, Qfont) ||
266 return -1; \ 248 EQ (prop, Qdisplay_table) ||
267 } while (0) 249 EQ (prop, Qbackground_pixmap) ||
268 250 EQ (prop, Qunderline) ||
269 FROB (foreground); 251 EQ (prop, Qstrikethru) ||
270 FROB (background); 252 EQ (prop, Qhighlight) ||
271 FROB (font); 253 EQ (prop, Qdim) ||
272 FROB (display_table); 254 EQ (prop, Qblinking) ||
273 FROB (background_pixmap); 255 EQ (prop, Qreverse))
274 FROB (underline); 256 return -1;
275 FROB (strikethru);
276 FROB (highlight);
277 FROB (dim);
278 FROB (blinking);
279 FROB (reverse);
280
281 #undef FROB
282 257
283 if (EQ (prop, Qdoc_string)) 258 if (EQ (prop, Qdoc_string))
284 { 259 {
285 f->doc_string = Qnil; 260 f->doc_string = Qnil;
286 return 1; 261 return 1;
293 face_plist (Lisp_Object obj) 268 face_plist (Lisp_Object obj)
294 { 269 {
295 struct Lisp_Face *f = XFACE (obj); 270 struct Lisp_Face *f = XFACE (obj);
296 Lisp_Object result = Qnil; 271 Lisp_Object result = Qnil;
297 272
298 #define FROB(propprop) \ 273 /* backwards order; we reverse it below */
299 do { \ 274 result = Fcons (f->foreground, Fcons (Qforeground, result));
300 /* backwards order; we reverse it below */ \ 275 result = Fcons (f->background, Fcons (Qbackground, result));
301 result = Fcons (f->propprop, Fcons (Q##propprop, result)); \ 276 result = Fcons (f->font, Fcons (Qfont, result));
302 } while (0) 277 result = Fcons (f->display_table, Fcons (Qdisplay_table, result));
303 278 result = Fcons (f->background_pixmap, Fcons (Qbackground_pixmap, result));
304 FROB (foreground); 279 result = Fcons (f->underline, Fcons (Qunderline, result));
305 FROB (background); 280 result = Fcons (f->strikethru, Fcons (Qstrikethru, result));
306 FROB (font); 281 result = Fcons (f->highlight, Fcons (Qhighlight, result));
307 FROB (display_table); 282 result = Fcons (f->dim, Fcons (Qdim, result));
308 FROB (background_pixmap); 283 result = Fcons (f->blinking, Fcons (Qblinking, result));
309 FROB (underline); 284 result = Fcons (f->reverse, Fcons (Qreverse, result));
310 FROB (strikethru); 285
311 FROB (highlight);
312 FROB (dim);
313 FROB (blinking);
314 FROB (reverse);
315
316 #undef FROB
317 return nconc2 (Fnreverse (result), f->plist); 286 return nconc2 (Fnreverse (result), f->plist);
318 } 287 }
319 288
320 289
321 /************************************************************************/ 290 /************************************************************************/
518 487
519 for (elt = FACE_PROPERTY_SPEC_LIST (cur_face, property, Qall); 488 for (elt = FACE_PROPERTY_SPEC_LIST (cur_face, property, Qall);
520 !NILP (elt); 489 !NILP (elt);
521 elt = XCDR (elt)) 490 elt = XCDR (elt))
522 { 491 {
523 Lisp_Object locale, values; 492 Lisp_Object values = XCDR (XCAR (elt));
524
525 locale = XCAR (XCAR (elt));
526 values = XCDR (XCAR (elt));
527 493
528 for (; !NILP (values); values = XCDR (values)) 494 for (; !NILP (values); values = XCDR (values))
529 { 495 {
530 Lisp_Object value = XCDR (XCAR (values)); 496 Lisp_Object value = XCDR (XCAR (values));
531 if (VECTORP (value) && XVECTOR_LENGTH (value)) 497 if (VECTORP (value) && XVECTOR_LENGTH (value))
552 518
553 if (EQ (fcl->property, Qfont)) 519 if (EQ (fcl->property, Qfont))
554 { 520 {
555 update_inheritance_mapper_internal (contents, fcl->face, Qfont); 521 update_inheritance_mapper_internal (contents, fcl->face, Qfont);
556 } 522 }
557 else if (EQ (fcl->property, Qforeground) 523 else if (EQ (fcl->property, Qforeground) ||
558 || EQ (fcl->property, Qbackground)) 524 EQ (fcl->property, Qbackground))
559 { 525 {
560 update_inheritance_mapper_internal (contents, fcl->face, Qforeground); 526 update_inheritance_mapper_internal (contents, fcl->face, Qforeground);
561 update_inheritance_mapper_internal (contents, fcl->face, Qbackground); 527 update_inheritance_mapper_internal (contents, fcl->face, Qbackground);
562 } 528 }
563 else if (EQ (fcl->property, Qunderline) 529 else if (EQ (fcl->property, Qunderline) ||
564 || EQ (fcl->property, Qstrikethru) 530 EQ (fcl->property, Qstrikethru) ||
565 || EQ (fcl->property, Qhighlight) 531 EQ (fcl->property, Qhighlight) ||
566 || EQ (fcl->property, Qdim) 532 EQ (fcl->property, Qdim) ||
567 || EQ (fcl->property, Qblinking) 533 EQ (fcl->property, Qblinking) ||
568 || EQ (fcl->property, Qreverse)) 534 EQ (fcl->property, Qreverse))
569 { 535 {
570 update_inheritance_mapper_internal (contents, fcl->face, Qunderline); 536 update_inheritance_mapper_internal (contents, fcl->face, Qunderline);
571 update_inheritance_mapper_internal (contents, fcl->face, Qstrikethru); 537 update_inheritance_mapper_internal (contents, fcl->face, Qstrikethru);
572 update_inheritance_mapper_internal (contents, fcl->face, Qhighlight); 538 update_inheritance_mapper_internal (contents, fcl->face, Qhighlight);
573 update_inheritance_mapper_internal (contents, fcl->face, Qdim); 539 update_inheritance_mapper_internal (contents, fcl->face, Qdim);
1159 1125
1160 for (i = 0; i < NUM_LEADING_BYTES; i++) 1126 for (i = 0; i < NUM_LEADING_BYTES; i++)
1161 { 1127 {
1162 if (charsets[i]) 1128 if (charsets[i])
1163 { 1129 {
1164 Lisp_Object charset; 1130 Lisp_Object charset = CHARSET_BY_LEADING_BYTE (i + MIN_LEADING_BYTE);
1165 Lisp_Object font_instance; 1131 Lisp_Object font_instance = FACE_CACHEL_FONT (cachel, charset);
1166 struct Lisp_Font_Instance *fi; 1132 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font_instance);
1167 1133
1168 charset = CHARSET_BY_LEADING_BYTE (i + MIN_LEADING_BYTE);
1169 assert (CHARSETP (charset)); 1134 assert (CHARSETP (charset));
1170 font_instance = FACE_CACHEL_FONT (cachel, charset);
1171 assert (FONT_INSTANCEP (font_instance)); 1135 assert (FONT_INSTANCEP (font_instance));
1172 fi = XFONT_INSTANCE (font_instance); 1136
1173 fm->ascent = max ((int) fi->ascent, (int) fm->ascent); 1137 if (fm->ascent < (int) fi->ascent) fm->ascent = (int) fi->ascent;
1174 fm->descent = max ((int) fi->descent, (int) fm->descent); 1138 if (fm->descent < (int) fi->descent) fm->descent = (int) fi->descent;
1175 fm->height = fm->ascent + fm->descent; 1139 fm->height = fm->ascent + fm->descent;
1176 if (fi->proportional_p) 1140 if (fi->proportional_p)
1177 fm->proportional_p = 1; 1141 fm->proportional_p = 1;
1178 if (EQ (charset, Vcharset_ascii)) 1142 if (EQ (charset, Vcharset_ascii))
1179 fm->width = fi->width; 1143 fm->width = fi->width;
1648 /* Setting the background clears the entire frame area 1612 /* Setting the background clears the entire frame area
1649 including the toolbar so we force an immediate redraw of 1613 including the toolbar so we force an immediate redraw of
1650 it. */ 1614 it. */
1651 if (EQ (name, Qbackground)) 1615 if (EQ (name, Qbackground))
1652 MAYBE_DEVMETH (XDEVICE (frm->device), redraw_frame_toolbars, (frm)); 1616 MAYBE_DEVMETH (XDEVICE (frm->device), redraw_frame_toolbars, (frm));
1653 #endif 1617 #endif /* HAVE_TOOLBARS */
1654 1618
1655 /* The intent of this code is to cause the frame size in 1619 /* The intent of this code is to cause the frame size in
1656 characters to remain the same when the font changes, at the 1620 characters to remain the same when the font changes, at the
1657 expense of changing the frame size in pixels. It's not 1621 expense of changing the frame size in pixels. It's not
1658 totally clear that this is the right thing to do, but it's 1622 totally clear that this is the right thing to do, but it's
1756 1720
1757 /* We GCPRO old_face because it might be temporary, and GCing could 1721 /* We GCPRO old_face because it might be temporary, and GCing could
1758 occur in various places below. */ 1722 occur in various places below. */
1759 GCPRO4 (tag_set, locale, old_face, new_face); 1723 GCPRO4 (tag_set, locale, old_face, new_face);
1760 /* check validity of how_to_add now. */ 1724 /* check validity of how_to_add now. */
1761 (void) decode_how_to_add_specification (how_to_add); 1725 decode_how_to_add_specification (how_to_add);
1762 /* and of tag_set. */ 1726 /* and of tag_set. */
1763 tag_set = decode_specifier_tag_set (tag_set); 1727 tag_set = decode_specifier_tag_set (tag_set);
1764 /* and of locale. */ 1728 /* and of locale. */
1765 locale = decode_locale_list (locale); 1729 locale = decode_locale_list (locale);
1766 1730
1938 /* #### We may want to have different fallback values if NeXTstep 1902 /* #### We may want to have different fallback values if NeXTstep
1939 support is compiled in. */ 1903 support is compiled in. */
1940 { 1904 {
1941 Lisp_Object inst_list = Qnil; 1905 Lisp_Object inst_list = Qnil;
1942 #ifdef HAVE_X_WINDOWS 1906 #ifdef HAVE_X_WINDOWS
1943 CONST char *fonts[30];
1944 int n = 0;
1945
1946 /* The same gory list from x-faces.el. 1907 /* The same gory list from x-faces.el.
1947 (#### Perhaps we should remove the stuff from x-faces.el 1908 (#### Perhaps we should remove the stuff from x-faces.el
1948 and only depend on this stuff here? That should work.) 1909 and only depend on this stuff here? That should work.)
1949 */ 1910 */
1950 fonts[n++] = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*"; 1911 CONST char *fonts[] =
1951 fonts[n++] = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*"; 1912 {
1952 fonts[n++] = "-*-courier-*-r-*-*-*-120-*-*-*-*-iso8859-*"; 1913 "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
1953 fonts[n++] = "-*-*-medium-r-*-*-*-120-*-*-m-*-iso8859-*"; 1914 "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
1954 fonts[n++] = "-*-*-medium-r-*-*-*-120-*-*-c-*-iso8859-*"; 1915 "-*-courier-*-r-*-*-*-120-*-*-*-*-iso8859-*",
1955 fonts[n++] = "-*-*-*-r-*-*-*-120-*-*-m-*-iso8859-*"; 1916 "-*-*-medium-r-*-*-*-120-*-*-m-*-iso8859-*",
1956 fonts[n++] = "-*-*-*-r-*-*-*-120-*-*-c-*-iso8859-*"; 1917 "-*-*-medium-r-*-*-*-120-*-*-c-*-iso8859-*",
1957 fonts[n++] = "-*-*-*-r-*-*-*-120-*-*-*-*-iso8859-*"; 1918 "-*-*-*-r-*-*-*-120-*-*-m-*-iso8859-*",
1958 fonts[n++] = "-*-*-medium-r-*-*-*-120-*-*-m-*-*-*"; 1919 "-*-*-*-r-*-*-*-120-*-*-c-*-iso8859-*",
1959 fonts[n++] = "-*-*-medium-r-*-*-*-120-*-*-c-*-*-*"; 1920 "-*-*-*-r-*-*-*-120-*-*-*-*-iso8859-*",
1960 fonts[n++] = "-*-*-*-r-*-*-*-120-*-*-m-*-*-*"; 1921 "-*-*-medium-r-*-*-*-120-*-*-m-*-*-*",
1961 fonts[n++] = "-*-*-*-r-*-*-*-120-*-*-c-*-*-*"; 1922 "-*-*-medium-r-*-*-*-120-*-*-c-*-*-*",
1962 fonts[n++] = "-*-*-*-r-*-*-*-120-*-*-*-*-*-*"; 1923 "-*-*-*-r-*-*-*-120-*-*-m-*-*-*",
1963 fonts[n++] = "-*-*-*-*-*-*-*-120-*-*-*-*-*-*"; 1924 "-*-*-*-r-*-*-*-120-*-*-c-*-*-*",
1964 fonts[n++] = "*"; 1925 "-*-*-*-r-*-*-*-120-*-*-*-*-*-*",
1965 1926 "-*-*-*-*-*-*-*-120-*-*-*-*-*-*",
1966 for (--n; n >= 0; --n) 1927 "*"
1967 inst_list = Fcons (Fcons (list1 (Qx), build_string (fonts[n])), 1928 };
1929 CONST char **fontptr;
1930
1931 for (fontptr = fonts + countof(fonts) - 1; fontptr >= fonts; fontptr--)
1932 inst_list = Fcons (Fcons (list1 (Qx), build_string (*fontptr)),
1968 inst_list); 1933 inst_list);
1969 #endif 1934 #endif /* HAVE_X_WINDOWS */
1935
1970 #ifdef HAVE_TTY 1936 #ifdef HAVE_TTY
1971 inst_list = Fcons (Fcons (list1 (Qtty), build_string ("normal")), 1937 inst_list = Fcons (Fcons (list1 (Qtty), build_string ("normal")),
1972 inst_list); 1938 inst_list);
1973 #endif 1939 #endif /* HAVE_TTY */
1974 set_specifier_fallback (Fget (Vdefault_face, Qfont, Qnil), inst_list); 1940 set_specifier_fallback (Fget (Vdefault_face, Qfont, Qnil), inst_list);
1975 } 1941 }
1976 1942
1977 set_specifier_fallback (Fget (Vdefault_face, Qunderline, Qnil), 1943 set_specifier_fallback (Fget (Vdefault_face, Qunderline, Qnil),
1978 list1 (Fcons (Qnil, Qnil))); 1944 list1 (Fcons (Qnil, Qnil)));