diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/window.c | 97 |
2 files changed, 52 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4d162c46b97..32cd8dee991 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2000-12-27 Gerd Moellmann <gerd@gnu.org> | 1 | 2000-12-27 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * window.c (Frecenter): Use displayed_window_lines instead | ||
| 4 | of window_internal_height. | ||
| 5 | |||
| 3 | * xterm.c (syms_of_xterm): DEFVAR_LISP x-toolkit-scroll-bars | 6 | * xterm.c (syms_of_xterm): DEFVAR_LISP x-toolkit-scroll-bars |
| 4 | instead of x-toolkit-scroll-bars-p. | 7 | instead of x-toolkit-scroll-bars-p. |
| 5 | (Vx_toolkit_scroll_bars): Renamed from x_toolkit_scroll_bars_p. | 8 | (Vx_toolkit_scroll_bars): Renamed from x_toolkit_scroll_bars_p. |
diff --git a/src/window.c b/src/window.c index f2af5e3305a..c148598ae62 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -4433,6 +4433,54 @@ Default for ARG is window width minus 2.") | |||
| 4433 | - XINT (arg))); | 4433 | - XINT (arg))); |
| 4434 | } | 4434 | } |
| 4435 | 4435 | ||
| 4436 | |||
| 4437 | /* Value is the number of lines actually displayed in window W, | ||
| 4438 | as opposed to its height. */ | ||
| 4439 | |||
| 4440 | static int | ||
| 4441 | displayed_window_lines (w) | ||
| 4442 | struct window *w; | ||
| 4443 | { | ||
| 4444 | struct it it; | ||
| 4445 | struct text_pos start; | ||
| 4446 | int height = window_box_height (w); | ||
| 4447 | struct buffer *old_buffer; | ||
| 4448 | int bottom_y; | ||
| 4449 | |||
| 4450 | if (XBUFFER (w->buffer) != current_buffer) | ||
| 4451 | { | ||
| 4452 | old_buffer = current_buffer; | ||
| 4453 | set_buffer_internal (XBUFFER (w->buffer)); | ||
| 4454 | } | ||
| 4455 | else | ||
| 4456 | old_buffer = NULL; | ||
| 4457 | |||
| 4458 | SET_TEXT_POS_FROM_MARKER (start, w->start); | ||
| 4459 | start_display (&it, w, start); | ||
| 4460 | move_it_vertically (&it, height); | ||
| 4461 | |||
| 4462 | if (old_buffer) | ||
| 4463 | set_buffer_internal (old_buffer); | ||
| 4464 | |||
| 4465 | bottom_y = it.current_y + it.max_ascent + it.max_descent; | ||
| 4466 | |||
| 4467 | if (bottom_y > it.current_y && bottom_y <= it.last_visible_y) | ||
| 4468 | /* Hit a line without a terminating newline. */ | ||
| 4469 | it.vpos++; | ||
| 4470 | |||
| 4471 | /* Add in empty lines at the bottom of the window. */ | ||
| 4472 | if (bottom_y < height) | ||
| 4473 | { | ||
| 4474 | struct frame *f = XFRAME (w->frame); | ||
| 4475 | int rest = height - bottom_y; | ||
| 4476 | int lines = rest / CANON_Y_UNIT (f); | ||
| 4477 | it.vpos += lines; | ||
| 4478 | } | ||
| 4479 | |||
| 4480 | return it.vpos; | ||
| 4481 | } | ||
| 4482 | |||
| 4483 | |||
| 4436 | DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", | 4484 | DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", |
| 4437 | "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\ | 4485 | "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\ |
| 4438 | The desired position of point is always relative to the current window.\n\ | 4486 | The desired position of point is always relative to the current window.\n\ |
| @@ -4443,7 +4491,7 @@ redraws with point in the center of the current window.") | |||
| 4443 | register Lisp_Object arg; | 4491 | register Lisp_Object arg; |
| 4444 | { | 4492 | { |
| 4445 | register struct window *w = XWINDOW (selected_window); | 4493 | register struct window *w = XWINDOW (selected_window); |
| 4446 | register int ht = window_internal_height (w); | 4494 | register int ht = displayed_window_lines (w); |
| 4447 | struct position pos; | 4495 | struct position pos; |
| 4448 | struct buffer *buf = XBUFFER (w->buffer); | 4496 | struct buffer *buf = XBUFFER (w->buffer); |
| 4449 | struct buffer *obuf = current_buffer; | 4497 | struct buffer *obuf = current_buffer; |
| @@ -4488,53 +4536,6 @@ redraws with point in the center of the current window.") | |||
| 4488 | } | 4536 | } |
| 4489 | 4537 | ||
| 4490 | 4538 | ||
| 4491 | /* Value is the number of lines actually displayed in window W, | ||
| 4492 | as opposed to its height. */ | ||
| 4493 | |||
| 4494 | static int | ||
| 4495 | displayed_window_lines (w) | ||
| 4496 | struct window *w; | ||
| 4497 | { | ||
| 4498 | struct it it; | ||
| 4499 | struct text_pos start; | ||
| 4500 | int height = window_box_height (w); | ||
| 4501 | struct buffer *old_buffer; | ||
| 4502 | int bottom_y; | ||
| 4503 | |||
| 4504 | if (XBUFFER (w->buffer) != current_buffer) | ||
| 4505 | { | ||
| 4506 | old_buffer = current_buffer; | ||
| 4507 | set_buffer_internal (XBUFFER (w->buffer)); | ||
| 4508 | } | ||
| 4509 | else | ||
| 4510 | old_buffer = NULL; | ||
| 4511 | |||
| 4512 | SET_TEXT_POS_FROM_MARKER (start, w->start); | ||
| 4513 | start_display (&it, w, start); | ||
| 4514 | move_it_vertically (&it, height); | ||
| 4515 | |||
| 4516 | if (old_buffer) | ||
| 4517 | set_buffer_internal (old_buffer); | ||
| 4518 | |||
| 4519 | bottom_y = it.current_y + it.max_ascent + it.max_descent; | ||
| 4520 | |||
| 4521 | if (bottom_y > it.current_y && bottom_y <= it.last_visible_y) | ||
| 4522 | /* Hit a line without a terminating newline. */ | ||
| 4523 | it.vpos++; | ||
| 4524 | |||
| 4525 | /* Add in empty lines at the bottom of the window. */ | ||
| 4526 | if (bottom_y < height) | ||
| 4527 | { | ||
| 4528 | struct frame *f = XFRAME (w->frame); | ||
| 4529 | int rest = height - bottom_y; | ||
| 4530 | int lines = rest / CANON_Y_UNIT (f); | ||
| 4531 | it.vpos += lines; | ||
| 4532 | } | ||
| 4533 | |||
| 4534 | return it.vpos; | ||
| 4535 | } | ||
| 4536 | |||
| 4537 | |||
| 4538 | DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, | 4539 | DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, |
| 4539 | 0, 1, 0, | 4540 | 0, 1, 0, |
| 4540 | "Return the height in lines of the text display area of WINDOW.\n\ | 4541 | "Return the height in lines of the text display area of WINDOW.\n\ |