aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2006-09-18 11:11:23 +0000
committerKim F. Storm2006-09-18 11:11:23 +0000
commit536833ab8804b1d8145cdc9dcfcb7588d6b5470e (patch)
treea44d9f8bcfd0ef6bd5c79fb12d1afca85583b124 /src
parent37228c3809552749f13d3c2a409a90411eca7086 (diff)
downloademacs-536833ab8804b1d8145cdc9dcfcb7588d6b5470e.tar.gz
emacs-536833ab8804b1d8145cdc9dcfcb7588d6b5470e.zip
(Fwindow_line_visibility): Remove.
(Fwindow_line_height): New defun replacing it. (syms_of_window): Defsubr it.
Diffstat (limited to 'src')
-rw-r--r--src/window.c111
1 files changed, 78 insertions, 33 deletions
diff --git a/src/window.c b/src/window.c
index 8d6918feff2..69307449968 100644
--- a/src/window.c
+++ b/src/window.c
@@ -390,30 +390,47 @@ row, and VPOS is the row number (0-based) containing POS. */)
390 return in_window; 390 return in_window;
391} 391}
392 392
393DEFUN ("window-line-visibility", Fwindow_line_visibility, 393DEFUN ("window-line-height", Fwindow_line_height,
394 Swindow_line_visibility, 0, 2, 0, 394 Swindow_line_height, 1, 2, 0,
395 doc: /* Return information about visibility of last line in WINDOW. 395 doc: /* Return height in pixels of text line LINE in window WINDOW.
396If optional second arg is non-nil, test first text line instead. 396If WINDOW is nil or omitted, use selected window.
397Return nil if visibility of the line is not known; in that case, 397
398caller may use `pos-visible-in-window-p' to know for sure. 398Normal text lines are numbered starting from 1. Negative numbers
399 399counts from the end of the window. Return height of header or mode
400Return t if window line is known to be fully visible. Otherwise, 400line if LINE is `header-line' and `mode-line'.
401return cons (VIS . INVIS), where VIS and INVIS is pixel height 401
402of the visible and invisible part of the line. */) 402Value is a list (HEIGHT VPOS YPOS INVIS), where HEIGHT is the height
403 (window, first) 403in pixels of the visible part of the line, VPOS and YPOS are the
404 Lisp_Object window, first; 404vertical position in lines and pixels of the row, relative to the top
405of the first text line, and INVIS is the number of invisible pixels at
406the bottom of the text row. If there are invisible pixels at the top
407of the (first) text row, YPOS is negative.
408
409Return nil if window display is not up-to-date. In that case, use
410`pos-visible-in-window-p' to obtain the information. */)
411 (line, window)
412 Lisp_Object line, window;
405{ 413{
406 register struct window *w; 414 register struct window *w;
407 register struct buffer *b; 415 register struct buffer *b;
408 struct glyph_row *row, *end_row; 416 struct glyph_row *row, *end_row;
409 int max_y, crop; 417 int max_y, crop, i, n;
410 418
411 w = decode_window (window); 419 w = decode_window (window);
412 420
413 if (noninteractive 421 if (noninteractive
414 || !FRAME_WINDOW_P (WINDOW_XFRAME (w)) 422 || !FRAME_WINDOW_P (WINDOW_XFRAME (w))
415 || w->pseudo_window_p) 423 || w->pseudo_window_p)
416 return Qt; 424 {
425 int vpos = (!INTEGERP (line)
426 ? 0
427 : (n = XINT (line), n > 0)
428 ? (n - 1)
429 : (WINDOW_TOTAL_LINES (w) + n));
430 return list4 (make_number (1), /* fixed line height */
431 make_number(vpos), make_number (vpos),
432 make_number (0));
433 }
417 434
418 CHECK_BUFFER (w->buffer); 435 CHECK_BUFFER (w->buffer);
419 b = XBUFFER (w->buffer); 436 b = XBUFFER (w->buffer);
@@ -426,36 +443,64 @@ of the visible and invisible part of the line. */)
426 || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b)) 443 || XFASTINT (w->last_overlay_modified) < BUF_OVERLAY_MODIFF (b))
427 return Qnil; 444 return Qnil;
428 445
429 row = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 446 if (EQ (line, Qheader_line))
430 if (!NILP (first))
431 { 447 {
432 448 if (!WINDOW_WANTS_HEADER_LINE_P (w))
449 return Qnil;
450 row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
433 if (!row->enabled_p) 451 if (!row->enabled_p)
434 return Qnil; 452 return Qnil;
435 453 return list4 (make_number (row->height),
436 crop = WINDOW_HEADER_LINE_HEIGHT (w) - row->y; 454 make_number (0), make_number (0),
455 make_number (0));
437 } 456 }
438 else 457
458 if (EQ (line, Qmode_line))
439 { 459 {
440 int max_y = window_text_bottom_y (w); 460 row = MATRIX_MODE_LINE_ROW (w->current_matrix);
441 struct glyph_row *end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w); 461 if (!row->enabled_p)
462 return Qnil;
463 return list4 (make_number (row->height),
464 make_number (0), /* not accurate */
465 make_number (WINDOW_HEADER_LINE_HEIGHT (w)
466 + window_text_bottom_y (w)),
467 make_number (0));
468 }
442 469
443 while (row <= end_row && row->enabled_p 470 CHECK_NUMBER (line);
444 && row->y + row->height < max_y)
445 row++;
446 471
447 if (row > end_row || !row->enabled_p) 472 if ((n = XINT (line), !n))
448 return Qnil; 473 return Qnil;
474
475 row = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
476 end_row = MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w);
477 max_y = window_text_bottom_y (w);
478 i = 1;
479
480 while ((n < 0 || i < n)
481 && row <= end_row && row->enabled_p
482 && row->y + row->height < max_y)
483 row++, i++;
449 484
450 crop = (row->y + row->height) - max_y; 485 if (row > end_row || !row->enabled_p)
486 return Qnil;
487
488 if (n < 0)
489 {
490 if (-n > i)
491 return Qnil;
492 row += n + 1;
493 i += n + 1;
451 } 494 }
452 495
453 if (crop > 0) 496 crop = max (0, (row->y + row->height) - max_y);
454 return Fcons (make_number (row->height - crop), 497 return list4 (make_number (row->height + min (0, row->y) - crop),
455 make_number (crop)); 498 make_number (i - 1),
456 return Qt; 499 make_number (row->y),
500 make_number (crop));
457} 501}
458 502
503
459 504
460static struct window * 505static struct window *
461decode_window (window) 506decode_window (window)
@@ -7433,7 +7478,7 @@ The selected frame is the one whose configuration has changed. */);
7433 defsubr (&Swindowp); 7478 defsubr (&Swindowp);
7434 defsubr (&Swindow_live_p); 7479 defsubr (&Swindow_live_p);
7435 defsubr (&Spos_visible_in_window_p); 7480 defsubr (&Spos_visible_in_window_p);
7436 defsubr (&Swindow_line_visibility); 7481 defsubr (&Swindow_line_height);
7437 defsubr (&Swindow_buffer); 7482 defsubr (&Swindow_buffer);
7438 defsubr (&Swindow_height); 7483 defsubr (&Swindow_height);
7439 defsubr (&Swindow_width); 7484 defsubr (&Swindow_width);