diff options
| author | Gerd Moellmann | 2000-12-06 16:53:44 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-12-06 16:53:44 +0000 |
| commit | 06a128110933c1eb7e1464df9e089dcac8bfed6b (patch) | |
| tree | 84908524bd561f3ab4022565a0fb8ec294660af3 /src | |
| parent | 347d0813d20dd091e3a1fc049baa6b499619c262 (diff) | |
| download | emacs-06a128110933c1eb7e1464df9e089dcac8bfed6b.tar.gz emacs-06a128110933c1eb7e1464df9e089dcac8bfed6b.zip | |
(underlying_face_id): New function.
(handle_face_prop, face_before_or_after_it_pos): Use it
to determine the face ``under'' a string. Let strings inherit
the face of the buffer under them.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 84 |
1 files changed, 62 insertions, 22 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 0e761ada607..2260c24059d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -759,6 +759,7 @@ static int face_before_or_after_it_pos P_ ((struct it *, int)); | |||
| 759 | static int next_overlay_change P_ ((int)); | 759 | static int next_overlay_change P_ ((int)); |
| 760 | static int handle_single_display_prop P_ ((struct it *, Lisp_Object, | 760 | static int handle_single_display_prop P_ ((struct it *, Lisp_Object, |
| 761 | Lisp_Object, struct text_pos *)); | 761 | Lisp_Object, struct text_pos *)); |
| 762 | static int underlying_face_id P_ ((struct it *)); | ||
| 762 | 763 | ||
| 763 | #define face_before_it_pos(IT) face_before_or_after_it_pos ((IT), 1) | 764 | #define face_before_it_pos(IT) face_before_or_after_it_pos ((IT), 1) |
| 764 | #define face_after_it_pos(IT) face_before_or_after_it_pos ((IT), 0) | 765 | #define face_after_it_pos(IT) face_before_or_after_it_pos ((IT), 0) |
| @@ -2138,17 +2139,28 @@ handle_face_prop (it) | |||
| 2138 | } | 2139 | } |
| 2139 | else | 2140 | else |
| 2140 | { | 2141 | { |
| 2141 | new_face_id | 2142 | int base_face_id, bufpos; |
| 2142 | = face_at_string_position (it->w, | 2143 | |
| 2143 | it->string, | 2144 | if (it->current.overlay_string_index >= 0) |
| 2144 | IT_STRING_CHARPOS (*it), | 2145 | bufpos = IT_CHARPOS (*it); |
| 2145 | (it->current.overlay_string_index >= 0 | 2146 | else |
| 2146 | ? IT_CHARPOS (*it) | 2147 | bufpos = 0; |
| 2147 | : 0), | 2148 | |
| 2148 | it->region_beg_charpos, | 2149 | /* For strings from a buffer, i.e. overlay strings or strings |
| 2149 | it->region_end_charpos, | 2150 | from a `display' property, use the face at IT's current |
| 2150 | &next_stop, | 2151 | buffer position as the base face to merge with, so that |
| 2151 | it->base_face_id); | 2152 | overlay strings appear in the same face as surrounding |
| 2153 | text, unless they specify their own faces. */ | ||
| 2154 | base_face_id = underlying_face_id (it); | ||
| 2155 | |||
| 2156 | new_face_id = face_at_string_position (it->w, | ||
| 2157 | it->string, | ||
| 2158 | IT_STRING_CHARPOS (*it), | ||
| 2159 | bufpos, | ||
| 2160 | it->region_beg_charpos, | ||
| 2161 | it->region_end_charpos, | ||
| 2162 | &next_stop, | ||
| 2163 | base_face_id); | ||
| 2152 | 2164 | ||
| 2153 | #if 0 /* This shouldn't be neccessary. Let's check it. */ | 2165 | #if 0 /* This shouldn't be neccessary. Let's check it. */ |
| 2154 | /* If IT is used to display a mode line we would really like to | 2166 | /* If IT is used to display a mode line we would really like to |
| @@ -2184,6 +2196,27 @@ handle_face_prop (it) | |||
| 2184 | } | 2196 | } |
| 2185 | 2197 | ||
| 2186 | 2198 | ||
| 2199 | /* Return the ID of the face ``underlying'' IT's current position, | ||
| 2200 | which is in a string. If the iterator is associated with a | ||
| 2201 | buffer, return the face at IT's current buffer position. | ||
| 2202 | Otherwise, use the iterator's base_face_id. */ | ||
| 2203 | |||
| 2204 | static int | ||
| 2205 | underlying_face_id (it) | ||
| 2206 | struct it *it; | ||
| 2207 | { | ||
| 2208 | int face_id = it->base_face_id, i; | ||
| 2209 | |||
| 2210 | xassert (STRINGP (it->string)); | ||
| 2211 | |||
| 2212 | for (i = it->sp - 1; i >= 0; --i) | ||
| 2213 | if (NILP (it->stack[i].string)) | ||
| 2214 | face_id = it->stack[i].face_id; | ||
| 2215 | |||
| 2216 | return face_id; | ||
| 2217 | } | ||
| 2218 | |||
| 2219 | |||
| 2187 | /* Compute the face one character before or after the current position | 2220 | /* Compute the face one character before or after the current position |
| 2188 | of IT. BEFORE_P non-zero means get the face in front of IT's | 2221 | of IT. BEFORE_P non-zero means get the face in front of IT's |
| 2189 | position. Value is the id of the face. */ | 2222 | position. Value is the id of the face. */ |
| @@ -2201,6 +2234,8 @@ face_before_or_after_it_pos (it, before_p) | |||
| 2201 | 2234 | ||
| 2202 | if (STRINGP (it->string)) | 2235 | if (STRINGP (it->string)) |
| 2203 | { | 2236 | { |
| 2237 | int bufpos, base_face_id; | ||
| 2238 | |||
| 2204 | /* No face change past the end of the string (for the case | 2239 | /* No face change past the end of the string (for the case |
| 2205 | we are padding with spaces). No face change before the | 2240 | we are padding with spaces). No face change before the |
| 2206 | string start. */ | 2241 | string start. */ |
| @@ -2218,18 +2253,22 @@ face_before_or_after_it_pos (it, before_p) | |||
| 2218 | ? string_pos (IT_STRING_CHARPOS (*it) + it->cmp_len, it->string) | 2253 | ? string_pos (IT_STRING_CHARPOS (*it) + it->cmp_len, it->string) |
| 2219 | : string_pos (IT_STRING_CHARPOS (*it) + 1, it->string)); | 2254 | : string_pos (IT_STRING_CHARPOS (*it) + 1, it->string)); |
| 2220 | 2255 | ||
| 2256 | if (it->current.overlay_string_index >= 0) | ||
| 2257 | bufpos = IT_CHARPOS (*it); | ||
| 2258 | else | ||
| 2259 | bufpos = 0; | ||
| 2260 | |||
| 2261 | base_face_id = underlying_face_id (it); | ||
| 2262 | |||
| 2221 | /* Get the face for ASCII, or unibyte. */ | 2263 | /* Get the face for ASCII, or unibyte. */ |
| 2222 | face_id | 2264 | face_id = face_at_string_position (it->w, |
| 2223 | = face_at_string_position (it->w, | 2265 | it->string, |
| 2224 | it->string, | 2266 | CHARPOS (pos), |
| 2225 | CHARPOS (pos), | 2267 | bufpos, |
| 2226 | (it->current.overlay_string_index >= 0 | 2268 | it->region_beg_charpos, |
| 2227 | ? IT_CHARPOS (*it) | 2269 | it->region_end_charpos, |
| 2228 | : 0), | 2270 | &next_check_charpos, |
| 2229 | it->region_beg_charpos, | 2271 | base_face_id); |
| 2230 | it->region_end_charpos, | ||
| 2231 | &next_check_charpos, | ||
| 2232 | it->base_face_id); | ||
| 2233 | 2272 | ||
| 2234 | /* Correct the face for charsets different from ASCII. Do it | 2273 | /* Correct the face for charsets different from ASCII. Do it |
| 2235 | for the multibyte case only. The face returned above is | 2274 | for the multibyte case only. The face returned above is |
| @@ -2265,6 +2304,7 @@ face_before_or_after_it_pos (it, before_p) | |||
| 2265 | else | 2304 | else |
| 2266 | INC_TEXT_POS (pos, it->multibyte_p); | 2305 | INC_TEXT_POS (pos, it->multibyte_p); |
| 2267 | } | 2306 | } |
| 2307 | |||
| 2268 | /* Determine face for CHARSET_ASCII, or unibyte. */ | 2308 | /* Determine face for CHARSET_ASCII, or unibyte. */ |
| 2269 | face_id = face_at_buffer_position (it->w, | 2309 | face_id = face_at_buffer_position (it->w, |
| 2270 | CHARPOS (pos), | 2310 | CHARPOS (pos), |