Lisp_Object Vtemp_buffer_show_function;
+/* Non-zero means line and page scrolling on tall lines (with images)
+ does partial scrolling by modifying window-vscroll. */
+
+int auto_window_vscroll_p;
+
/* Non-zero means to use mode-line-inactive face in all windows but the
selected-window and the minibuffer-scroll-window when the
minibuffer is active. */
POS defaults to point in WINDOW; WINDOW defaults to the selected window.
If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
-return value is a list (X Y FULLY) where X and Y are the pixel coordinates
-relative to the top left corner of the window, and FULLY is t if the
-character after POS is fully visible and nil otherwise. */)
+return value is a list (X Y PARTIAL) where X and Y are the pixel coordinates
+relative to the top left corner of the window. PARTIAL is nil if the character
+after POS is fully visible; otherwise it is a cons (RTOP . RBOT) where RTOP
+and RBOT are the number of pixels invisible at the top and bottom of the row. */)
(pos, window, partially)
Lisp_Object pos, window, partially;
{
register struct buffer *buf;
struct text_pos top;
Lisp_Object in_window = Qnil;
- int fully_p = 1;
+ int rtop, rbot, fully_p = 1;
int x, y;
w = decode_window (window);
&& posint <= BUF_ZV (buf)
&& CHARPOS (top) >= BUF_BEGV (buf)
&& CHARPOS (top) <= BUF_ZV (buf)
- && pos_visible_p (w, posint, &fully_p, &x, &y, NILP (partially))
- && (!NILP (partially) || fully_p))
+ && pos_visible_p (w, posint, &x, &y, &rtop, &rbot, NILP (partially))
+ && (fully_p = !rtop && !rbot, (!NILP (partially) || fully_p)))
in_window = Qt;
if (!NILP (in_window) && !NILP (partially))
in_window = Fcons (make_number (x),
Fcons (make_number (y),
- Fcons (fully_p ? Qt : Qnil, Qnil)));
+ Fcons ((fully_p ? Qnil
+ : Fcons (make_number (rtop),
+ make_number (rbot))),
+ Qnil)));
return in_window;
}
: Qnil);
else if (EQ (*all_frames, Qvisible))
;
- else if (XFASTINT (*all_frames) == 0)
+ else if (EQ (*all_frames, make_number (0)))
;
else if (FRAMEP (*all_frames))
;
if (f)
frame_arg = Qlambda;
- else if (XFASTINT (frames) == 0)
+ else if (EQ (frames, make_number (0)))
frame_arg = frames;
else if (EQ (frames, Qvisible))
frame_arg = frames;
doc: /* Return the window least recently selected or used for display.
Return a full-width window if possible.
A minibuffer window is never a candidate.
+A dedicated window is never a candidate, so if all windows are dedicated,
+the value is nil.
If optional argument FRAME is `visible', search all visible frames.
If FRAME is 0, search all visible and iconified frames.
If FRAME is t, search all frames.
DEFUN ("get-largest-window", Fget_largest_window, Sget_largest_window, 0, 1, 0,
doc: /* Return the largest window in area.
A minibuffer window is never a candidate.
+A dedicated window is never a candidate, so if all windows are dedicated,
+the value is nil.
If optional argument FRAME is `visible', search all visible frames.
If FRAME is 0, search all visible and iconified frames.
If FRAME is t, search all frames.
start = it.current.pos;
}
+ else if (auto_window_vscroll_p)
+ {
+ if (tem = XCAR (XCDR (XCDR (tem))), CONSP (tem))
+ {
+ int px;
+ int dy = WINDOW_FRAME_LINE_HEIGHT (w);
+ if (whole)
+ dy = max ((window_box_height (w)
+ - next_screen_context_lines * dy),
+ dy);
+ dy *= n;
+
+ if (n < 0 && (px = XINT (XCAR (tem))) > 0)
+ {
+ px = max (0, -w->vscroll - min (px, -dy));
+ Fset_window_vscroll (window, make_number (px), Qt);
+ return;
+ }
+ if (n > 0 && (px = XINT (XCDR (tem))) > 0)
+ {
+ px = max (0, -w->vscroll + min (px, dy));
+ Fset_window_vscroll (window, make_number (px), Qt);
+ return;
+ }
+ }
+ Fset_window_vscroll (window, make_number (0), Qt);
+ }
/* 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. */
start_display (&it, w, start);
if (whole)
{
- int screen_full = (window_box_height (w)
- - next_screen_context_lines * FRAME_LINE_HEIGHT (it.f));
- int dy = n * screen_full;
+ int start_pos = IT_CHARPOS (it);
+ int dy = WINDOW_FRAME_LINE_HEIGHT (w);
+ dy = max ((window_box_height (w)
+ - next_screen_context_lines * dy),
+ dy) * n;
/* Note that move_it_vertically always moves the iterator to the
start of a line. So, if the last line doesn't have a newline,
we would end up at the start of the line ending at ZV. */
if (dy <= 0)
- move_it_vertically_backward (&it, -dy);
+ {
+ move_it_vertically_backward (&it, -dy);
+ /* Ensure we actually does move, e.g. in case we are currently
+ looking at an image that is taller that the window height. */
+ while (start_pos == IT_CHARPOS (it)
+ && start_pos > BEGV)
+ move_it_by_lines (&it, -1, 1);
+ }
else if (dy > 0)
- move_it_to (&it, ZV, -1, it.current_y + dy, -1,
- MOVE_TO_POS | MOVE_TO_Y);
+ {
+ move_it_to (&it, ZV, -1, it.current_y + dy, -1,
+ MOVE_TO_POS | MOVE_TO_Y);
+ /* Ensure we actually does move, e.g. in case we are currently
+ looking at an image that is taller that the window height. */
+ while (start_pos == IT_CHARPOS (it)
+ && start_pos < ZV)
+ move_it_by_lines (&it, 1, 1);
+ }
}
else
move_it_by_lines (&it, n, 1);
not including the height of the header line if any. */
it.current_y = it.vpos = 0;
- /* Preserve the screen position if we should. */
- if (preserve_y >= 0)
- {
- /* If we have a header line, take account of it. */
- if (WINDOW_WANTS_HEADER_LINE_P (w))
- preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
+ /* Move PT out of scroll margins.
+ This code wants current_y to be zero at the window start position
+ even if there is a header line. */
+ this_scroll_margin = max (0, scroll_margin);
+ this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
+ this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
- move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
- SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
- }
- else
+ if (n > 0)
{
- /* Move PT out of scroll margins.
- This code wants current_y to be zero at the window start position
- even if there is a header line. */
- this_scroll_margin = max (0, scroll_margin);
- this_scroll_margin = min (this_scroll_margin, XFASTINT (w->total_lines) / 4);
- this_scroll_margin *= FRAME_LINE_HEIGHT (it.f);
-
- if (n > 0)
+ /* We moved the window start towards ZV, so PT may be now
+ in the scroll margin at the top. */
+ move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
+ if (IT_CHARPOS (it) == PT && it.current_y >= this_scroll_margin)
+ /* We found PT at a legitimate height. Leave it alone. */
+ ;
+ else if (preserve_y >= 0)
+ {
+ /* If we have a header line, take account of it.
+ This is necessary because we set it.current_y to 0, above. */
+ if (WINDOW_WANTS_HEADER_LINE_P (w))
+ preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
+
+ move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
+ SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
+ }
+ else
{
- /* We moved the window start towards ZV, so PT may be now
- in the scroll margin at the top. */
- move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
while (it.current_y < this_scroll_margin)
{
int prev = it.current_y;
}
SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
}
- else if (n < 0)
+ }
+ else if (n < 0)
+ {
+ int charpos, bytepos;
+ int partial_p;
+
+ /* Save our position, for the preserve_y case. */
+ charpos = IT_CHARPOS (it);
+ bytepos = IT_BYTEPOS (it);
+
+ /* We moved the window start towards BEGV, so PT may be now
+ in the scroll margin at the bottom. */
+ move_it_to (&it, PT, -1,
+ it.last_visible_y - this_scroll_margin - 1, -1,
+ MOVE_TO_POS | MOVE_TO_Y);
+
+ /* Save our position, in case it's correct. */
+ charpos = IT_CHARPOS (it);
+ bytepos = IT_BYTEPOS (it);
+
+ /* See if point is on a partially visible line at the end. */
+ if (it.what == IT_EOB)
+ partial_p = it.current_y + it.ascent + it.descent > it.last_visible_y;
+ else
{
- int charpos, bytepos;
-
- /* We moved the window start towards BEGV, so PT may be now
- in the scroll margin at the bottom. */
- move_it_to (&it, PT, -1,
- it.last_visible_y - this_scroll_margin - 1, -1,
- MOVE_TO_POS | MOVE_TO_Y);
+ move_it_by_lines (&it, 1, 1);
+ partial_p = it.current_y > it.last_visible_y;
+ }
- /* Save our position, in case it's correct. */
- charpos = IT_CHARPOS (it);
- bytepos = IT_BYTEPOS (it);
+ if (charpos == PT && !partial_p)
+ /* We found PT before we found the display margin, so PT is ok. */
+ ;
+ else if (preserve_y >= 0)
+ {
+ SET_TEXT_POS_FROM_MARKER (start, w->start);
+ start_display (&it, w, start);
+#if 0 /* It's wrong to subtract this here
+ because we called start_display again
+ and did not alter it.current_y this time. */
+
+ /* If we have a header line, take account of it. */
+ if (WINDOW_WANTS_HEADER_LINE_P (w))
+ preserve_y -= CURRENT_HEADER_LINE_HEIGHT (w);
+#endif
- /* See if point is on a partially visible line at the end. */
- move_it_by_lines (&it, 1, 1);
- if (it.current_y > it.last_visible_y)
+ move_it_to (&it, -1, -1, preserve_y, -1, MOVE_TO_Y);
+ SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it));
+ }
+ else
+ {
+ if (partial_p)
/* The last line was only partially visible, so back up two
lines to make sure we're on a fully visible line. */
{
struct window *w = decode_window (window);
if (!NILP (width))
- CHECK_NATNUM (width);
+ {
+ CHECK_NATNUM (width);
- if (XINT (width) == 0)
- vertical_type = Qnil;
+ if (XINT (width) == 0)
+ vertical_type = Qnil;
+ }
if (!(EQ (vertical_type, Qnil)
|| EQ (vertical_type, Qleft)
: XFLOATINT (vscroll));
w->vscroll = min (w->vscroll, 0);
- /* Adjust glyph matrix of the frame if the virtual display
- area becomes larger than before. */
- if (w->vscroll < 0 && w->vscroll < old_dy)
- adjust_glyphs (f);
+ if (w->vscroll != old_dy)
+ {
+ /* Adjust glyph matrix of the frame if the virtual display
+ area becomes larger than before. */
+ if (w->vscroll < 0 && w->vscroll < old_dy)
+ adjust_glyphs (f);
- /* Prevent redisplay shortcuts. */
- XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
+ /* Prevent redisplay shortcuts. */
+ XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
+ }
}
return Fwindow_vscroll (window, pixels_p);
doc: /* *Non-nil means `display-buffer' should make a separate frame. */);
pop_up_frames = 0;
+ DEFVAR_BOOL ("auto-window-vscroll", &auto_window_vscroll_p,
+ doc: /* *Non-nil means to automatically adjust `window-vscroll' to view tall lines. */);
+ auto_window_vscroll_p = 1;
+
DEFVAR_BOOL ("display-buffer-reuse-frames", &display_buffer_reuse_frames,
doc: /* *Non-nil means `display-buffer' should reuse frames.
If the buffer in question is already displayed in a frame, raise that frame. */);
DEFVAR_LISP ("scroll-preserve-screen-position",
&Vscroll_preserve_screen_position,
- doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged. */);
+ doc: /* *Non-nil means scroll commands move point to keep its screen line unchanged.
+This is only when it is impossible to keep point fixed and still
+scroll as specified. */);
Vscroll_preserve_screen_position = Qnil;
DEFVAR_LISP ("window-configuration-change-hook",