changeset 72990:2d3156eeb678

(Fset_window_hscroll, Fpos_visible_in_window_p): Doc fix. Use "off-screen" instead of "invisible". (Fwindow_line_height): Make line numbers 0-based. Make line arg optional; if nil, use current cursor row. Handle text terminals properly. Return nil if non-interactive or pseudo-window.
author Kim F. Storm <storm@cua.dk>
date Tue, 19 Sep 2006 13:09:11 +0000
parents f9742f561ed9
children 0782f0fe772b
files src/window.c
diffstat 1 files changed, 32 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/window.c	Tue Sep 19 10:19:34 2006 +0000
+++ b/src/window.c	Tue Sep 19 13:09:11 2006 +0000
@@ -340,8 +340,8 @@
 where X and Y are the pixel coordinates relative to the top left corner
 of the window.  The remaining elements are omitted if the character after
 POS is fully visible; otherwise, RTOP and RBOT are the number of pixels
-invisible at the top and bottom of the row, ROWH is the height of the display
-row, and VPOS is the row number (0-based) containing POS.  */)
+off-screen at the top and bottom of the row, ROWH is the height of the
+display row, and VPOS is the row number (0-based) containing POS.  */)
      (pos, window, partially)
      Lisp_Object pos, window, partially;
 {
@@ -391,19 +391,20 @@
 }
 
 DEFUN ("window-line-height", Fwindow_line_height,
-       Swindow_line_height, 1, 2, 0,
+       Swindow_line_height, 0, 2, 0,
        doc: /* Return height in pixels of text line LINE in window WINDOW.
 If WINDOW is nil or omitted, use selected window.
 
-Normal text lines are numbered starting from 1.  Negative numbers
-counts from the end of the window.  Return height of header or mode
-line if LINE is `header-line' and `mode-line'.
-
-Value is a list (HEIGHT VPOS YPOS INVIS), where HEIGHT is the height
+Return height of current line if LINE is omitted or nil.  Return height of
+header or mode line if LINE is `header-line' and `mode-line'.
+Otherwise, LINE is a text line number starting from 0.  A negative number
+counts from the end of the window.
+
+Value is a list (HEIGHT VPOS YPOS OFFBOT), where HEIGHT is the height
 in pixels of the visible part of the line, VPOS and YPOS are the
 vertical position in lines and pixels of the row, relative to the top
-of the first text line, and INVIS is the number of invisible pixels at
-the bottom of the text row.  If there are invisible pixels at the top
+of the first text line, and OFFBOT is the number of off-screen pixels at
+the bottom of the text row.  If there are off-screen pixels at the top
 of the (first) text row, YPOS is negative.
 
 Return nil if window display is not up-to-date.  In that case, use
@@ -419,18 +420,8 @@
   w = decode_window (window);
 
   if (noninteractive
-      || !FRAME_WINDOW_P (WINDOW_XFRAME (w))
       || w->pseudo_window_p)
-    {
-      int vpos = (!INTEGERP (line)
-		  ? 0
-		  : (n = XINT (line), n > 0)
-		  ? (n - 1)
-		  : (WINDOW_TOTAL_LINES (w) + n));
-      return list4 (make_number (1), /* fixed line height */
-		    make_number(vpos), make_number (vpos),
-		    make_number (0));
-    }
+    return Qnil;
 
   CHECK_BUFFER (w->buffer);
   b = XBUFFER (w->buffer);
@@ -443,6 +434,16 @@
       || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b))
     return Qnil;
 
+  if (NILP (line))
+    {
+      i = w->cursor.vpos;
+      if (i < 0 || i >= w->current_matrix->nrows
+	  || (row = MATRIX_ROW (w->current_matrix, i), !row->enabled_p))
+	return Qnil;
+      max_y = window_text_bottom_y (w);
+      goto found_row;
+    }
+
   if (EQ (line, Qheader_line))
     {
       if (!WINDOW_WANTS_HEADER_LINE_P (w))
@@ -468,14 +469,12 @@
     }
 
   CHECK_NUMBER (line);
-
-  if ((n = XINT (line), !n))
-    return Qnil;
+  n = XINT (line);
 
   row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
   end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w);
   max_y = window_text_bottom_y (w);
-  i = 1;
+  i = 0;
 
   while ((n < 0 || i < n)
 	 && row <= end_row && row->enabled_p
@@ -485,17 +484,18 @@
   if (row > end_row || !row->enabled_p)
     return Qnil;
 
-  if (n < 0)
+  if (++n < 0)
     {
       if (-n > i)
 	return Qnil;
-      row += n + 1;
-      i += n + 1;
-    }
-
+      row += n;
+      i += n;
+    }
+
+ found_row:
   crop = max (0, (row->y + row->height) - max_y);
   return list4 (make_number (row->height + min (0, row->y) - crop),
-		make_number (i - 1),
+		make_number (i),
 		make_number (row->y),
 		make_number (crop));
 }
@@ -565,7 +565,7 @@
 Return NCOL.  NCOL should be zero or positive.
 
 Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
-window so that the location of point becomes invisible.  */)
+window so that the location of point moves off-screen.  */)
      (window, ncol)
      Lisp_Object window, ncol;
 {