Mercurial > hg > xemacs-beta
comparison src/faces.c @ 2865:8baa2f03d853
[xemacs-hg @ 2005-07-19 09:45:00 by didierv]
Face aliasing feature
author | didierv |
---|---|
date | Tue, 19 Jul 2005 09:45:23 +0000 |
parents | 6fa9919a9a0b |
children | abbd4c295aa2 |
comparison
equal
deleted
inserted
replaced
2864:97c8b3b7213a | 2865:8baa2f03d853 |
---|---|
57 Lisp_Object Vleft_margin_face, Vright_margin_face, Vtext_cursor_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; | 58 Lisp_Object Vpointer_face, Vvertical_divider_face, Vtoolbar_face, Vwidget_face; |
59 | 59 |
60 /* Qdefault, Qhighlight, Qleft_margin, Qright_margin defined in general.c */ | 60 /* Qdefault, Qhighlight, Qleft_margin, Qright_margin defined in general.c */ |
61 Lisp_Object Qmodeline, Qgui_element, Qtext_cursor, Qvertical_divider; | 61 Lisp_Object Qmodeline, Qgui_element, Qtext_cursor, Qvertical_divider; |
62 | |
63 Lisp_Object Qface_alias, Qcyclic_face_aliasing; | |
62 | 64 |
63 /* In the old implementation Vface_list was a list of the face names, | 65 /* In the old implementation Vface_list was a list of the face names, |
64 not the faces themselves. We now distinguish between permanent and | 66 not the faces themselves. We now distinguish between permanent and |
65 temporary faces. Permanent faces are kept in a regular hash table, | 67 temporary faces. Permanent faces are kept in a regular hash table, |
66 temporary faces in a weak hash table. */ | 68 temporary faces in a weak hash table. */ |
627 nil is returned. Otherwise the associated face object is returned. | 629 nil is returned. Otherwise the associated face object is returned. |
628 */ | 630 */ |
629 (face_or_name)) | 631 (face_or_name)) |
630 { | 632 { |
631 Lisp_Object retval; | 633 Lisp_Object retval; |
634 Lisp_Object face_name; | |
635 Lisp_Object face_alias; | |
636 int i; | |
632 | 637 |
633 if (FACEP (face_or_name)) | 638 if (FACEP (face_or_name)) |
634 return face_or_name; | 639 return face_or_name; |
635 CHECK_SYMBOL (face_or_name); | 640 |
641 face_name = face_or_name; | |
642 CHECK_SYMBOL (face_name); | |
643 | |
644 # define FACE_ALIASING_MAX_DEPTH 32 | |
645 | |
646 i = 0; | |
647 while (! NILP ((face_alias = Fget (face_name, Qface_alias, Qnil))) | |
648 && i < FACE_ALIASING_MAX_DEPTH) | |
649 { | |
650 face_name = face_alias; | |
651 CHECK_SYMBOL (face_alias); | |
652 i += 1; | |
653 } | |
654 | |
655 /* #### This test actually makes the aliasing max depth to 30, which is more | |
656 #### than enough IMO. -- dvl */ | |
657 if (i == FACE_ALIASING_MAX_DEPTH) | |
658 signal_error (Qcyclic_face_aliasing, | |
659 "Max face aliasing depth reached", | |
660 face_name); | |
661 | |
662 # undef FACE_ALIASING_MAX_DEPTH | |
636 | 663 |
637 /* Check if the name represents a permanent face. */ | 664 /* Check if the name represents a permanent face. */ |
638 retval = Fgethash (face_or_name, Vpermanent_faces_cache, Qnil); | 665 retval = Fgethash (face_name, Vpermanent_faces_cache, Qnil); |
639 if (!NILP (retval)) | 666 if (!NILP (retval)) |
640 return retval; | 667 return retval; |
641 | 668 |
642 /* Check if the name represents a temporary face. */ | 669 /* Check if the name represents a temporary face. */ |
643 return Fgethash (face_or_name, Vtemporary_faces_cache, Qnil); | 670 return Fgethash (face_name, Vtemporary_faces_cache, Qnil); |
644 } | 671 } |
645 | 672 |
646 DEFUN ("get-face", Fget_face, 1, 1, 0, /* | 673 DEFUN ("get-face", Fget_face, 1, 1, 0, /* |
647 Retrieve the face of the given name. | 674 Retrieve the face of the given name. |
648 Same as `find-face' except an error is signalled if there is no such | 675 Same as `find-face' except an error is signalled if there is no such |
1862 DEFSYMBOL (Qstrikethru); | 1889 DEFSYMBOL (Qstrikethru); |
1863 /* Qhighlight, Qreverse defined in general.c */ | 1890 /* Qhighlight, Qreverse defined in general.c */ |
1864 DEFSYMBOL (Qdim); | 1891 DEFSYMBOL (Qdim); |
1865 DEFSYMBOL (Qblinking); | 1892 DEFSYMBOL (Qblinking); |
1866 | 1893 |
1894 DEFSYMBOL (Qface_alias); | |
1895 DEFERROR_STANDARD (Qcyclic_face_aliasing, Qinvalid_state); | |
1896 | |
1867 DEFSYMBOL (Qinit_face_from_resources); | 1897 DEFSYMBOL (Qinit_face_from_resources); |
1868 DEFSYMBOL (Qinit_global_faces); | 1898 DEFSYMBOL (Qinit_global_faces); |
1869 DEFSYMBOL (Qinit_device_faces); | 1899 DEFSYMBOL (Qinit_device_faces); |
1870 DEFSYMBOL (Qinit_frame_faces); | 1900 DEFSYMBOL (Qinit_frame_faces); |
1871 } | 1901 } |
1975 support is compiled in. */ | 2005 support is compiled in. */ |
1976 { | 2006 { |
1977 Lisp_Object inst_list = Qnil; | 2007 Lisp_Object inst_list = Qnil; |
1978 | 2008 |
1979 #if defined (HAVE_X_WINDOWS) || defined (HAVE_GTK) | 2009 #if defined (HAVE_X_WINDOWS) || defined (HAVE_GTK) |
1980 | 2010 |
1981 const Ascbyte *fonts[] = | 2011 const Ascbyte *fonts[] = |
1982 { | 2012 { |
1983 /************** ISO-8859 fonts *************/ | 2013 /************** ISO-8859 fonts *************/ |
1984 | 2014 |
1985 "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*", | 2015 "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-*", |
2014 | 2044 |
2015 /* Following 3 fonts proposed by Teruhiko.Kurosaka@Japan.eng.sun */ | 2045 /* Following 3 fonts proposed by Teruhiko.Kurosaka@Japan.eng.sun */ |
2016 "-sun-gothic-medium-r-normal--14-120-75-75-c-60-jisx0201.1976-0", | 2046 "-sun-gothic-medium-r-normal--14-120-75-75-c-60-jisx0201.1976-0", |
2017 "-sun-gothic-medium-r-normal--14-120-75-75-c-120-jisx0208.1983-0", | 2047 "-sun-gothic-medium-r-normal--14-120-75-75-c-120-jisx0208.1983-0", |
2018 "-wadalab-gothic-medium-r-normal--14-120-75-75-c-120-jisx0212.1990-0", | 2048 "-wadalab-gothic-medium-r-normal--14-120-75-75-c-120-jisx0212.1990-0", |
2019 | 2049 |
2020 /* Other Japanese fonts */ | 2050 /* Other Japanese fonts */ |
2021 "-*-fixed-medium-r-*--*-jisx0201.1976-*", | 2051 "-*-fixed-medium-r-*--*-jisx0201.1976-*", |
2022 "-*-fixed-medium-r-*--*-jisx0208.1983-*", | 2052 "-*-fixed-medium-r-*--*-jisx0208.1983-*", |
2023 "-*-fixed-medium-r-*--*-jisx0212*-*", | 2053 "-*-fixed-medium-r-*--*-jisx0212*-*", |
2024 "-*-*-*-r-*--*-jisx0201.1976-*", | 2054 "-*-*-*-r-*--*-jisx0201.1976-*", |
2027 | 2057 |
2028 /************* Chinese fonts ************/ | 2058 /************* Chinese fonts ************/ |
2029 | 2059 |
2030 "-*-*-medium-r-*--*-gb2312.1980-*", | 2060 "-*-*-medium-r-*--*-gb2312.1980-*", |
2031 "-*-fixed-medium-r-*--*-cns11643*-*", | 2061 "-*-fixed-medium-r-*--*-cns11643*-*", |
2032 | 2062 |
2033 "-*-fixed-medium-r-*--*-big5*-*," | 2063 "-*-fixed-medium-r-*--*-big5*-*," |
2034 "-*-fixed-medium-r-*--*-sisheng_cwnn-0", | 2064 "-*-fixed-medium-r-*--*-sisheng_cwnn-0", |
2035 | 2065 |
2036 /************* Korean fonts *************/ | 2066 /************* Korean fonts *************/ |
2037 | 2067 |
2040 /************* Thai fonts **************/ | 2070 /************* Thai fonts **************/ |
2041 | 2071 |
2042 "-*-fixed-medium-r-*--*-tis620.2529-1", | 2072 "-*-fixed-medium-r-*--*-tis620.2529-1", |
2043 | 2073 |
2044 /************* Other fonts (nonstandard) *************/ | 2074 /************* Other fonts (nonstandard) *************/ |
2045 | 2075 |
2046 "-*-fixed-medium-r-*--*-viscii1.1-1", | 2076 "-*-fixed-medium-r-*--*-viscii1.1-1", |
2047 "-*-fixed-medium-r-*--*-mulearabic-*", | 2077 "-*-fixed-medium-r-*--*-mulearabic-*", |
2048 "-*-fixed-medium-r-*--*-muleipa-*", | 2078 "-*-fixed-medium-r-*--*-muleipa-*", |
2049 "-*-fixed-medium-r-*--*-ethio-*", | 2079 "-*-fixed-medium-r-*--*-ethio-*", |
2050 | 2080 |
2135 "Courier New:Regular:10::", | 2165 "Courier New:Regular:10::", |
2136 "Courier:Regular:10::", | 2166 "Courier:Regular:10::", |
2137 ":Regular:10::" | 2167 ":Regular:10::" |
2138 }; | 2168 }; |
2139 const Ascbyte **mswfontptr; | 2169 const Ascbyte **mswfontptr; |
2140 | 2170 |
2141 for (mswfontptr = mswfonts + countof (mswfonts) - 1; | 2171 for (mswfontptr = mswfonts + countof (mswfonts) - 1; |
2142 mswfontptr >= mswfonts; mswfontptr--) | 2172 mswfontptr >= mswfonts; mswfontptr--) |
2143 { | 2173 { |
2144 /* display device */ | 2174 /* display device */ |
2145 inst_list = Fcons (Fcons (list1 (Qmswindows), | 2175 inst_list = Fcons (Fcons (list1 (Qmswindows), |
2146 build_string (*mswfontptr)), | 2176 build_string (*mswfontptr)), |
2147 inst_list); | 2177 inst_list); |
2148 /* printer device */ | 2178 /* printer device */ |
2149 inst_list = Fcons (Fcons (list1 (Qmsprinter), | 2179 inst_list = Fcons (Fcons (list1 (Qmsprinter), |
2150 build_string (*mswfontptr)), | 2180 build_string (*mswfontptr)), |
2151 inst_list); | 2181 inst_list); |
2152 } | 2182 } |
2153 /* Use Lucida Console rather than Courier New if it exists -- the | 2183 /* Use Lucida Console rather than Courier New if it exists -- the |
2154 line spacing is much less, so many more lines fit with the same | 2184 line spacing is much less, so many more lines fit with the same |
2155 size font. (And it's specifically designed for screens.) */ | 2185 size font. (And it's specifically designed for screens.) */ |
2156 inst_list = Fcons (Fcons (list1 (Qmswindows), | 2186 inst_list = Fcons (Fcons (list1 (Qmswindows), |
2157 build_string ("Lucida Console:Regular:10::")), | 2187 build_string ("Lucida Console:Regular:10::")), |
2158 inst_list); | 2188 inst_list); |
2159 } | 2189 } |
2160 #endif /* HAVE_MS_WINDOWS */ | 2190 #endif /* HAVE_MS_WINDOWS */ |
2161 | 2191 |