comparison src/window.c @ 64114:51f6009d047b

(Frecenter): When arg is inside the scroll margin, move it out of the margin.
author Richard M. Stallman <rms@gnu.org>
date Wed, 06 Jul 2005 22:06:15 +0000
parents a8fa7c632ee4
children 7e06f331c228 24c69010999c f9a65d7ebd29
comparison
equal deleted inserted replaced
64113:247cbeeeba2a 64114:51f6009d047b
5331 struct window *w = XWINDOW (selected_window); 5331 struct window *w = XWINDOW (selected_window);
5332 struct buffer *buf = XBUFFER (w->buffer); 5332 struct buffer *buf = XBUFFER (w->buffer);
5333 struct buffer *obuf = current_buffer; 5333 struct buffer *obuf = current_buffer;
5334 int center_p = 0; 5334 int center_p = 0;
5335 int charpos, bytepos; 5335 int charpos, bytepos;
5336 int iarg;
5337 int this_scroll_margin;
5336 5338
5337 /* If redisplay is suppressed due to an error, try again. */ 5339 /* If redisplay is suppressed due to an error, try again. */
5338 obuf->display_error_modiff = 0; 5340 obuf->display_error_modiff = 0;
5339 5341
5340 if (NILP (arg)) 5342 if (NILP (arg))
5356 arg = Fprefix_numeric_value (arg); 5358 arg = Fprefix_numeric_value (arg);
5357 CHECK_NUMBER (arg); 5359 CHECK_NUMBER (arg);
5358 } 5360 }
5359 5361
5360 set_buffer_internal (buf); 5362 set_buffer_internal (buf);
5363
5364 /* Do this after making BUF current
5365 in case scroll_margin is buffer-local. */
5366 this_scroll_margin = max (0, scroll_margin);
5367 this_scroll_margin = min (this_scroll_margin,
5368 XFASTINT (w->total_lines) / 4);
5361 5369
5362 /* Handle centering on a graphical frame specially. Such frames can 5370 /* Handle centering on a graphical frame specially. Such frames can
5363 have variable-height lines and centering point on the basis of 5371 have variable-height lines and centering point on the basis of
5364 line counts would lead to strange effects. */ 5372 line counts would lead to strange effects. */
5365 if (FRAME_WINDOW_P (XFRAME (w->frame))) 5373 if (FRAME_WINDOW_P (XFRAME (w->frame)))
5373 start_display (&it, w, pt); 5381 start_display (&it, w, pt);
5374 move_it_vertically_backward (&it, window_box_height (w) / 2); 5382 move_it_vertically_backward (&it, window_box_height (w) / 2);
5375 charpos = IT_CHARPOS (it); 5383 charpos = IT_CHARPOS (it);
5376 bytepos = IT_BYTEPOS (it); 5384 bytepos = IT_BYTEPOS (it);
5377 } 5385 }
5378 else if (XINT (arg) < 0) 5386 else if (iarg < 0)
5379 { 5387 {
5380 struct it it; 5388 struct it it;
5381 struct text_pos pt; 5389 struct text_pos pt;
5382 int nlines = - XINT (arg); 5390 int nlines = -iarg;
5383 int extra_line_spacing; 5391 int extra_line_spacing;
5384 int h = window_box_height (w); 5392 int h = window_box_height (w);
5393
5394 iarg = XINT (arg);
5395 iarg = - max (-iarg, this_scroll_margin);
5385 5396
5386 SET_TEXT_POS (pt, PT, PT_BYTE); 5397 SET_TEXT_POS (pt, PT, PT_BYTE);
5387 start_display (&it, w, pt); 5398 start_display (&it, w, pt);
5388 5399
5389 /* Be sure we have the exact height of the full line containing PT. */ 5400 /* Be sure we have the exact height of the full line containing PT. */
5439 bytepos = IT_BYTEPOS (it); 5450 bytepos = IT_BYTEPOS (it);
5440 } 5451 }
5441 else 5452 else
5442 { 5453 {
5443 struct position pos; 5454 struct position pos;
5444 pos = *vmotion (PT, - XINT (arg), w); 5455
5456 iarg = XINT (arg);
5457 iarg = max (iarg, this_scroll_margin);
5458
5459 pos = *vmotion (PT, -iarg, w);
5445 charpos = pos.bufpos; 5460 charpos = pos.bufpos;
5446 bytepos = pos.bytepos; 5461 bytepos = pos.bytepos;
5447 } 5462 }
5448 } 5463 }
5449 else 5464 else
5450 { 5465 {
5451 struct position pos; 5466 struct position pos;
5452 int ht = window_internal_height (w); 5467 int ht = window_internal_height (w);
5453 5468
5454 if (center_p) 5469 if (center_p)
5455 arg = make_number (ht / 2); 5470 iarg = make_number (ht / 2);
5456 else if (XINT (arg) < 0) 5471 else if (XINT (arg) < 0)
5457 arg = make_number (XINT (arg) + ht); 5472 iarg = XINT (arg) + ht;
5458 5473 else
5459 pos = *vmotion (PT, - XINT (arg), w); 5474 iarg = XINT (arg);
5475
5476 /* Don't let it get into the margin at either top or bottom. */
5477 iarg = max (iarg, this_scroll_margin);
5478 iarg = min (iarg, ht - this_scroll_margin - 1);
5479
5480 pos = *vmotion (PT, - iarg, w);
5460 charpos = pos.bufpos; 5481 charpos = pos.bufpos;
5461 bytepos = pos.bytepos; 5482 bytepos = pos.bytepos;
5462 } 5483 }
5463 5484
5464 /* Set the new window start. */ 5485 /* Set the new window start. */
5503 Lisp_Object arg; 5524 Lisp_Object arg;
5504 { 5525 {
5505 struct window *w = XWINDOW (selected_window); 5526 struct window *w = XWINDOW (selected_window);
5506 int lines, start; 5527 int lines, start;
5507 Lisp_Object window; 5528 Lisp_Object window;
5529 #if 0
5530 int this_scroll_margin;
5531 #endif
5508 5532
5509 window = selected_window; 5533 window = selected_window;
5510 start = marker_position (w->start); 5534 start = marker_position (w->start);
5511 if (start < BEGV || start > ZV) 5535 if (start < BEGV || start > ZV)
5512 { 5536 {
5518 } 5542 }
5519 else 5543 else
5520 Fgoto_char (w->start); 5544 Fgoto_char (w->start);
5521 5545
5522 lines = displayed_window_lines (w); 5546 lines = displayed_window_lines (w);
5547
5548 #if 0
5549 this_scroll_margin = max (0, scroll_margin);
5550 this_scroll_margin = min (this_scroll_margin, lines / 4);
5551 #endif
5552
5523 if (NILP (arg)) 5553 if (NILP (arg))
5524 XSETFASTINT (arg, lines / 2); 5554 XSETFASTINT (arg, lines / 2);
5525 else 5555 else
5526 { 5556 {
5527 arg = Fprefix_numeric_value (arg); 5557 int iarg = XINT (Fprefix_numeric_value (arg));
5528 if (XINT (arg) < 0) 5558
5529 XSETINT (arg, XINT (arg) + lines); 5559 if (iarg < 0)
5560 iarg = iarg + lines;
5561
5562 #if 0 /* This code would prevent move-to-window-line from moving point
5563 to a place inside the scroll margins (which would cause the
5564 next redisplay to scroll). I wrote this code, but then concluded
5565 it is probably better not to install it. However, it is here
5566 inside #if 0 so as not to lose it. -- rms. */
5567
5568 /* Don't let it get into the margin at either top or bottom. */
5569 iarg = max (iarg, this_scroll_margin);
5570 iarg = min (iarg, lines - this_scroll_margin - 1);
5571 #endif
5572
5573 arg = make_number (iarg);
5530 } 5574 }
5531 5575
5532 /* Skip past a partially visible first line. */ 5576 /* Skip past a partially visible first line. */
5533 if (w->vscroll) 5577 if (w->vscroll)
5534 XSETINT (arg, XINT (arg) + 1); 5578 XSETINT (arg, XINT (arg) + 1);