comparison src/window.c @ 37307:f028d889de06

(window_scroll): Change the meaning of N to mean N screen-fulls or N lines. (window_scroll_pixel_based, window_scroll_line_based) (scroll_command, Fscroll_other_window): Change accordingly.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 10 Apr 2001 16:13:02 +0000
parents 8381b1ef7f3a
children b1f9c6a7a002
comparison
equal deleted inserted replaced
37306:600d4fa98eb1 37307:f028d889de06
3913 /************************************************************************ 3913 /************************************************************************
3914 Window Scrolling 3914 Window Scrolling
3915 ***********************************************************************/ 3915 ***********************************************************************/
3916 3916
3917 /* Scroll contents of window WINDOW up. If WHOLE is non-zero, scroll 3917 /* Scroll contents of window WINDOW up. If WHOLE is non-zero, scroll
3918 one screen-full, which is defined as the height of the window minus 3918 N screen-fulls, which is defined as the height of the window minus
3919 next_screen_context_lines. If WHOLE is zero, scroll up N lines 3919 next_screen_context_lines. If WHOLE is zero, scroll up N lines
3920 instead. Negative values of N mean scroll down. NOERROR non-zero 3920 instead. Negative values of N mean scroll down. NOERROR non-zero
3921 means don't signal an error if we try to move over BEGV or ZV, 3921 means don't signal an error if we try to move over BEGV or ZV,
3922 respectively. */ 3922 respectively. */
3923 3923
4002 start_display (&it, w, start); 4002 start_display (&it, w, start);
4003 if (whole) 4003 if (whole)
4004 { 4004 {
4005 int screen_full = (window_box_height (w) 4005 int screen_full = (window_box_height (w)
4006 - next_screen_context_lines * CANON_Y_UNIT (it.f)); 4006 - next_screen_context_lines * CANON_Y_UNIT (it.f));
4007 int direction = n < 0 ? -1 : 1; 4007 int dy = n * screen_full;
4008 int dy = direction * screen_full;
4009 4008
4010 /* Note that move_it_vertically always moves the iterator to the 4009 /* Note that move_it_vertically always moves the iterator to the
4011 start of a line. So, if the last line doesn't have a newline, 4010 start of a line. So, if the last line doesn't have a newline,
4012 we would end up at the start of the line ending at ZV. */ 4011 we would end up at the start of the line ending at ZV. */
4013 if (dy <= 0) 4012 if (dy <= 0)
4147 Lisp_Object bolp; 4146 Lisp_Object bolp;
4148 int startpos; 4147 int startpos;
4149 struct position posit; 4148 struct position posit;
4150 int original_vpos; 4149 int original_vpos;
4151 4150
4151 /* If scrolling screen-fulls, compute the number of lines to
4152 scroll from the window's height. */
4153 if (whole)
4154 n *= max (1, ht - next_screen_context_lines);
4155
4152 startpos = marker_position (w->start); 4156 startpos = marker_position (w->start);
4153 4157
4154 posit = *compute_motion (startpos, 0, 0, 0, 4158 posit = *compute_motion (startpos, 0, 0, 0,
4155 PT, ht, 0, 4159 PT, ht, 0,
4156 window_internal_width (w), XINT (w->hscroll), 4160 window_internal_width (w), XINT (w->hscroll),
4278 static void 4282 static void
4279 scroll_command (n, direction) 4283 scroll_command (n, direction)
4280 Lisp_Object n; 4284 Lisp_Object n;
4281 int direction; 4285 int direction;
4282 { 4286 {
4283 register int defalt; 4287 int count = BINDING_STACK_SIZE ();
4284 int count = specpdl_ptr - specpdl;
4285 4288
4286 xassert (abs (direction) == 1); 4289 xassert (abs (direction) == 1);
4287 4290
4288 /* If selected window's buffer isn't current, make it current for 4291 /* If selected window's buffer isn't current, make it current for
4289 the moment. But don't screw up if window_scroll gets an error. */ 4292 the moment. But don't screw up if window_scroll gets an error. */
4294 4297
4295 /* Make redisplay consider other windows than just selected_window. */ 4298 /* Make redisplay consider other windows than just selected_window. */
4296 ++windows_or_buffers_changed; 4299 ++windows_or_buffers_changed;
4297 } 4300 }
4298 4301
4299 defalt = (window_internal_height (XWINDOW (selected_window))
4300 - next_screen_context_lines);
4301 defalt = direction * (defalt < 1 ? 1 : defalt);
4302
4303 if (NILP (n)) 4302 if (NILP (n))
4304 window_scroll (selected_window, defalt, 1, 0); 4303 window_scroll (selected_window, direction, 1, 0);
4305 else if (EQ (n, Qminus)) 4304 else if (EQ (n, Qminus))
4306 window_scroll (selected_window, - defalt, 1, 0); 4305 window_scroll (selected_window, -direction, 1, 0);
4307 else 4306 else
4308 { 4307 {
4309 n = Fprefix_numeric_value (n); 4308 n = Fprefix_numeric_value (n);
4310 window_scroll (selected_window, XINT (n) * direction, 0, 0); 4309 window_scroll (selected_window, XINT (n) * direction, 0, 0);
4311 } 4310 }
4393 If in the minibuffer, `minibuffer-scroll-window' if non-nil\n\ 4392 If in the minibuffer, `minibuffer-scroll-window' if non-nil\n\
4394 specifies the window to scroll.\n\ 4393 specifies the window to scroll.\n\
4395 If `other-window-scroll-buffer' is non-nil, scroll the window\n\ 4394 If `other-window-scroll-buffer' is non-nil, scroll the window\n\
4396 showing that buffer, popping the buffer up if necessary.") 4395 showing that buffer, popping the buffer up if necessary.")
4397 (arg) 4396 (arg)
4398 register Lisp_Object arg; 4397 Lisp_Object arg;
4399 { 4398 {
4400 register Lisp_Object window; 4399 Lisp_Object window;
4401 register int defalt; 4400 struct window *w;
4402 register struct window *w; 4401 int count = BINDING_STACK_SIZE ();
4403 register int count = specpdl_ptr - specpdl;
4404 4402
4405 window = Fother_window_for_scrolling (); 4403 window = Fother_window_for_scrolling ();
4406
4407 w = XWINDOW (window); 4404 w = XWINDOW (window);
4408 defalt = window_internal_height (w) - next_screen_context_lines;
4409 if (defalt < 1) defalt = 1;
4410 4405
4411 /* Don't screw up if window_scroll gets an error. */ 4406 /* Don't screw up if window_scroll gets an error. */
4412 record_unwind_protect (save_excursion_restore, save_excursion_save ()); 4407 record_unwind_protect (save_excursion_restore, save_excursion_save ());
4413 ++windows_or_buffers_changed; 4408 ++windows_or_buffers_changed;
4414 4409
4415 Fset_buffer (w->buffer); 4410 Fset_buffer (w->buffer);
4416 SET_PT (marker_position (w->pointm)); 4411 SET_PT (marker_position (w->pointm));
4417 4412
4418 if (NILP (arg)) 4413 if (NILP (arg))
4419 window_scroll (window, defalt, 1, 1); 4414 window_scroll (window, 1, 1, 1);
4420 else if (EQ (arg, Qminus)) 4415 else if (EQ (arg, Qminus))
4421 window_scroll (window, -defalt, 1, 1); 4416 window_scroll (window, -1, 1, 1);
4422 else 4417 else
4423 { 4418 {
4424 if (CONSP (arg)) 4419 if (CONSP (arg))
4425 arg = Fcar (arg); 4420 arg = Fcar (arg);
4426 CHECK_NUMBER (arg, 0); 4421 CHECK_NUMBER (arg, 0);