Mercurial > emacs
comparison src/xdisp.c @ 5800:295e342614a4
(fix_glyph): New function.
(display_text_line, display_string): Use fix_glyph.
(copy_rope): Function deleted.
(copy_part_of_rope): Merge the glyph's face using compute_glyph_face.
Take frame as additional arg.
(display_text_line): Use copy_part_of_rope always, not copy_rope.
Pass the frame as arg.
(display_string): Likewise.
(display_count_lines): Pass new arg to scan_buffer.
(display_menu_bar): Pass explicit max arg to display_string.
(display_string): New arg OBEY_WINDOW_WIDTH. All callers changed.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 06 Feb 1994 08:04:54 +0000 |
parents | 0709eb474647 |
children | 13cb3226cb41 |
comparison
equal
deleted
inserted
replaced
5799:13d7ce941848 | 5800:295e342614a4 |
---|---|
397 vpos = XFASTINT (XWINDOW (minibuf_window)->top); | 397 vpos = XFASTINT (XWINDOW (minibuf_window)->top); |
398 get_display_line (f, vpos, 0); | 398 get_display_line (f, vpos, 0); |
399 display_string (XWINDOW (minibuf_window), vpos, | 399 display_string (XWINDOW (minibuf_window), vpos, |
400 echo_area_glyphs ? echo_area_glyphs : "", | 400 echo_area_glyphs ? echo_area_glyphs : "", |
401 echo_area_glyphs ? echo_area_glyphs_length : -1, | 401 echo_area_glyphs ? echo_area_glyphs_length : -1, |
402 0, 0, 0, FRAME_WIDTH (f)); | 402 0, 0, 0, 0, FRAME_WIDTH (f)); |
403 | 403 |
404 /* If desired cursor location is on this line, put it at end of text */ | 404 /* If desired cursor location is on this line, put it at end of text */ |
405 if (FRAME_CURSOR_Y (f) == vpos) | 405 if (FRAME_CURSOR_Y (f) == vpos) |
406 FRAME_CURSOR_X (f) = FRAME_DESIRED_GLYPHS (f)->used[vpos]; | 406 FRAME_CURSOR_X (f) = FRAME_DESIRED_GLYPHS (f)->used[vpos]; |
407 | 407 |
412 for (i = vpos + 1; | 412 for (i = vpos + 1; |
413 i < vpos + XFASTINT (XWINDOW (minibuf_window)->height); i++) | 413 i < vpos + XFASTINT (XWINDOW (minibuf_window)->height); i++) |
414 { | 414 { |
415 get_display_line (f, i, 0); | 415 get_display_line (f, i, 0); |
416 display_string (XWINDOW (minibuf_window), vpos, | 416 display_string (XWINDOW (minibuf_window), vpos, |
417 "", 0, 0, 0, 0, FRAME_WIDTH (f)); | 417 "", 0, 0, 0, 0, 0, FRAME_WIDTH (f)); |
418 } | 418 } |
419 } | 419 } |
420 } | 420 } |
421 else if (!EQ (minibuf_window, selected_window)) | 421 else if (!EQ (minibuf_window, selected_window)) |
422 windows_or_buffers_changed++; | 422 windows_or_buffers_changed++; |
1044 int i; | 1044 int i; |
1045 | 1045 |
1046 for (i = 0; i < height; i++) | 1046 for (i = 0; i < height; i++) |
1047 { | 1047 { |
1048 get_display_line (f, vpos + i, 0); | 1048 get_display_line (f, vpos + i, 0); |
1049 display_string (w, vpos + i, "", 0, 0, 0, 0, width); | 1049 display_string (w, vpos + i, "", 0, 0, 0, 1, 0, width); |
1050 } | 1050 } |
1051 | 1051 |
1052 goto finish_scroll_bars; | 1052 goto finish_scroll_bars; |
1053 } | 1053 } |
1054 } | 1054 } |
1821 | 1821 |
1822 BUF_MODIFF (buf) ++; | 1822 BUF_MODIFF (buf) ++; |
1823 } | 1823 } |
1824 | 1824 |
1825 | 1825 |
1826 /* Copy glyphs from the vector FROM to the rope T. | 1826 /* Copy LEN glyphs starting address FROM to the rope TO. |
1827 But don't actually copy the parts that would come in before S. | 1827 But don't actually copy the parts that would come in before S. |
1828 Value is T, advanced past the copied data. */ | 1828 Value is TO, advanced past the copied data. |
1829 | 1829 F is the frame we are displaying in. */ |
1830 GLYPH * | 1830 |
1831 copy_rope (t, s, from, face) | 1831 static GLYPH * |
1832 register GLYPH *t; /* Copy to here. */ | 1832 copy_part_of_rope (f, to, s, from, len, face) |
1833 register GLYPH *s; /* Starting point. */ | 1833 FRAME_PTR f; |
1834 Lisp_Object from; /* Data to copy; known to be a vector. */ | 1834 register GLYPH *to; /* Copy to here. */ |
1835 int face; /* Face to apply to glyphs which don't specify one. */ | |
1836 { | |
1837 register int n = XVECTOR (from)->size; | |
1838 register Lisp_Object *f = XVECTOR (from)->contents; | |
1839 | |
1840 while (n--) | |
1841 { | |
1842 int glyph = XFASTINT (*f); | |
1843 | |
1844 if (t >= s) *t = MAKE_GLYPH (GLYPH_CHAR (glyph), | |
1845 (GLYPH_FACE (glyph) | |
1846 ? GLYPH_FACE (glyph) | |
1847 : face)); | |
1848 ++t; | |
1849 ++f; | |
1850 } | |
1851 return t; | |
1852 } | |
1853 | |
1854 /* Copy exactly LEN glyphs from FROM into data at T. | |
1855 But don't alter words before S. */ | |
1856 | |
1857 GLYPH * | |
1858 copy_part_of_rope (t, s, from, len, face) | |
1859 register GLYPH *t; /* Copy to here. */ | |
1860 register GLYPH *s; /* Starting point. */ | 1835 register GLYPH *s; /* Starting point. */ |
1861 Lisp_Object *from; /* Data to copy. */ | 1836 Lisp_Object *from; /* Data to copy. */ |
1862 int len; | 1837 int len; |
1863 int face; /* Face to apply to glyphs which don't specify one. */ | 1838 int face; /* Face to apply to glyphs which don't specify one. */ |
1864 { | 1839 { |
1865 int n = len; | 1840 int n = len; |
1866 register Lisp_Object *f = from; | 1841 register Lisp_Object *fp = from; |
1842 /* These cache the results of the last call to compute_glyph_face. */ | |
1843 int last_code = -1; | |
1844 int last_merged = 0; | |
1867 | 1845 |
1868 while (n--) | 1846 while (n--) |
1869 { | 1847 { |
1870 int glyph = XFASTINT (*f); | 1848 int glyph = XFASTINT (*fp); |
1871 | 1849 int facecode; |
1872 if (t >= s) *t = MAKE_GLYPH (GLYPH_CHAR (glyph), | 1850 |
1873 (GLYPH_FACE (glyph) | 1851 if (GLYPH_FACE (glyph) == 0) |
1874 ? GLYPH_FACE (glyph) | 1852 /* If GLYPH has no face code, use FACE. */ |
1875 : face)); | 1853 facecode = face; |
1876 ++t; | 1854 else if (GLYPH_FACE (glyph) == last_code) |
1877 ++f; | 1855 /* If it's same as previous glyph, use same result. */ |
1878 } | 1856 facecode = last_merged; |
1879 return t; | 1857 else |
1858 { | |
1859 /* Merge this glyph's face and remember the result. */ | |
1860 last_code = GLYPH_FACE (glyph); | |
1861 last_merged = facecode = compute_glyph_face (f, last_code, face); | |
1862 } | |
1863 | |
1864 if (to >= s) *to = MAKE_GLYPH (GLYPH_CHAR (glyph), facecode); | |
1865 ++to; | |
1866 ++fp; | |
1867 } | |
1868 return to; | |
1869 } | |
1870 | |
1871 /* Correct a glyph by replacing its specified user-level face code | |
1872 with a displayable computed face code. */ | |
1873 | |
1874 static GLYPH | |
1875 fix_glyph (f, glyph, current_face) | |
1876 FRAME_PTR f; | |
1877 GLYPH glyph; | |
1878 int current_face; | |
1879 { | |
1880 if (GLYPH_FACE (glyph) == 0) | |
1881 return glyph; | |
1882 return MAKE_GLYPH (GLYPH_CHAR (glyph), | |
1883 compute_glyph_face (f, GLYPH_FACE (glyph), current_face)); | |
1880 } | 1884 } |
1881 | 1885 |
1882 /* Display one line of window w, starting at position START in W's buffer. | 1886 /* Display one line of window w, starting at position START in W's buffer. |
1883 Display starting at horizontal position HPOS, which is normally zero | 1887 Display starting at horizontal position HPOS, which is normally zero |
1884 or negative. A negative value causes output up to hpos = 0 to be discarded. | 1888 or negative. A negative value causes output up to hpos = 0 to be discarded. |
1951 = (dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector | 1955 = (dp && XTYPE (DISP_INVIS_VECTOR (dp)) == Lisp_Vector |
1952 ? XVECTOR (DISP_INVIS_VECTOR (dp))->contents | 1956 ? XVECTOR (DISP_INVIS_VECTOR (dp))->contents |
1953 : default_invis_vector); | 1957 : default_invis_vector); |
1954 | 1958 |
1955 GLYPH truncator = (dp == 0 || XTYPE (DISP_TRUNC_GLYPH (dp)) != Lisp_Int | 1959 GLYPH truncator = (dp == 0 || XTYPE (DISP_TRUNC_GLYPH (dp)) != Lisp_Int |
1956 ? '$' : XINT (DISP_TRUNC_GLYPH (dp))); | 1960 ? '$' : XINT (DISP_TRUNC_GLYPH (dp))); |
1957 GLYPH continuer = (dp == 0 || XTYPE (DISP_CONTINUE_GLYPH (dp)) != Lisp_Int | 1961 GLYPH continuer = (dp == 0 || XTYPE (DISP_CONTINUE_GLYPH (dp)) != Lisp_Int |
1958 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp))); | 1962 ? '\\' : XINT (DISP_CONTINUE_GLYPH (dp))); |
1959 | 1963 |
1960 /* The next buffer location at which the face should change, due | 1964 /* The next buffer location at which the face should change, due |
1961 to overlays or text property changes. */ | 1965 to overlays or text property changes. */ |
1962 int next_face_change; | 1966 int next_face_change; |
1963 | 1967 |
1999 && vpos == XFASTINT (w->top)) | 2003 && vpos == XFASTINT (w->top)) |
2000 { | 2004 { |
2001 if (minibuf_prompt) | 2005 if (minibuf_prompt) |
2002 hpos = display_string (w, vpos, minibuf_prompt, -1, hpos, | 2006 hpos = display_string (w, vpos, minibuf_prompt, -1, hpos, |
2003 (!truncate ? continuer : truncator), | 2007 (!truncate ? continuer : truncator), |
2004 -1, -1); | 2008 1, -1, -1); |
2005 minibuf_prompt_width = hpos; | 2009 minibuf_prompt_width = hpos; |
2006 } | 2010 } |
2007 | 2011 |
2008 desired_glyphs->bufp[vpos] = pos; | 2012 desired_glyphs->bufp[vpos] = pos; |
2009 p1 = desired_glyphs->glyphs[vpos] + hpos; | 2013 p1 = desired_glyphs->glyphs[vpos] + hpos; |
2128 if (invis && selective_rlen > 0 && p1 >= startp) | 2132 if (invis && selective_rlen > 0 && p1 >= startp) |
2129 { | 2133 { |
2130 p1 += selective_rlen; | 2134 p1 += selective_rlen; |
2131 if (p1 - startp > width) | 2135 if (p1 - startp > width) |
2132 p1 = endp; | 2136 p1 = endp; |
2133 copy_part_of_rope (p1prev, p1prev, invis_vector_contents, | 2137 copy_part_of_rope (f, p1prev, p1prev, invis_vector_contents, |
2134 (p1 - p1prev), current_face); | 2138 (p1 - p1prev), current_face); |
2135 } | 2139 } |
2136 #if 1 | 2140 #if 1 |
2137 /* Draw the face of the newline character as extending all the | 2141 /* Draw the face of the newline character as extending all the |
2138 way to the end of the frame line. */ | 2142 way to the end of the frame line. */ |
2161 if (selective_rlen > 0) | 2165 if (selective_rlen > 0) |
2162 { | 2166 { |
2163 p1 += selective_rlen; | 2167 p1 += selective_rlen; |
2164 if (p1 - startp > width) | 2168 if (p1 - startp > width) |
2165 p1 = endp; | 2169 p1 = endp; |
2166 copy_part_of_rope (p1prev, p1prev, invis_vector_contents, | 2170 copy_part_of_rope (f, p1prev, p1prev, invis_vector_contents, |
2167 (p1 - p1prev), current_face); | 2171 (p1 - p1prev), current_face); |
2168 } | 2172 } |
2169 #if 1 | 2173 #if 1 |
2170 /* Draw the face of the newline character as extending all the | 2174 /* Draw the face of the newline character as extending all the |
2171 way to the end of the frame line. */ | 2175 way to the end of the frame line. */ |
2175 #endif | 2179 #endif |
2176 break; | 2180 break; |
2177 } | 2181 } |
2178 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector) | 2182 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector) |
2179 { | 2183 { |
2180 p1 = copy_rope (p1, startp, DISP_CHAR_VECTOR (dp, c), current_face); | 2184 p1 = copy_part_of_rope (f, p1, startp, |
2185 XVECTOR (DISP_CHAR_VECTOR (dp, c))->contents, | |
2186 XVECTOR (DISP_CHAR_VECTOR (dp, c))->size, | |
2187 current_face); | |
2181 } | 2188 } |
2182 else if (c < 0200 && ctl_arrow) | 2189 else if (c < 0200 && ctl_arrow) |
2183 { | 2190 { |
2184 if (p1 >= startp) | 2191 if (p1 >= startp) |
2185 *p1 = MAKE_GLYPH ((dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int | 2192 *p1 = fix_glyph (f, (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int |
2186 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'), | 2193 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'), |
2187 current_face); | 2194 current_face); |
2188 p1++; | 2195 p1++; |
2189 if (p1 >= startp && p1 < endp) | 2196 if (p1 >= startp && p1 < endp) |
2190 *p1 = MAKE_GLYPH (c ^ 0100, current_face); | 2197 *p1 = MAKE_GLYPH (c ^ 0100, current_face); |
2191 p1++; | 2198 p1++; |
2192 } | 2199 } |
2193 else | 2200 else |
2194 { | 2201 { |
2195 if (p1 >= startp) | 2202 if (p1 >= startp) |
2196 *p1 = MAKE_GLYPH ((dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int | 2203 *p1 = fix_glyph (f, (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int |
2197 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), | 2204 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), |
2198 current_face); | 2205 current_face); |
2199 p1++; | 2206 p1++; |
2200 if (p1 >= startp && p1 < endp) | 2207 if (p1 >= startp && p1 < endp) |
2201 *p1 = MAKE_GLYPH ((c >> 6) + '0', current_face); | 2208 *p1 = MAKE_GLYPH ((c >> 6) + '0', current_face); |
2202 p1++; | 2209 p1++; |
2203 if (p1 >= startp && p1 < endp) | 2210 if (p1 >= startp && p1 < endp) |
2250 else | 2257 else |
2251 /* Stopped due to right margin of window */ | 2258 /* Stopped due to right margin of window */ |
2252 { | 2259 { |
2253 if (truncate) | 2260 if (truncate) |
2254 { | 2261 { |
2255 *p1++ = truncator; | 2262 *p1++ = fix_glyph (f, truncator, 0); |
2256 /* Truncating => start next line after next newline, | 2263 /* Truncating => start next line after next newline, |
2257 and point is on this line if it is before the newline, | 2264 and point is on this line if it is before the newline, |
2258 and skip none of first char of next line */ | 2265 and skip none of first char of next line */ |
2259 pos = find_next_newline (pos, 1); | 2266 pos = find_next_newline (pos, 1); |
2260 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0; | 2267 val.hpos = XINT (w->hscroll) ? 1 - XINT (w->hscroll) : 0; |
2261 | 2268 |
2262 lastpos = pos - (FETCH_CHAR (pos - 1) == '\n'); | 2269 lastpos = pos - (FETCH_CHAR (pos - 1) == '\n'); |
2263 } | 2270 } |
2264 else | 2271 else |
2265 { | 2272 { |
2266 *p1++ = continuer; | 2273 *p1++ = fix_glyph (f, continuer, 0); |
2267 val.vpos = 0; | 2274 val.vpos = 0; |
2268 lastpos--; | 2275 lastpos--; |
2269 } | 2276 } |
2270 } | 2277 } |
2271 } | 2278 } |
2310 } | 2317 } |
2311 | 2318 |
2312 /* If hscroll and line not empty, insert truncation-at-left marker */ | 2319 /* If hscroll and line not empty, insert truncation-at-left marker */ |
2313 if (hscroll && lastpos != start) | 2320 if (hscroll && lastpos != start) |
2314 { | 2321 { |
2315 *startp = truncator; | 2322 *startp = fix_glyph (f, truncator, 0); |
2316 if (p1 <= startp) | 2323 if (p1 <= startp) |
2317 p1 = startp + 1; | 2324 p1 = startp + 1; |
2318 } | 2325 } |
2319 | 2326 |
2320 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)) | 2327 if (XFASTINT (w->width) + XFASTINT (w->left) != FRAME_WIDTH (f)) |
2395 | 2402 |
2396 if (hpos < maxendcol) | 2403 if (hpos < maxendcol) |
2397 hpos = display_string (XWINDOW (FRAME_ROOT_WINDOW (f)), vpos, | 2404 hpos = display_string (XWINDOW (FRAME_ROOT_WINDOW (f)), vpos, |
2398 XSTRING (string)->data, | 2405 XSTRING (string)->data, |
2399 XSTRING (string)->size, | 2406 XSTRING (string)->size, |
2400 hpos, 0, hpos, maxendcol); | 2407 hpos, 0, 0, hpos, maxendcol); |
2401 /* Put a gap of 3 spaces between items. */ | 2408 /* Put a gap of 3 spaces between items. */ |
2402 if (hpos < maxendcol) | 2409 if (hpos < maxendcol) |
2403 { | 2410 { |
2404 int hpos1 = hpos + 3; | 2411 int hpos1 = hpos + 3; |
2405 hpos = display_string (w, vpos, "", 0, hpos, 0, | 2412 hpos = display_string (w, vpos, "", 0, hpos, 0, 0, |
2406 min (hpos1, maxendcol), maxendcol); | 2413 min (hpos1, maxendcol), maxendcol); |
2407 } | 2414 } |
2408 } | 2415 } |
2409 | 2416 |
2410 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0; | 2417 FRAME_DESIRED_GLYPHS (f)->bufp[vpos] = 0; |
2411 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video; | 2418 FRAME_DESIRED_GLYPHS (f)->highlight[vpos] = mode_line_inverse_video; |
2412 | 2419 |
2413 /* Fill out the line with spaces. */ | 2420 /* Fill out the line with spaces. */ |
2414 if (maxendcol > hpos) | 2421 if (maxendcol > hpos) |
2415 hpos = display_string (w, vpos, "", 0, hpos, 0, maxendcol, -1); | 2422 hpos = display_string (w, vpos, "", 0, hpos, 0, 0, maxendcol, maxendcol); |
2416 | 2423 |
2417 /* Clear the rest of the lines allocated to the menu bar. */ | 2424 /* Clear the rest of the lines allocated to the menu bar. */ |
2418 vpos++; | 2425 vpos++; |
2419 while (vpos < FRAME_MENU_BAR_LINES (f)) | 2426 while (vpos < FRAME_MENU_BAR_LINES (f)) |
2420 get_display_line (f, vpos++, 0); | 2427 get_display_line (f, vpos++, 0); |
2527 while ((c = *this++) != '\0' && c != '%') | 2534 while ((c = *this++) != '\0' && c != '%') |
2528 ; | 2535 ; |
2529 if (this - 1 != last) | 2536 if (this - 1 != last) |
2530 { | 2537 { |
2531 register int lim = --this - last + hpos; | 2538 register int lim = --this - last + hpos; |
2532 hpos = display_string (w, vpos, last, -1, hpos, 0, hpos, | 2539 hpos = display_string (w, vpos, last, -1, hpos, 0, 1, |
2533 min (lim, maxendcol)); | 2540 hpos, min (lim, maxendcol)); |
2534 } | 2541 } |
2535 else /* c == '%' */ | 2542 else /* c == '%' */ |
2536 { | 2543 { |
2537 register int spec_width = 0; | 2544 register int spec_width = 0; |
2538 | 2545 |
2557 else if (c != 0) | 2564 else if (c != 0) |
2558 hpos = display_string (w, vpos, | 2565 hpos = display_string (w, vpos, |
2559 decode_mode_spec (w, c, | 2566 decode_mode_spec (w, c, |
2560 maxendcol - hpos), | 2567 maxendcol - hpos), |
2561 -1, | 2568 -1, |
2562 hpos, 0, spec_width, maxendcol); | 2569 hpos, 0, 1, spec_width, maxendcol); |
2563 } | 2570 } |
2564 } | 2571 } |
2565 } | 2572 } |
2566 break; | 2573 break; |
2567 | 2574 |
2579 /* If value is a string, output that string literally: | 2586 /* If value is a string, output that string literally: |
2580 don't check for % within it. */ | 2587 don't check for % within it. */ |
2581 if (XTYPE (tem) == Lisp_String) | 2588 if (XTYPE (tem) == Lisp_String) |
2582 hpos = display_string (w, vpos, XSTRING (tem)->data, | 2589 hpos = display_string (w, vpos, XSTRING (tem)->data, |
2583 XSTRING (tem)->size, | 2590 XSTRING (tem)->size, |
2584 hpos, 0, minendcol, maxendcol); | 2591 hpos, 0, 1, minendcol, maxendcol); |
2585 /* Give up right away for nil or t. */ | 2592 /* Give up right away for nil or t. */ |
2586 else if (!EQ (tem, elt)) | 2593 else if (!EQ (tem, elt)) |
2587 { elt = tem; goto tail_recurse; } | 2594 { elt = tem; goto tail_recurse; } |
2588 } | 2595 } |
2589 } | 2596 } |
2668 } | 2675 } |
2669 break; | 2676 break; |
2670 | 2677 |
2671 default: | 2678 default: |
2672 invalid: | 2679 invalid: |
2673 return (display_string (w, vpos, "*invalid*", -1, hpos, 0, | 2680 return (display_string (w, vpos, "*invalid*", -1, hpos, 0, 1, |
2674 minendcol, maxendcol)); | 2681 minendcol, maxendcol)); |
2675 } | 2682 } |
2676 | 2683 |
2677 end: | 2684 end: |
2678 if (minendcol > hpos) | 2685 if (minendcol > hpos) |
2679 hpos = display_string (w, vpos, "", 0, hpos, 0, minendcol, -1); | 2686 hpos = display_string (w, vpos, "", 0, hpos, 0, 1, minendcol, maxendcol); |
2680 return hpos; | 2687 return hpos; |
2681 } | 2688 } |
2682 | 2689 |
2683 /* Return a string for the output of a mode line %-spec for window W, | 2690 /* Return a string for the output of a mode line %-spec for window W, |
2684 generated by character C and width MAXWIDTH. */ | 2691 generated by character C and width MAXWIDTH. */ |
2948 if (limit < from) | 2955 if (limit < from) |
2949 BEGV = limit; | 2956 BEGV = limit; |
2950 else | 2957 else |
2951 ZV = limit; | 2958 ZV = limit; |
2952 | 2959 |
2953 *pos_ptr = scan_buffer ('\n', from, n, &shortage); | 2960 *pos_ptr = scan_buffer ('\n', from, n, &shortage, 0); |
2954 | 2961 |
2955 ZV = oldzv; | 2962 ZV = oldzv; |
2956 BEGV = oldbegv; | 2963 BEGV = oldbegv; |
2957 | 2964 |
2958 if (n < 0) | 2965 if (n < 0) |
2974 -1 for MINCOL or MAXCOL means no explicit minimum or maximum. | 2981 -1 for MINCOL or MAXCOL means no explicit minimum or maximum. |
2975 Both count from the left edge of the frame, as does HPOS. | 2982 Both count from the left edge of the frame, as does HPOS. |
2976 The right edge of W is an implicit maximum. | 2983 The right edge of W is an implicit maximum. |
2977 If TRUNCATE is nonzero, the implicit maximum is one column before the edge. | 2984 If TRUNCATE is nonzero, the implicit maximum is one column before the edge. |
2978 | 2985 |
2979 Returns ending hpos */ | 2986 OBEY_WINDOW_WIDTH says to put spaces or vertical bars |
2987 at the place where the current window ends in this line | |
2988 and not display anything beyond there. Otherwise, only MAXCOL | |
2989 controls where to stop output. | |
2990 | |
2991 Returns ending hpos. */ | |
2980 | 2992 |
2981 static int | 2993 static int |
2982 display_string (w, vpos, string, length, hpos, truncate, mincol, maxcol) | 2994 display_string (w, vpos, string, length, hpos, truncate, |
2995 obey_window_width, mincol, maxcol) | |
2983 struct window *w; | 2996 struct window *w; |
2984 unsigned char *string; | 2997 unsigned char *string; |
2985 int length; | 2998 int length; |
2986 int vpos, hpos; | 2999 int vpos, hpos; |
2987 GLYPH truncate; | 3000 GLYPH truncate; |
3001 int obey_window_width; | |
2988 int mincol, maxcol; | 3002 int mincol, maxcol; |
2989 { | 3003 { |
2990 register int c; | 3004 register int c; |
2991 register GLYPH *p1; | 3005 register GLYPH *p1; |
2992 int hscroll = XINT (w->hscroll); | 3006 int hscroll = XINT (w->hscroll); |
3008 | 3022 |
3009 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; | 3023 if (tab_width <= 0 || tab_width > 1000) tab_width = 8; |
3010 | 3024 |
3011 p1 = p1start; | 3025 p1 = p1start; |
3012 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); | 3026 start = desired_glyphs->glyphs[vpos] + XFASTINT (w->left); |
3013 end = start + window_width - (truncate != 0); | 3027 |
3014 | 3028 if (obey_window_width) |
3015 if ((window_width + XFASTINT (w->left)) != FRAME_WIDTH (f)) | 3029 { |
3016 { | 3030 end = start + window_width - (truncate != 0); |
3017 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) | 3031 |
3018 { | 3032 if ((window_width + XFASTINT (w->left)) != FRAME_WIDTH (f)) |
3019 int i; | 3033 { |
3020 | 3034 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
3021 for (i = 0; i < VERTICAL_SCROLL_BAR_WIDTH; i++) | 3035 { |
3022 *end-- = ' '; | 3036 int i; |
3023 } | 3037 |
3024 else | 3038 for (i = 0; i < VERTICAL_SCROLL_BAR_WIDTH; i++) |
3025 *end-- = '|'; | 3039 *end-- = ' '; |
3026 } | 3040 } |
3027 | 3041 else |
3028 if (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol) | 3042 *end-- = '|'; |
3043 } | |
3044 } | |
3045 | |
3046 if (! obey_window_width | |
3047 || (maxcol >= 0 && end - desired_glyphs->glyphs[vpos] > maxcol)) | |
3029 end = desired_glyphs->glyphs[vpos] + maxcol; | 3048 end = desired_glyphs->glyphs[vpos] + maxcol; |
3049 | |
3030 if (maxcol >= 0 && mincol > maxcol) | 3050 if (maxcol >= 0 && mincol > maxcol) |
3031 mincol = maxcol; | 3051 mincol = maxcol; |
3032 | 3052 |
3033 while (p1 < end) | 3053 while (p1 < end) |
3034 { | 3054 { |
3058 p1++; | 3078 p1++; |
3059 } | 3079 } |
3060 while ((p1 - start + hscroll - (hscroll > 0)) % tab_width); | 3080 while ((p1 - start + hscroll - (hscroll > 0)) % tab_width); |
3061 } | 3081 } |
3062 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector) | 3082 else if (dp != 0 && XTYPE (DISP_CHAR_VECTOR (dp, c)) == Lisp_Vector) |
3063 p1 = copy_rope (p1, start, DISP_CHAR_VECTOR (dp, c), 0); | 3083 { |
3084 p1 = copy_part_of_rope (f, p1, start, | |
3085 XVECTOR (DISP_CHAR_VECTOR (dp, c))->contents, | |
3086 XVECTOR (DISP_CHAR_VECTOR (dp, c))->size, | |
3087 0); | |
3088 } | |
3064 else if (c < 0200 && ! NILP (buffer_defaults.ctl_arrow)) | 3089 else if (c < 0200 && ! NILP (buffer_defaults.ctl_arrow)) |
3065 { | 3090 { |
3066 if (p1 >= start) | 3091 if (p1 >= start) |
3067 *p1 = (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int | 3092 *p1 = fix_glyph (f, (dp && XTYPE (DISP_CTRL_GLYPH (dp)) == Lisp_Int |
3068 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'); | 3093 ? XINT (DISP_CTRL_GLYPH (dp)) : '^'), |
3094 0); | |
3069 p1++; | 3095 p1++; |
3070 if (p1 >= start && p1 < end) | 3096 if (p1 >= start && p1 < end) |
3071 *p1 = c ^ 0100; | 3097 *p1 = c ^ 0100; |
3072 p1++; | 3098 p1++; |
3073 } | 3099 } |
3074 else | 3100 else |
3075 { | 3101 { |
3076 if (p1 >= start) | 3102 if (p1 >= start) |
3077 *p1 = (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int | 3103 *p1 = fix_glyph (f, (dp && XTYPE (DISP_ESCAPE_GLYPH (dp)) == Lisp_Int |
3078 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'); | 3104 ? XINT (DISP_ESCAPE_GLYPH (dp)) : '\\'), |
3105 0); | |
3079 p1++; | 3106 p1++; |
3080 if (p1 >= start && p1 < end) | 3107 if (p1 >= start && p1 < end) |
3081 *p1 = (c >> 6) + '0'; | 3108 *p1 = (c >> 6) + '0'; |
3082 p1++; | 3109 p1++; |
3083 if (p1 >= start && p1 < end) | 3110 if (p1 >= start && p1 < end) |
3090 } | 3117 } |
3091 | 3118 |
3092 if (c && length > 0) | 3119 if (c && length > 0) |
3093 { | 3120 { |
3094 p1 = end; | 3121 p1 = end; |
3095 if (truncate) *p1++ = truncate; | 3122 if (truncate) *p1++ = fix_glyph (f, truncate, 0); |
3096 } | 3123 } |
3097 else if (mincol >= 0) | 3124 else if (mincol >= 0) |
3098 { | 3125 { |
3099 end = desired_glyphs->glyphs[vpos] + mincol; | 3126 end = desired_glyphs->glyphs[vpos] + mincol; |
3100 while (p1 < end) | 3127 while (p1 < end) |