aboutsummaryrefslogtreecommitdiffstats
path: root/src/xdisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c122
1 files changed, 76 insertions, 46 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 4b0865aa4f0..c3f659a85e6 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2071,6 +2071,7 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id)
2071 * FRAME_LINE_HEIGHT (it->f)); 2071 * FRAME_LINE_HEIGHT (it->f));
2072 else if (it->f->extra_line_spacing > 0) 2072 else if (it->f->extra_line_spacing > 0)
2073 it->extra_line_spacing = it->f->extra_line_spacing; 2073 it->extra_line_spacing = it->f->extra_line_spacing;
2074 it->max_extra_line_spacing = 0;
2074 } 2075 }
2075 2076
2076 /* If realized faces have been removed, e.g. because of face 2077 /* If realized faces have been removed, e.g. because of face
@@ -6066,10 +6067,13 @@ move_it_vertically_backward (it, dy)
6066{ 6067{
6067 int nlines, h; 6068 int nlines, h;
6068 struct it it2, it3; 6069 struct it it2, it3;
6069 int start_pos = IT_CHARPOS (*it); 6070 int start_pos;
6070 6071
6072 move_further_back:
6071 xassert (dy >= 0); 6073 xassert (dy >= 0);
6072 6074
6075 start_pos = IT_CHARPOS (*it);
6076
6073 /* Estimate how many newlines we must move back. */ 6077 /* Estimate how many newlines we must move back. */
6074 nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f)); 6078 nlines = max (1, dy / FRAME_LINE_HEIGHT (it->f));
6075 6079
@@ -6135,13 +6139,13 @@ move_it_vertically_backward (it, dy)
6135 a line height of 13 pixels each, recentering with point 6139 a line height of 13 pixels each, recentering with point
6136 on the bottom line will try to move -39/2 = 19 pixels 6140 on the bottom line will try to move -39/2 = 19 pixels
6137 backward. Try to avoid moving into the first line. */ 6141 backward. Try to avoid moving into the first line. */
6138 && it->current_y - target_y > line_height / 3 * 2 6142 && it->current_y - target_y > line_height * 2 / 3
6139 && IT_CHARPOS (*it) > BEGV) 6143 && IT_CHARPOS (*it) > BEGV)
6140 { 6144 {
6141 TRACE_MOVE ((stderr, " not far enough -> move_vert %d\n", 6145 TRACE_MOVE ((stderr, " not far enough -> move_vert %d\n",
6142 target_y - it->current_y)); 6146 target_y - it->current_y));
6143 move_it_vertically (it, target_y - it->current_y); 6147 dy = it->current_y - target_y;
6144 xassert (IT_CHARPOS (*it) >= BEGV); 6148 goto move_further_back;
6145 } 6149 }
6146 else if (target_y >= it->current_y + line_height 6150 else if (target_y >= it->current_y + line_height
6147 && IT_CHARPOS (*it) < ZV) 6151 && IT_CHARPOS (*it) < ZV)
@@ -6182,7 +6186,7 @@ move_it_vertically (it, dy)
6182{ 6186{
6183 if (dy <= 0) 6187 if (dy <= 0)
6184 move_it_vertically_backward (it, -dy); 6188 move_it_vertically_backward (it, -dy);
6185 else if (dy > 0) 6189 else
6186 { 6190 {
6187 TRACE_MOVE ((stderr, "move_it_v: from %d, %d\n", IT_CHARPOS (*it), dy)); 6191 TRACE_MOVE ((stderr, "move_it_v: from %d, %d\n", IT_CHARPOS (*it), dy));
6188 move_it_to (it, ZV, -1, it->current_y + dy, -1, 6192 move_it_to (it, ZV, -1, it->current_y + dy, -1,
@@ -6279,6 +6283,8 @@ move_it_by_lines (it, dvpos, need_y_p)
6279 /* DVPOS == 0 means move to the start of the screen line. */ 6283 /* DVPOS == 0 means move to the start of the screen line. */
6280 move_it_vertically_backward (it, 0); 6284 move_it_vertically_backward (it, 0);
6281 xassert (it->current_x == 0 && it->hpos == 0); 6285 xassert (it->current_x == 0 && it->hpos == 0);
6286 /* Let next call to line_bottom_y calculate real line height */
6287 last_height = 0;
6282 } 6288 }
6283 else if (dvpos > 0) 6289 else if (dvpos > 0)
6284 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS); 6290 move_it_to (it, -1, -1, -1, it->vpos + dvpos, MOVE_TO_VPOS);
@@ -7422,7 +7428,7 @@ resize_mini_window (w, exact_p)
7422 height = it.current_y + last_height; 7428 height = it.current_y + last_height;
7423 else 7429 else
7424 height = it.current_y + it.max_ascent + it.max_descent; 7430 height = it.current_y + it.max_ascent + it.max_descent;
7425 height -= it.extra_line_spacing; 7431 height -= min (it.extra_line_spacing, it.max_extra_line_spacing);
7426 height = (height + unit - 1) / unit; 7432 height = (height + unit - 1) / unit;
7427 } 7433 }
7428 7434
@@ -8699,6 +8705,7 @@ display_tool_bar_line (it)
8699 { 8705 {
8700 row->height = row->phys_height = it->last_visible_y - row->y; 8706 row->height = row->phys_height = it->last_visible_y - row->y;
8701 row->ascent = row->phys_ascent = 0; 8707 row->ascent = row->phys_ascent = 0;
8708 row->extra_line_spacing = 0;
8702 } 8709 }
8703 8710
8704 row->full_width_p = 1; 8711 row->full_width_p = 1;
@@ -10888,7 +10895,7 @@ make_cursor_line_fully_visible (w, force_p)
10888 row = MATRIX_ROW (matrix, w->cursor.vpos); 10895 row = MATRIX_ROW (matrix, w->cursor.vpos);
10889 10896
10890 /* If the cursor row is not partially visible, there's nothing to do. */ 10897 /* If the cursor row is not partially visible, there's nothing to do. */
10891 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 10898 if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row))
10892 return 1; 10899 return 1;
10893 10900
10894 /* If the row the cursor is in is taller than the window's height, 10901 /* If the row the cursor is in is taller than the window's height,
@@ -11042,7 +11049,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11042 { 11049 {
11043 start_display (&it, w, scroll_margin_pos); 11050 start_display (&it, w, scroll_margin_pos);
11044 if (this_scroll_margin) 11051 if (this_scroll_margin)
11045 move_it_vertically (&it, - this_scroll_margin); 11052 move_it_vertically_backward (&it, this_scroll_margin);
11046 if (extra_scroll_margin_lines) 11053 if (extra_scroll_margin_lines)
11047 move_it_by_lines (&it, - extra_scroll_margin_lines, 0); 11054 move_it_by_lines (&it, - extra_scroll_margin_lines, 0);
11048 scroll_margin_pos = it.current.pos; 11055 scroll_margin_pos = it.current.pos;
@@ -11162,7 +11169,7 @@ try_scrolling (window, just_this_one_p, scroll_conservatively,
11162 if (amount_to_scroll <= 0) 11169 if (amount_to_scroll <= 0)
11163 return SCROLLING_FAILED; 11170 return SCROLLING_FAILED;
11164 11171
11165 move_it_vertically (&it, - amount_to_scroll); 11172 move_it_vertically_backward (&it, amount_to_scroll);
11166 startp = it.current.pos; 11173 startp = it.current.pos;
11167 } 11174 }
11168 } 11175 }
@@ -11466,7 +11473,7 @@ try_cursor_movement (window, startp, scroll_step)
11466 /* if PT is not in the glyph row, give up. */ 11473 /* if PT is not in the glyph row, give up. */
11467 rc = CURSOR_MOVEMENT_MUST_SCROLL; 11474 rc = CURSOR_MOVEMENT_MUST_SCROLL;
11468 } 11475 }
11469 else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (row)) 11476 else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row))
11470 { 11477 {
11471 if (PT == MATRIX_ROW_END_CHARPOS (row) 11478 if (PT == MATRIX_ROW_END_CHARPOS (row)
11472 && !row->ends_at_zv_p 11479 && !row->ends_at_zv_p
@@ -12043,7 +12050,7 @@ redisplay_window (window, just_this_one_p)
12043 if (it.current_y <= 0) 12050 if (it.current_y <= 0)
12044 { 12051 {
12045 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); 12052 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
12046 move_it_vertically (&it, 0); 12053 move_it_vertically_backward (&it, 0);
12047 xassert (IT_CHARPOS (it) <= PT); 12054 xassert (IT_CHARPOS (it) <= PT);
12048 it.current_y = 0; 12055 it.current_y = 0;
12049 } 12056 }
@@ -12395,7 +12402,7 @@ try_window_reusing_current_matrix (w)
12395 /* Give up if old or new display is scrolled vertically. We could 12402 /* Give up if old or new display is scrolled vertically. We could
12396 make this function handle this, but right now it doesn't. */ 12403 make this function handle this, but right now it doesn't. */
12397 start_row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 12404 start_row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
12398 if (w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (start_row)) 12405 if (w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (w, start_row))
12399 return 0; 12406 return 0;
12400 12407
12401 /* The variable new_start now holds the new window start. The old 12408 /* The variable new_start now holds the new window start. The old
@@ -12443,7 +12450,7 @@ try_window_reusing_current_matrix (w)
12443 start = start_row->start.pos; 12450 start = start_row->start.pos;
12444 /* If there are no more rows to try, or just one, give up. */ 12451 /* If there are no more rows to try, or just one, give up. */
12445 if (start_row == MATRIX_MODE_LINE_ROW (w->current_matrix) - 1 12452 if (start_row == MATRIX_MODE_LINE_ROW (w->current_matrix) - 1
12446 || w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (start_row) 12453 || w->vscroll || MATRIX_ROW_PARTIALLY_VISIBLE_P (w, start_row)
12447 || CHARPOS (start) == ZV) 12454 || CHARPOS (start) == ZV)
12448 { 12455 {
12449 clear_glyph_matrix (w->desired_matrix); 12456 clear_glyph_matrix (w->desired_matrix);
@@ -14237,6 +14244,7 @@ compute_line_metrics (it)
14237 row->height = it->max_ascent + it->max_descent; 14244 row->height = it->max_ascent + it->max_descent;
14238 row->phys_ascent = it->max_phys_ascent; 14245 row->phys_ascent = it->max_phys_ascent;
14239 row->phys_height = it->max_phys_ascent + it->max_phys_descent; 14246 row->phys_height = it->max_phys_ascent + it->max_phys_descent;
14247 row->extra_line_spacing = it->max_extra_line_spacing;
14240 } 14248 }
14241 14249
14242 /* Compute the width of this line. */ 14250 /* Compute the width of this line. */
@@ -14280,6 +14288,7 @@ compute_line_metrics (it)
14280 row->pixel_width -= it->truncation_pixel_width; 14288 row->pixel_width -= it->truncation_pixel_width;
14281 row->ascent = row->phys_ascent = 0; 14289 row->ascent = row->phys_ascent = 0;
14282 row->height = row->phys_height = row->visible_height = 1; 14290 row->height = row->phys_height = row->visible_height = 1;
14291 row->extra_line_spacing = 0;
14283 } 14292 }
14284 14293
14285 /* Compute a hash code for this row. */ 14294 /* Compute a hash code for this row. */
@@ -14616,6 +14625,7 @@ display_line (it)
14616 row->height = it->max_ascent + it->max_descent; 14625 row->height = it->max_ascent + it->max_descent;
14617 row->phys_ascent = it->max_phys_ascent; 14626 row->phys_ascent = it->max_phys_ascent;
14618 row->phys_height = it->max_phys_ascent + it->max_phys_descent; 14627 row->phys_height = it->max_phys_ascent + it->max_phys_descent;
14628 row->extra_line_spacing = it->max_extra_line_spacing;
14619 14629
14620 /* Loop generating characters. The loop is left with IT on the next 14630 /* Loop generating characters. The loop is left with IT on the next
14621 character to display. */ 14631 character to display. */
@@ -14681,6 +14691,8 @@ display_line (it)
14681 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent); 14691 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
14682 row->phys_height = max (row->phys_height, 14692 row->phys_height = max (row->phys_height,
14683 it->max_phys_ascent + it->max_phys_descent); 14693 it->max_phys_ascent + it->max_phys_descent);
14694 row->extra_line_spacing = max (row->extra_line_spacing,
14695 it->max_extra_line_spacing);
14684 set_iterator_to_next (it, 1); 14696 set_iterator_to_next (it, 1);
14685 continue; 14697 continue;
14686 } 14698 }
@@ -14709,6 +14721,8 @@ display_line (it)
14709 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent); 14721 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
14710 row->phys_height = max (row->phys_height, 14722 row->phys_height = max (row->phys_height,
14711 it->max_phys_ascent + it->max_phys_descent); 14723 it->max_phys_ascent + it->max_phys_descent);
14724 row->extra_line_spacing = max (row->extra_line_spacing,
14725 it->max_extra_line_spacing);
14712 if (it->current_x - it->pixel_width < it->first_visible_x) 14726 if (it->current_x - it->pixel_width < it->first_visible_x)
14713 row->x = x - it->first_visible_x; 14727 row->x = x - it->first_visible_x;
14714 } 14728 }
@@ -14860,6 +14874,8 @@ display_line (it)
14860 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent); 14874 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
14861 row->phys_height = max (row->phys_height, 14875 row->phys_height = max (row->phys_height,
14862 it->max_phys_ascent + it->max_phys_descent); 14876 it->max_phys_ascent + it->max_phys_descent);
14877 row->extra_line_spacing = max (row->extra_line_spacing,
14878 it->max_extra_line_spacing);
14863 14879
14864 /* End of this display line if row is continued. */ 14880 /* End of this display line if row is continued. */
14865 if (row->continued_p || row->ends_at_zv_p) 14881 if (row->continued_p || row->ends_at_zv_p)
@@ -16043,27 +16059,31 @@ pint2hrstr (buf, width, d)
16043 { 16059 {
16044 tenths = remainder / 100; 16060 tenths = remainder / 100;
16045 if (50 <= remainder % 100) 16061 if (50 <= remainder % 100)
16046 if (tenths < 9) 16062 {
16047 tenths++; 16063 if (tenths < 9)
16048 else 16064 tenths++;
16049 { 16065 else
16050 quotient++; 16066 {
16051 if (quotient == 10) 16067 quotient++;
16052 tenths = -1; 16068 if (quotient == 10)
16053 else 16069 tenths = -1;
16054 tenths = 0; 16070 else
16055 } 16071 tenths = 0;
16072 }
16073 }
16056 } 16074 }
16057 else 16075 else
16058 if (500 <= remainder) 16076 if (500 <= remainder)
16059 if (quotient < 999) 16077 {
16060 quotient++; 16078 if (quotient < 999)
16061 else 16079 quotient++;
16062 { 16080 else
16063 quotient = 1; 16081 {
16064 exponent++; 16082 quotient = 1;
16065 tenths = 0; 16083 exponent++;
16066 } 16084 tenths = 0;
16085 }
16086 }
16067 } 16087 }
16068 16088
16069 /* Calculate the LENGTH of QUOTIENT.TENTHS as a string. */ 16089 /* Calculate the LENGTH of QUOTIENT.TENTHS as a string. */
@@ -16765,6 +16785,7 @@ display_string (string, lisp_string, face_string, face_string_pos,
16765 row->height = it->max_ascent + it->max_descent; 16785 row->height = it->max_ascent + it->max_descent;
16766 row->phys_ascent = it->max_phys_ascent; 16786 row->phys_ascent = it->max_phys_ascent;
16767 row->phys_height = it->max_phys_ascent + it->max_phys_descent; 16787 row->phys_height = it->max_phys_ascent + it->max_phys_descent;
16788 row->extra_line_spacing = it->max_extra_line_spacing;
16768 16789
16769 /* This condition is for the case that we are called with current_x 16790 /* This condition is for the case that we are called with current_x
16770 past last_visible_x. */ 16791 past last_visible_x. */
@@ -16824,6 +16845,8 @@ display_string (string, lisp_string, face_string, face_string_pos,
16824 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent); 16845 row->phys_ascent = max (row->phys_ascent, it->max_phys_ascent);
16825 row->phys_height = max (row->phys_height, 16846 row->phys_height = max (row->phys_height,
16826 it->max_phys_ascent + it->max_phys_descent); 16847 it->max_phys_ascent + it->max_phys_descent);
16848 row->extra_line_spacing = max (row->extra_line_spacing,
16849 it->max_extra_line_spacing);
16827 x += glyph->pixel_width; 16850 x += glyph->pixel_width;
16828 ++i; 16851 ++i;
16829 } 16852 }
@@ -18350,7 +18373,7 @@ produce_image_glyph (it)
18350{ 18373{
18351 struct image *img; 18374 struct image *img;
18352 struct face *face; 18375 struct face *face;
18353 int face_ascent, glyph_ascent; 18376 int glyph_ascent;
18354 struct glyph_slice slice; 18377 struct glyph_slice slice;
18355 18378
18356 xassert (it->what == IT_IMAGE); 18379 xassert (it->what == IT_IMAGE);
@@ -18433,7 +18456,7 @@ produce_image_glyph (it)
18433 18456
18434#if 0 /* this breaks image tiling */ 18457#if 0 /* this breaks image tiling */
18435 /* If this glyph is alone on the last line, adjust it.ascent to minimum row ascent. */ 18458 /* If this glyph is alone on the last line, adjust it.ascent to minimum row ascent. */
18436 face_ascent = face->font ? FONT_BASE (face->font) : FRAME_BASELINE_OFFSET (it->f); 18459 int face_ascent = face->font ? FONT_BASE (face->font) : FRAME_BASELINE_OFFSET (it->f);
18437 if (face_ascent > it->ascent) 18460 if (face_ascent > it->ascent)
18438 it->ascent = it->phys_ascent = face_ascent; 18461 it->ascent = it->phys_ascent = face_ascent;
18439#endif 18462#endif
@@ -19446,7 +19469,11 @@ x_produce_glyphs (it)
19446 it->current_x += it->pixel_width; 19469 it->current_x += it->pixel_width;
19447 19470
19448 if (extra_line_spacing > 0) 19471 if (extra_line_spacing > 0)
19449 it->descent += extra_line_spacing; 19472 {
19473 it->descent += extra_line_spacing;
19474 if (extra_line_spacing > it->max_extra_line_spacing)
19475 it->max_extra_line_spacing = extra_line_spacing;
19476 }
19450 19477
19451 it->max_ascent = max (it->max_ascent, it->ascent); 19478 it->max_ascent = max (it->max_ascent, it->ascent);
19452 it->max_descent = max (it->max_descent, it->descent); 19479 it->max_descent = max (it->max_descent, it->descent);
@@ -20413,19 +20440,20 @@ fast_find_position (w, charpos, hpos, vpos, x, y, stop)
20413 int past_end = 0; 20440 int past_end = 0;
20414 20441
20415 first = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 20442 first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
20443 if (charpos < MATRIX_ROW_START_CHARPOS (first))
20444 {
20445 *x = first->x;
20446 *y = first->y;
20447 *hpos = 0;
20448 *vpos = MATRIX_ROW_VPOS (first, w->current_matrix);
20449 return 1;
20450 }
20451
20416 row = row_containing_pos (w, charpos, first, NULL, 0); 20452 row = row_containing_pos (w, charpos, first, NULL, 0);
20417 if (row == NULL) 20453 if (row == NULL)
20418 { 20454 {
20419 if (charpos < MATRIX_ROW_START_CHARPOS (first)) 20455 row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
20420 { 20456 past_end = 1;
20421 *x = *y = *hpos = *vpos = 0;
20422 return 1;
20423 }
20424 else
20425 {
20426 row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
20427 past_end = 1;
20428 }
20429 } 20457 }
20430 20458
20431 *x = row->x; 20459 *x = row->x;
@@ -20970,8 +20998,10 @@ note_mouse_highlight (f, x, y)
20970 /* Which window is that in? */ 20998 /* Which window is that in? */
20971 window = window_from_coordinates (f, x, y, &part, 0, 0, 1); 20999 window = window_from_coordinates (f, x, y, &part, 0, 0, 1);
20972 21000
20973 /* If we were displaying active text in another window, clear that. */ 21001 /* If we were displaying active text in another window, clear that.
20974 if (! EQ (window, dpyinfo->mouse_face_window)) 21002 Also clear if we move out of text area in same window. */
21003 if (! EQ (window, dpyinfo->mouse_face_window)
21004 || (part != ON_TEXT && !NILP (dpyinfo->mouse_face_window)))
20975 clear_mouse_face (dpyinfo); 21005 clear_mouse_face (dpyinfo);
20976 21006
20977 /* Not on a window -> return. */ 21007 /* Not on a window -> return. */