diff options
author | Gerd Moellmann <[email protected]> | 2000-12-27 15:46:54 +0000 |
---|---|---|
committer | Gerd Moellmann <[email protected]> | 2000-12-27 15:46:54 +0000 |
commit | 12c8b416beffe0194fe5c06f07685d6676bbf811 (patch) | |
tree | c2a5949f035c3460a2177240ca807a37c8a09447 | |
parent | 6061fbf05a7391c37ed70c478642b1577402d3f5 (diff) |
(Frecenter): Use displayed_window_lines instead
of window_internal_height.
-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 4d162c46b9..32cd8dee99 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2000-12-27 Gerd Moellmann <[email protected]> + * window.c (Frecenter): Use displayed_window_lines instead + of window_internal_height. + * xterm.c (syms_of_xterm): DEFVAR_LISP x-toolkit-scroll-bars instead of x-toolkit-scroll-bars-p. (Vx_toolkit_scroll_bars): Renamed from x_toolkit_scroll_bars_p. diff --git a/src/window.c b/src/window.c index f2af5e3305..c148598ae6 100644 --- a/src/window.c +++ b/src/window.c @@ -4433,6 +4433,54 @@ Default for ARG is window width minus 2.") - XINT (arg))); } + +/* Value is the number of lines actually displayed in window W, + as opposed to its height. */ + +static int +displayed_window_lines (w) + struct window *w; +{ + struct it it; + struct text_pos start; + int height = window_box_height (w); + struct buffer *old_buffer; + int bottom_y; + + if (XBUFFER (w->buffer) != current_buffer) + { + old_buffer = current_buffer; + set_buffer_internal (XBUFFER (w->buffer)); + } + else + old_buffer = NULL; + + SET_TEXT_POS_FROM_MARKER (start, w->start); + start_display (&it, w, start); + move_it_vertically (&it, height); + + if (old_buffer) + set_buffer_internal (old_buffer); + + bottom_y = it.current_y + it.max_ascent + it.max_descent; + + if (bottom_y > it.current_y && bottom_y <= it.last_visible_y) + /* Hit a line without a terminating newline. */ + it.vpos++; + + /* Add in empty lines at the bottom of the window. */ + if (bottom_y < height) + { + struct frame *f = XFRAME (w->frame); + int rest = height - bottom_y; + int lines = rest / CANON_Y_UNIT (f); + it.vpos += lines; + } + + return it.vpos; +} + + DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\ 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.") register Lisp_Object arg; { register struct window *w = XWINDOW (selected_window); - register int ht = window_internal_height (w); + register int ht = displayed_window_lines (w); struct position pos; struct buffer *buf = XBUFFER (w->buffer); struct buffer *obuf = current_buffer; @@ -4488,53 +4536,6 @@ redraws with point in the center of the current window.") } -/* Value is the number of lines actually displayed in window W, - as opposed to its height. */ - -static int -displayed_window_lines (w) - struct window *w; -{ - struct it it; - struct text_pos start; - int height = window_box_height (w); - struct buffer *old_buffer; - int bottom_y; - - if (XBUFFER (w->buffer) != current_buffer) - { - old_buffer = current_buffer; - set_buffer_internal (XBUFFER (w->buffer)); - } - else - old_buffer = NULL; - - SET_TEXT_POS_FROM_MARKER (start, w->start); - start_display (&it, w, start); - move_it_vertically (&it, height); - - if (old_buffer) - set_buffer_internal (old_buffer); - - bottom_y = it.current_y + it.max_ascent + it.max_descent; - - if (bottom_y > it.current_y && bottom_y <= it.last_visible_y) - /* Hit a line without a terminating newline. */ - it.vpos++; - - /* Add in empty lines at the bottom of the window. */ - if (bottom_y < height) - { - struct frame *f = XFRAME (w->frame); - int rest = height - bottom_y; - int lines = rest / CANON_Y_UNIT (f); - it.vpos += lines; - } - - return it.vpos; -} - - DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, 0, 1, 0, "Return the height in lines of the text display area of WINDOW.\n\ |