From d0c38d631d0e7a1979921c0c4efe2f31ff6d7c3b Mon Sep 17 00:00:00 2001 From: Kim F. Storm Date: Tue, 9 Nov 2004 11:16:32 +0000 Subject: Fix commentary. --- src/window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index aae7a9f951e..0c08a662380 100644 --- a/src/window.c +++ b/src/window.c @@ -204,7 +204,7 @@ static int window_initialized; Lisp_Object Qwindow_configuration_change_hook; Lisp_Object Vwindow_configuration_change_hook; -/* Nonzero means scroll commands try to put point +/* Non-nil means scroll commands try to put point at the same screen height as previously. */ Lisp_Object Vscroll_preserve_screen_position; @@ -4523,7 +4523,7 @@ window_scroll_pixel_based (window, n, whole, noerror) start = it.current.pos; } - /* If scroll_preserve_screen_position is non-zero, we try to set + /* If scroll_preserve_screen_position is non-nil, we try to set point in the same window line as it is now, so get that line. */ if (!NILP (Vscroll_preserve_screen_position)) { -- cgit v1.2.1 From f204989e2e4cfb5d3744c30efe3ef408fa80fe08 Mon Sep 17 00:00:00 2001 From: Kim F. Storm Date: Fri, 12 Nov 2004 14:26:53 +0000 Subject: (window_scroll_pixel_based, Frecenter): Use move_it_vertically_backward directly. (Frecenter): Fix calculation of new start pos for negative arg. Before, the new start pos was sometimes chosen too far back, so the last line became only partially visible, and thus would be either only semi-visible or automatically scrolled to the middle of the window by redisplay. --- src/window.c | 55 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 11 deletions(-) (limited to 'src/window.c') diff --git a/src/window.c b/src/window.c index 0c08a662380..24be93a3943 100644 --- a/src/window.c +++ b/src/window.c @@ -4506,7 +4506,7 @@ window_scroll_pixel_based (window, n, whole, noerror) results for variable height lines. */ init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); it.current_y = it.last_visible_y; - move_it_vertically (&it, - window_box_height (w) / 2); + move_it_vertically_backward (&it, window_box_height (w) / 2); /* The function move_iterator_vertically may move over more than the specified y-distance. If it->w is small, e.g. a @@ -4516,7 +4516,7 @@ window_scroll_pixel_based (window, n, whole, noerror) if (it.current_y <= 0) { init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); - move_it_vertically (&it, 0); + move_it_vertically_backward (&it, 0); it.current_y = 0; } @@ -5185,7 +5185,7 @@ and redisplay normally--don't erase and redraw the frame. */) SET_TEXT_POS (pt, PT, PT_BYTE); start_display (&it, w, pt); - move_it_vertically (&it, - window_box_height (w) / 2); + move_it_vertically_backward (&it, window_box_height (w) / 2); charpos = IT_CHARPOS (it); bytepos = IT_BYTEPOS (it); } @@ -5193,29 +5193,62 @@ and redisplay normally--don't erase and redraw the frame. */) { struct it it; struct text_pos pt; - int y0, y1, h, nlines; + int nlines = - XINT (arg); + int extra_line_spacing; + int h = window_box_height (w); SET_TEXT_POS (pt, PT, PT_BYTE); start_display (&it, w, pt); - y0 = it.current_y; + + /* Be sure we have the exact height of the full line containing PT. */ + move_it_by_lines (&it, 0, 1); /* The amount of pixels we have to move back is the window height minus what's displayed in the line containing PT, and the lines below. */ - nlines = - XINT (arg) - 1; + it.current_y = 0; + it.vpos = 0; move_it_by_lines (&it, nlines, 1); - y1 = line_bottom_y (&it); + if (it.vpos == nlines) + h -= it.current_y; + else + { + /* Last line has no newline */ + h -= line_bottom_y (&it); + it.vpos++; + } + + /* Don't reserve space for extra line spacing of last line. */ + extra_line_spacing = it.max_extra_line_spacing; /* If we can't move down NLINES lines because we hit the end of the buffer, count in some empty lines. */ if (it.vpos < nlines) - y1 += (nlines - it.vpos) * FRAME_LINE_HEIGHT (it.f); - - h = window_box_height (w) - (y1 - y0); + { + nlines -= it.vpos; + extra_line_spacing = it.extra_line_spacing; + h -= nlines * (FRAME_LINE_HEIGHT (it.f) + extra_line_spacing); + } + if (h <= 0) + return Qnil; + /* Now find the new top line (starting position) of the window. */ start_display (&it, w, pt); - move_it_vertically (&it, - h); + it.current_y = 0; + move_it_vertically_backward (&it, h); + + /* If extra line spacing is present, we may move too far + back. This causes the last line to be only partially + visible (which triggers redisplay to recenter that line + in the middle), so move forward. + But ignore extra line spacing on last line, as it is not + considered to be part of the visible height of the line. + */ + h += extra_line_spacing; + while (-it.current_y > h) + move_it_by_lines (&it, 1, 1); + charpos = IT_CHARPOS (it); bytepos = IT_BYTEPOS (it); } -- cgit v1.2.1