aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-01-02 15:32:31 +0000
committerGerd Moellmann2001-01-02 15:32:31 +0000
commit6df47b592ae005750e25cd3632d17cae4f263758 (patch)
tree8e5d27560ee9aca8b80b0d4e293a030d6fcb503e /src
parente6a0814f1803e0441cbaf56710cd30174a7c3d6b (diff)
downloademacs-6df47b592ae005750e25cd3632d17cae4f263758.tar.gz
emacs-6df47b592ae005750e25cd3632d17cae4f263758.zip
(Frecenter): Handle centering in graphical frames
specially. Centering on the basis of line counts doesn't work reliably with variable-height lines.
Diffstat (limited to 'src')
-rw-r--r--src/window.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/src/window.c b/src/window.c
index e6bee7b04d0..af5e61bef85 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4488,15 +4488,14 @@ redraws with point in the center of the current window.")
4488 (arg) 4488 (arg)
4489 register Lisp_Object arg; 4489 register Lisp_Object arg;
4490{ 4490{
4491 register struct window *w = XWINDOW (selected_window); 4491 struct window *w = XWINDOW (selected_window);
4492 register int ht = displayed_window_lines (w);
4493 struct position pos;
4494 struct buffer *buf = XBUFFER (w->buffer); 4492 struct buffer *buf = XBUFFER (w->buffer);
4495 struct buffer *obuf = current_buffer; 4493 struct buffer *obuf = current_buffer;
4494 int center_p = 0;
4495 int charpos, bytepos;
4496 4496
4497 if (NILP (arg)) 4497 if (NILP (arg))
4498 { 4498 {
4499 extern int frame_garbaged;
4500 int i; 4499 int i;
4501 4500
4502 /* Invalidate pixel data calculated for all compositions. */ 4501 /* Invalidate pixel data calculated for all compositions. */
@@ -4505,31 +4504,61 @@ redraws with point in the center of the current window.")
4505 4504
4506 Fredraw_frame (w->frame); 4505 Fredraw_frame (w->frame);
4507 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w))); 4506 SET_FRAME_GARBAGED (XFRAME (WINDOW_FRAME (w)));
4508 XSETFASTINT (arg, ht / 2); 4507 center_p = 1;
4509 } 4508 }
4510 else if (CONSP (arg)) /* Just C-u. */ 4509 else if (CONSP (arg)) /* Just C-u. */
4511 { 4510 center_p = 1;
4512 XSETFASTINT (arg, ht / 2);
4513 }
4514 else 4511 else
4515 { 4512 {
4516 arg = Fprefix_numeric_value (arg); 4513 arg = Fprefix_numeric_value (arg);
4517 CHECK_NUMBER (arg, 0); 4514 CHECK_NUMBER (arg, 0);
4518 } 4515 }
4519 4516
4520 if (XINT (arg) < 0)
4521 XSETINT (arg, XINT (arg) + ht);
4522
4523 set_buffer_internal (buf); 4517 set_buffer_internal (buf);
4524 pos = *vmotion (PT, - XINT (arg), w);
4525 4518
4526 set_marker_both (w->start, w->buffer, pos.bufpos, pos.bytepos); 4519 /* Handle centering on a gfaphical frame specially. Such frames can
4527 w->start_at_line_beg = ((pos.bytepos == BEGV_BYTE 4520 have variable-height lines and centering point on the basis of
4528 || FETCH_BYTE (pos.bytepos - 1) == '\n') 4521 line counts would lead to strange effects. */
4529 ? Qt : Qnil); 4522 if (center_p && FRAME_WINDOW_P (XFRAME (w->frame)))
4523 {
4524 struct it it;
4525 struct text_pos pt;
4526
4527 SET_TEXT_POS (pt, PT, PT_BYTE);
4528 start_display (&it, w, pt);
4529 move_it_vertically (&it, - it.last_visible_y / 2);
4530 charpos = IT_CHARPOS (it);
4531 bytepos = IT_BYTEPOS (it);
4532 }
4533 else
4534 {
4535 struct position pos;
4536
4537 if (center_p)
4538 {
4539 int ht = displayed_window_lines (w);
4540 arg = make_number (ht / 2);
4541 }
4542 else if (XINT (arg) < 0)
4543 {
4544 int ht = displayed_window_lines (w);
4545 XSETINT (arg, XINT (arg) + ht);
4546 }
4547
4548 pos = *vmotion (PT, - XINT (arg), w);
4549 charpos = pos.bufpos;
4550 bytepos = pos.bytepos;
4551 }
4552
4553 /* Set the new window start. */
4554 set_marker_both (w->start, w->buffer, charpos, bytepos);
4530 w->force_start = Qt; 4555 w->force_start = Qt;
4556 if (bytepos == BEGV_BYTE || FETCH_BYTE (bytepos - 1) == '\n')
4557 w->start_at_line_beg = Qt;
4558 else
4559 w->start_at_line_beg = Qnil;
4560
4531 set_buffer_internal (obuf); 4561 set_buffer_internal (obuf);
4532
4533 return Qnil; 4562 return Qnil;
4534} 4563}
4535 4564