diff options
| author | Gerd Moellmann | 2001-03-07 17:17:07 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-03-07 17:17:07 +0000 |
| commit | 521b203e8562ba9a89e6cbf3a499ac1447723eb3 (patch) | |
| tree | 18bbaf248b5a20abf2171d158517f20c2e87a19b /src | |
| parent | 5b3ebb4432046e655b48a5953d760aeab9778fbb (diff) | |
| download | emacs-521b203e8562ba9a89e6cbf3a499ac1447723eb3.tar.gz emacs-521b203e8562ba9a89e6cbf3a499ac1447723eb3.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.c | 78 |
1 files changed, 58 insertions, 20 deletions
diff --git a/src/window.c b/src/window.c index b02cc6b7969..823461c2ba3 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -69,6 +69,7 @@ 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 *)); |
| @@ -4495,7 +4496,16 @@ displayed_window_lines (w) | |||
| 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); |
| @@ -4555,34 +4565,62 @@ and redisplay normally--don't erase and redraw the frame.") | |||
| 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 | { | ||
| 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 | { | 4572 | { |
| 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; |