aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Bader2000-12-08 18:12:48 +0000
committerMiles Bader2000-12-08 18:12:48 +0000
commit5cdb3cf38f1c0fbd8468fc54d77159bf0b6fa97d (patch)
treec2d29c71f7d867e4c677447ade532bf728f1b443
parent2103c9fb65e691687b538749fd3fe9e757475036 (diff)
downloademacs-5cdb3cf38f1c0fbd8468fc54d77159bf0b6fa97d.tar.gz
emacs-5cdb3cf38f1c0fbd8468fc54d77159bf0b6fa97d.zip
(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.
-rw-r--r--src/ChangeLog9
-rw-r--r--src/window.c101
2 files changed, 83 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f668b87e4d8..a665944fa97 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12000-12-09 Miles Bader <miles@gnu.org>
2
3 * window.c (Fpos_visible_in_window_p): Replace FULLY parameter
4 with PARTIALLY, inverting the sense.
5 (window_scroll_pixel_based): Scroll partially visible lines into
6 place if we hit the beginning or end of the buffer.
7 (displayed_window_lines): Don't include partially visible line at
8 bottom.
9
12000-12-08 Gerd Moellmann <gerd@gnu.org> 102000-12-08 Gerd Moellmann <gerd@gnu.org>
2 11
3 * keymap.c (current_minor_maps): Use malloc. Prevent a leak. 12 * keymap.c (current_minor_maps): Use malloc. Prevent a leak.
diff --git a/src/window.c b/src/window.c
index 708c0475636..3467be7edda 100644
--- a/src/window.c
+++ b/src/window.c
@@ -304,10 +304,11 @@ 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\
306Return nil if that position is scrolled vertically out of view.\n\ 306Return nil if that position is scrolled vertically out of view.\n\
307If FULLY is non-nil, then only return t when POS is completely visible.\n\ 307If a character is only partially visible, nil is returned, unless the\n\
308optional argument PARTIALLY is non-nil.\n\
308POS defaults to point in WINDOW; WINDOW defaults to the selected window.") 309POS 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;
@@ -341,9 +342,9 @@ POS defaults to point in WINDOW; WINDOW defaults to the selected window.")
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
@@ -356,8 +357,8 @@ POS defaults to point in WINDOW; WINDOW defaults to the selected window.")
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 }
@@ -3885,6 +3886,8 @@ window_scroll_pixel_based (window, n, whole, noerror)
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
@@ -3944,23 +3947,53 @@ window_scroll_pixel_based (window, n, whole, noerror)
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 {
3966 if (w->vscroll != 0)
3967 /* The first line was only partially visible, make it fully
3968 visible. */
3969 w->vscroll = 0;
3970 else if (noerror)
3971 return;
3972 else
3973 Fsignal (Qbeginning_of_buffer, Qnil);
3974 }
3975
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;
3953 } 3982 }
3954 3983
3955 /* Set the window start, and set up the window for redisplay. */ 3984 if (! vscrolled)
3956 set_marker_restricted (w->start, make_number (IT_CHARPOS (it)), w->buffer); 3985 {
3957 w->start_at_line_beg = Fbolp (); 3986 /* Set the window start, and set up the window for redisplay. */
3958 w->update_mode_line = Qt; 3987 set_marker_restricted (w->start, make_number (IT_CHARPOS (it)),
3959 XSETFASTINT (w->last_modified, 0); 3988 w->buffer);
3960 XSETFASTINT (w->last_overlay_modified, 0); 3989 w->start_at_line_beg = Fbolp ();
3961 /* Set force_start so that redisplay_window will run the 3990 w->update_mode_line = Qt;
3962 window-scroll-functions. */ 3991 XSETFASTINT (w->last_modified, 0);
3963 w->force_start = Qt; 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
@@ -3988,18 +4021,30 @@ window_scroll_pixel_based (window, n, whole, noerror)
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}
@@ -4437,9 +4482,11 @@ displayed_window_lines (w)
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}