aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2000-10-21 07:57:20 +0000
committerMiles Bader2000-10-21 07:57:20 +0000
commit81e4d4652c51b98e90f39ef62048961dc2fca903 (patch)
tree4d6a3064918bd68e7a2b9a42b293be4409bcc7ef /src
parentfeb5013d7cb2a3604b0a1f8bab63e57bfb56723a (diff)
downloademacs-81e4d4652c51b98e90f39ef62048961dc2fca903.tar.gz
emacs-81e4d4652c51b98e90f39ef62048961dc2fca903.zip
(pos_fully_visible_in_window_p):
New function. (Fpos_visible_in_window_p): Add FULLY argument. Use pos_fully_visible_in_window_p. (window_scroll_pixel_based, window_scroll_line_based): Update calls to Fpos_visible_in_window_p.
Diffstat (limited to 'src')
-rw-r--r--src/window.c73
1 files changed, 64 insertions, 9 deletions
diff --git a/src/window.c b/src/window.c
index c196937ed7b..215ceea847f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -290,13 +290,52 @@ DEFUN ("window-minibuffer-p", Fwindow_minibuffer_p, Swindow_minibuffer_p, 0, 1,
290 return (MINI_WINDOW_P (w) ? Qt : Qnil); 290 return (MINI_WINDOW_P (w) ? Qt : Qnil);
291} 291}
292 292
293
294/* Return true if POS is fully visible in the window W. If W's end
295 position is not known, then return false. */
296
297static int
298pos_fully_visible_in_window_p (pos, w)
299 int pos;
300 struct window *w;
301{
302 struct glyph_row *first_row = &w->desired_matrix->rows[0];
303 struct glyph_row *last_row;
304
305 if (pos < first_row->start.pos.charpos)
306 /* POS is before the beginning of W. */
307 return 0;
308 else if (pos < first_row->end.pos.charpos)
309 /* POS is on the first row of W, so see if that row is fully visible. */
310 return !MATRIX_ROW_PARTIALLY_VISIBLE_P (first_row);
311
312 if (NILP (w->window_end_valid))
313 /* We can't determine where the end is, so we don't know. */
314 return 0;
315
316 last_row = &w->desired_matrix->rows[XFASTINT (w->window_end_vpos)];
317
318 if (pos < last_row->start.pos.charpos)
319 /* POS is somewhere in the middle of the window, not on the first or
320 last row, so it must be visible. */
321 return 1;
322 else if (pos >= last_row->end.pos.charpos)
323 /* POS is after the end of W. */
324 return 0;
325 else
326 /* POS is on the last row of W, so see if that row is fully visible. */
327 return !MATRIX_ROW_PARTIALLY_VISIBLE_P (last_row);
328}
329
330
293DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, 331DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p,
294 Spos_visible_in_window_p, 0, 2, 0, 332 Spos_visible_in_window_p, 0, 3, 0,
295 "Return t if position POS is currently on the frame in WINDOW.\n\ 333 "Return t if position POS is currently on the frame in WINDOW.\n\
296Returns nil if that position is scrolled vertically out of view.\n\ 334Returns nil if that position is scrolled vertically out of view.\n\
335If FULLY is non-nil, then only return t when POS is completely visible.\n\
297POS defaults to point; WINDOW, to the selected window.") 336POS defaults to point; WINDOW, to the selected window.")
298 (pos, window) 337 (pos, window, fully)
299 Lisp_Object pos, window; 338 Lisp_Object pos, window, fully;
300{ 339{
301 register struct window *w; 340 register struct window *w;
302 register int posint; 341 register int posint;
@@ -320,13 +359,18 @@ POS defaults to point; WINDOW, to the selected window.")
320 if (posint < CHARPOS (top)) 359 if (posint < CHARPOS (top))
321 in_window = Qnil; 360 in_window = Qnil;
322 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) 361 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf)
323 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf) 362 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf)
324 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) 363 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos))
325 /* If frame is up to date, and POSINT is < window end pos, use 364 /* If frame is up to date, and POSINT is < window end pos, use
326 that info. This doesn't work for POSINT == end pos, because 365 that info. This doesn't work for POSINT == end pos, because
327 the window end pos is actually the position _after_ the last 366 the window end pos is actually the position _after_ the last
328 char in the window. */ 367 char in the window. */
329 in_window = Qt; 368 {
369 if (NILP (fully) || pos_fully_visible_in_window_p (posint, w))
370 in_window = Qt;
371 else
372 in_window = Qnil;
373 }
330 else if (posint > BUF_ZV (buf)) 374 else if (posint > BUF_ZV (buf))
331 in_window = Qnil; 375 in_window = Qnil;
332 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf)) 376 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))
@@ -338,7 +382,18 @@ POS defaults to point; WINDOW, to the selected window.")
338 start_display (&it, w, top); 382 start_display (&it, w, top);
339 move_it_to (&it, posint, 0, it.last_visible_y, -1, 383 move_it_to (&it, posint, 0, it.last_visible_y, -1,
340 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); 384 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
341 in_window = IT_CHARPOS (it) == posint ? Qt : Qnil; 385 if (IT_CHARPOS (it) == posint)
386 {
387 if (NILP (fully))
388 in_window = Qt;
389 else
390 {
391 struct glyph_row *pos_row = &w->desired_matrix->rows[it.vpos];
392 return MATRIX_ROW_PARTIALLY_VISIBLE_P(pos_row) ? Qnil : Qt;
393 }
394 }
395 else
396 in_window = Qnil;
342 } 397 }
343 398
344 return in_window; 399 return in_window;
@@ -3784,7 +3839,7 @@ window_scroll_pixel_based (window, n, whole, noerror)
3784 /* If PT is not visible in WINDOW, move back one half of 3839 /* If PT is not visible in WINDOW, move back one half of
3785 the screen. */ 3840 the screen. */
3786 XSETFASTINT (tem, PT); 3841 XSETFASTINT (tem, PT);
3787 tem = Fpos_visible_in_window_p (tem, window); 3842 tem = Fpos_visible_in_window_p (tem, window, Qt);
3788 if (NILP (tem)) 3843 if (NILP (tem))
3789 { 3844 {
3790 /* Move backward half the height of the window. Performance note: 3845 /* Move backward half the height of the window. Performance note:
@@ -3928,7 +3983,7 @@ window_scroll_line_based (window, n, whole, noerror)
3928 original_vpos = posit.vpos; 3983 original_vpos = posit.vpos;
3929 3984
3930 XSETFASTINT (tem, PT); 3985 XSETFASTINT (tem, PT);
3931 tem = Fpos_visible_in_window_p (tem, window); 3986 tem = Fpos_visible_in_window_p (tem, window, Qt);
3932 3987
3933 if (NILP (tem)) 3988 if (NILP (tem))
3934 { 3989 {