comparison src/window.c @ 36635:f85346ef86be

(Frecenter): Rewrite code handling negative values of ARG on graphical frames. (displayed_window_lines): If W->start is outside the accessible portion of the buffer, call start_display with BEGV or ZV instead of W->start.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 07 Mar 2001 17:17:07 +0000
parents bd660efb3fe7
children 126bac1a4495
comparison
equal deleted inserted replaced
36634:f3706ac7b437 36635:f85346ef86be
67 67
68 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p; 68 Lisp_Object Qwindowp, Qwindow_live_p, Qwindow_configuration_p;
69 Lisp_Object Qwindow_size_fixed, Qleft_fringe, Qright_fringe; 69 Lisp_Object Qwindow_size_fixed, Qleft_fringe, Qright_fringe;
70 extern Lisp_Object Qheight, Qwidth; 70 extern Lisp_Object Qheight, Qwidth;
71 71
72 static int displayed_window_lines P_ ((struct window *));
72 static struct window *decode_window P_ ((Lisp_Object)); 73 static struct window *decode_window P_ ((Lisp_Object));
73 static Lisp_Object select_window_1 P_ ((Lisp_Object, int)); 74 static Lisp_Object select_window_1 P_ ((Lisp_Object, int));
74 static int count_windows P_ ((struct window *)); 75 static int count_windows P_ ((struct window *));
75 static int get_leaf_windows P_ ((struct window *, struct window **, int)); 76 static int get_leaf_windows P_ ((struct window *, struct window **, int));
76 static void window_scroll P_ ((Lisp_Object, int, int, int)); 77 static void window_scroll P_ ((Lisp_Object, int, int, int));
4493 set_buffer_internal (XBUFFER (w->buffer)); 4494 set_buffer_internal (XBUFFER (w->buffer));
4494 } 4495 }
4495 else 4496 else
4496 old_buffer = NULL; 4497 old_buffer = NULL;
4497 4498
4498 SET_TEXT_POS_FROM_MARKER (start, w->start); 4499 /* In case W->start is out of the accessible range, do something
4500 reasonable. This happens in Info mode when Info-scroll-down
4501 calls (recenter -1) while W->start is 1. */
4502 if (XMARKER (w->start)->charpos < BEGV)
4503 SET_TEXT_POS (start, BEGV, BEGV_BYTE);
4504 else if (XMARKER (w->start)->charpos > ZV)
4505 SET_TEXT_POS (start, ZV, ZV_BYTE);
4506 else
4507 SET_TEXT_POS_FROM_MARKER (start, w->start);
4508
4499 start_display (&it, w, start); 4509 start_display (&it, w, start);
4500 move_it_vertically (&it, height); 4510 move_it_vertically (&it, height);
4501 bottom_y = line_bottom_y (&it); 4511 bottom_y = line_bottom_y (&it);
4502 4512
4503 /* Add in empty lines at the bottom of the window. */ 4513 /* Add in empty lines at the bottom of the window. */
4553 CHECK_NUMBER (arg, 0); 4563 CHECK_NUMBER (arg, 0);
4554 } 4564 }
4555 4565
4556 set_buffer_internal (buf); 4566 set_buffer_internal (buf);
4557 4567
4558 /* Handle centering on a gfaphical frame specially. Such frames can 4568 /* Handle centering on a graphical frame specially. Such frames can
4559 have variable-height lines and centering point on the basis of 4569 have variable-height lines and centering point on the basis of
4560 line counts would lead to strange effects. */ 4570 line counts would lead to strange effects. */
4561 if (center_p && FRAME_WINDOW_P (XFRAME (w->frame))) 4571 if (FRAME_WINDOW_P (XFRAME (w->frame)))
4562 { 4572 {
4563 struct it it;
4564 struct text_pos pt;
4565
4566 SET_TEXT_POS (pt, PT, PT_BYTE);
4567 start_display (&it, w, pt);
4568 move_it_vertically (&it, - it.last_visible_y / 2);
4569 charpos = IT_CHARPOS (it);
4570 bytepos = IT_BYTEPOS (it);
4571 }
4572 else
4573 {
4574 struct position pos;
4575
4576 if (center_p) 4573 if (center_p)
4577 { 4574 {
4578 int ht = displayed_window_lines (w); 4575 struct it it;
4579 arg = make_number (ht / 2); 4576 struct text_pos pt;
4577
4578 SET_TEXT_POS (pt, PT, PT_BYTE);
4579 start_display (&it, w, pt);
4580 move_it_vertically (&it, - it.last_visible_y / 2);
4581 charpos = IT_CHARPOS (it);
4582 bytepos = IT_BYTEPOS (it);
4580 } 4583 }
4581 else if (XINT (arg) < 0) 4584 else if (XINT (arg) < 0)
4582 { 4585 {
4583 int ht = displayed_window_lines (w); 4586 struct it it;
4584 XSETINT (arg, XINT (arg) + ht); 4587 struct text_pos pt;
4588 int y0, y1, h;
4589
4590 SET_TEXT_POS (pt, PT, PT_BYTE);
4591 start_display (&it, w, pt);
4592 y0 = it.current_y;
4593
4594 /* The amount of pixels we have to move hack is the window
4595 height minus what's displayed in the line containing PT,
4596 and the lines below. */
4597 move_it_by_lines (&it, - XINT (arg) - 1, 1);
4598 y1 = it.current_y - y0;
4599 h = line_bottom_y (&it) - y1;
4600 y0 = it.last_visible_y - y1 - h;
4601
4602 start_display (&it, w, pt);
4603 move_it_vertically (&it, - y0);
4604 charpos = IT_CHARPOS (it);
4605 bytepos = IT_BYTEPOS (it);
4585 } 4606 }
4607 else
4608 {
4609 struct position pos;
4610 pos = *vmotion (PT, - XINT (arg), w);
4611 charpos = pos.bufpos;
4612 bytepos = pos.bytepos;
4613 }
4614 }
4615 else
4616 {
4617 struct position pos;
4618 int ht = window_internal_height (w);
4619
4620 if (center_p)
4621 arg = make_number (ht / 2);
4622 else if (XINT (arg) < 0)
4623 arg = make_number (XINT (arg) + ht);
4586 4624
4587 pos = *vmotion (PT, - XINT (arg), w); 4625 pos = *vmotion (PT, - XINT (arg), w);
4588 charpos = pos.bufpos; 4626 charpos = pos.bufpos;
4589 bytepos = pos.bytepos; 4627 bytepos = pos.bytepos;
4590 } 4628 }