Mercurial > emacs
comparison src/window.c @ 34381:f9d7bc96177b
(Fpos_visible_in_window_p): Replace FULLY parameter with PARTIALLY,
inverting the sense.
(window_scroll_pixel_based): Scroll partially visible lines into place
if we hit the beginning or end of the buffer.
(displayed_window_lines): Don't include partially visible line at bottom.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 08 Dec 2000 18:10:29 +0000 |
parents | a97360f46398 |
children | 9669bb49fca2 |
comparison
equal
deleted
inserted
replaced
34380:45cb6948fefa | 34381:f9d7bc96177b |
---|---|
302 | 302 |
303 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, | 303 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, |
304 Spos_visible_in_window_p, 0, 3, 0, | 304 Spos_visible_in_window_p, 0, 3, 0, |
305 "Return t if position POS is currently on the frame in WINDOW.\n\ | 305 "Return t if position POS is currently on the frame in WINDOW.\n\ |
306 Return nil if that position is scrolled vertically out of view.\n\ | 306 Return nil if that position is scrolled vertically out of view.\n\ |
307 If FULLY is non-nil, then only return t when POS is completely visible.\n\ | 307 If a character is only partially visible, nil is returned, unless the\n\ |
308 optional argument PARTIALLY is non-nil.\n\ | |
308 POS defaults to point in WINDOW; WINDOW defaults to the selected window.") | 309 POS defaults to point in WINDOW; WINDOW defaults to the selected window.") |
309 (pos, window, fully) | 310 (pos, window, partially) |
310 Lisp_Object pos, window, fully; | 311 Lisp_Object pos, window, partially; |
311 { | 312 { |
312 register struct window *w; | 313 register struct window *w; |
313 register int posint; | 314 register int posint; |
314 register struct buffer *buf; | 315 register struct buffer *buf; |
315 struct text_pos top; | 316 struct text_pos top; |
339 { | 340 { |
340 /* If frame is up-to-date, and POSINT is < window end pos, use | 341 /* If frame is up-to-date, and POSINT is < window end pos, use |
341 that info. This doesn't work for POSINT == end pos, because | 342 that info. This doesn't work for POSINT == end pos, because |
342 the window end pos is actually the position _after_ the last | 343 the window end pos is actually the position _after_ the last |
343 char in the window. */ | 344 char in the window. */ |
344 if (!NILP (fully)) | 345 if (NILP (partially)) |
345 { | 346 { |
346 pos_visible_p (w, posint, &fully_p, !NILP (fully)); | 347 pos_visible_p (w, posint, &fully_p, NILP (partially)); |
347 in_window = fully_p ? Qt : Qnil; | 348 in_window = fully_p ? Qt : Qnil; |
348 } | 349 } |
349 else | 350 else |
350 in_window = Qt; | 351 in_window = Qt; |
351 } | 352 } |
354 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf)) | 355 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf)) |
355 /* If window start is out of range, do something reasonable. */ | 356 /* If window start is out of range, do something reasonable. */ |
356 in_window = Qnil; | 357 in_window = Qnil; |
357 else | 358 else |
358 { | 359 { |
359 if (pos_visible_p (w, posint, &fully_p, !NILP (fully))) | 360 if (pos_visible_p (w, posint, &fully_p, NILP (partially))) |
360 in_window = NILP (fully) || fully_p ? Qt : Qnil; | 361 in_window = !NILP (partially) || fully_p ? Qt : Qnil; |
361 else | 362 else |
362 in_window = Qnil; | 363 in_window = Qnil; |
363 } | 364 } |
364 | 365 |
365 return in_window; | 366 return in_window; |
3883 struct window *w = XWINDOW (window); | 3884 struct window *w = XWINDOW (window); |
3884 struct text_pos start; | 3885 struct text_pos start; |
3885 Lisp_Object tem; | 3886 Lisp_Object tem; |
3886 int this_scroll_margin; | 3887 int this_scroll_margin; |
3887 int preserve_y; | 3888 int preserve_y; |
3889 /* True if we fiddled the window vscroll field without really scrolling. */ | |
3890 int vscrolled = 0; | |
3888 | 3891 |
3889 SET_TEXT_POS_FROM_MARKER (start, w->start); | 3892 SET_TEXT_POS_FROM_MARKER (start, w->start); |
3890 | 3893 |
3891 /* If PT is not visible in WINDOW, move back one half of | 3894 /* If PT is not visible in WINDOW, move back one half of |
3892 the screen. */ | 3895 the screen. */ |
3942 | 3945 |
3943 /* End if we end up at ZV or BEGV. */ | 3946 /* End if we end up at ZV or BEGV. */ |
3944 if ((n > 0 && IT_CHARPOS (it) == ZV) | 3947 if ((n > 0 && IT_CHARPOS (it) == ZV) |
3945 || (n < 0 && IT_CHARPOS (it) == CHARPOS (start))) | 3948 || (n < 0 && IT_CHARPOS (it) == CHARPOS (start))) |
3946 { | 3949 { |
3947 if (noerror) | 3950 if (IT_CHARPOS (it) == ZV) |
3948 return; | 3951 { |
3949 else if (IT_CHARPOS (it) == ZV) | 3952 if (it.current_y + it.max_ascent + it.max_descent |
3950 Fsignal (Qend_of_buffer, Qnil); | 3953 > it.last_visible_y) |
3954 /* The last line was only partially visible, make it fully | |
3955 visible. */ | |
3956 w->vscroll = | |
3957 it.last_visible_y | |
3958 - it.current_y + it.max_ascent + it.max_descent; | |
3959 else if (noerror) | |
3960 return; | |
3961 else | |
3962 Fsignal (Qend_of_buffer, Qnil); | |
3963 } | |
3951 else | 3964 else |
3952 Fsignal (Qbeginning_of_buffer, Qnil); | 3965 { |
3953 } | 3966 if (w->vscroll != 0) |
3954 | 3967 /* The first line was only partially visible, make it fully |
3955 /* Set the window start, and set up the window for redisplay. */ | 3968 visible. */ |
3956 set_marker_restricted (w->start, make_number (IT_CHARPOS (it)), w->buffer); | 3969 w->vscroll = 0; |
3957 w->start_at_line_beg = Fbolp (); | 3970 else if (noerror) |
3958 w->update_mode_line = Qt; | 3971 return; |
3959 XSETFASTINT (w->last_modified, 0); | 3972 else |
3960 XSETFASTINT (w->last_overlay_modified, 0); | 3973 Fsignal (Qbeginning_of_buffer, Qnil); |
3961 /* Set force_start so that redisplay_window will run the | 3974 } |
3962 window-scroll-functions. */ | 3975 |
3963 w->force_start = Qt; | 3976 /* If control gets here, then we vscrolled. */ |
3977 | |
3978 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; | |
3979 | |
3980 /* Don't try to change the window start below. */ | |
3981 vscrolled = 1; | |
3982 } | |
3983 | |
3984 if (! vscrolled) | |
3985 { | |
3986 /* Set the window start, and set up the window for redisplay. */ | |
3987 set_marker_restricted (w->start, make_number (IT_CHARPOS (it)), | |
3988 w->buffer); | |
3989 w->start_at_line_beg = Fbolp (); | |
3990 w->update_mode_line = Qt; | |
3991 XSETFASTINT (w->last_modified, 0); | |
3992 XSETFASTINT (w->last_overlay_modified, 0); | |
3993 /* Set force_start so that redisplay_window will run the | |
3994 window-scroll-functions. */ | |
3995 w->force_start = Qt; | |
3996 } | |
3964 | 3997 |
3965 it.current_y = it.vpos = 0; | 3998 it.current_y = it.vpos = 0; |
3966 | 3999 |
3967 /* Preserve the screen position if we must. */ | 4000 /* Preserve the screen position if we must. */ |
3968 if (preserve_y >= 0) | 4001 if (preserve_y >= 0) |
3986 move_it_by_lines (&it, 1, 1); | 4019 move_it_by_lines (&it, 1, 1); |
3987 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 4020 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
3988 } | 4021 } |
3989 else if (n < 0) | 4022 else if (n < 0) |
3990 { | 4023 { |
4024 int charpos, bytepos; | |
4025 | |
3991 /* We moved the window start towards BEGV, so PT may be now | 4026 /* We moved the window start towards BEGV, so PT may be now |
3992 in the scroll margin at the bottom. */ | 4027 in the scroll margin at the bottom. */ |
3993 move_it_to (&it, PT, -1, | 4028 move_it_to (&it, PT, -1, |
3994 it.last_visible_y - this_scroll_margin - 1, -1, | 4029 it.last_visible_y - this_scroll_margin - 1, -1, |
3995 MOVE_TO_POS | MOVE_TO_Y); | 4030 MOVE_TO_POS | MOVE_TO_Y); |
4031 | |
4032 /* Save our position, in case it's correct. */ | |
4033 charpos = IT_CHARPOS (it); | |
4034 bytepos = IT_BYTEPOS (it); | |
3996 | 4035 |
3997 /* Don't put point on a partially visible line at the end. */ | 4036 /* See if point is on a partially visible line at the end. */ |
3998 if (it.current_y + it.max_ascent + it.max_descent | 4037 move_it_by_lines (&it, 1, 1); |
3999 > it.last_visible_y) | 4038 if (it.current_y > it.last_visible_y) |
4000 move_it_by_lines (&it, -1, 0); | 4039 /* The last line was only partially visible, so back up two |
4001 | 4040 lines to make sure we're on a fully visible line. */ |
4002 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 4041 { |
4042 move_it_by_lines (&it, -2, 0); | |
4043 SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | |
4044 } | |
4045 else | |
4046 /* No, the position we saved is OK, so use it. */ | |
4047 SET_PT_BOTH (charpos, bytepos); | |
4003 } | 4048 } |
4004 } | 4049 } |
4005 } | 4050 } |
4006 | 4051 |
4007 | 4052 |
4435 struct frame *f = XFRAME (w->frame); | 4480 struct frame *f = XFRAME (w->frame); |
4436 int rest = height - bottom_y; | 4481 int rest = height - bottom_y; |
4437 int lines = (rest + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f); | 4482 int lines = (rest + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f); |
4438 it.vpos += lines; | 4483 it.vpos += lines; |
4439 } | 4484 } |
4485 #if 0 | |
4440 else if (it.current_y < height && bottom_y > height) | 4486 else if (it.current_y < height && bottom_y > height) |
4441 /* Partially visible line at the bottom. */ | 4487 /* Partially visible line at the bottom. */ |
4442 ++it.vpos; | 4488 ++it.vpos; |
4489 #endif | |
4443 | 4490 |
4444 return it.vpos; | 4491 return it.vpos; |
4445 } | 4492 } |
4446 | 4493 |
4447 | 4494 |