diff options
| author | Chong Yidong | 2011-11-08 15:25:56 +0800 |
|---|---|---|
| committer | Chong Yidong | 2011-11-08 15:25:56 +0800 |
| commit | 105216ed03e65f32a7477ba3d27ab05c94bd3449 (patch) | |
| tree | 3e43f81d57d93cc600c80e729bc03abbd68b5ff1 | |
| parent | 0a9f9ab528d1b73d033e2cd93e89e6f42e6ad132 (diff) | |
| download | emacs-105216ed03e65f32a7477ba3d27ab05c94bd3449.tar.gz emacs-105216ed03e65f32a7477ba3d27ab05c94bd3449.zip | |
Move low-level window width/height functions to C, and high-level functions to Lisp.
* lisp/window.el (window-total-height, window-total-width): Doc fix.
(window-body-size): Move from C.
(window-body-height, window-body-width): Move to C.
* src/window.c (Fwindow_left_column, Fwindow_top_line): Doc fix.
(Fwindow_body_height, Fwindow_body_width): Move from Lisp. Signal
an error if not a live window.
(Fwindow_total_width, Fwindow_total_height): Move from Lisp.
(Fwindow_total_size, Fwindow_body_size): Move to Lisp.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/window.el | 74 | ||||
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/window.c | 113 |
4 files changed, 99 insertions, 102 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 28e3f79ba6e..394559563e9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-11-08 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * window.el (window-total-height, window-total-width): Doc fix. | ||
| 4 | (window-body-size): Move from C. | ||
| 5 | (window-body-height, window-body-width): Move to C. | ||
| 6 | |||
| 1 | 2011-11-08 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2011-11-08 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * window.el: Make special-display like display-buffer-alist (bug#9532). | 9 | * window.el: Make special-display like display-buffer-alist (bug#9532). |
diff --git a/lisp/window.el b/lisp/window.el index 931d265ebab..2f1b2a99a41 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -920,17 +920,16 @@ doc-string of `window-resizable'." | |||
| 920 | (<= (window-resizable window delta horizontal ignore trail noup nodown) | 920 | (<= (window-resizable window delta horizontal ignore trail noup nodown) |
| 921 | delta))) | 921 | delta))) |
| 922 | 922 | ||
| 923 | (defsubst window-total-height (&optional window) | 923 | (defun window-total-size (&optional window horizontal) |
| 924 | "Return the total number of lines of WINDOW. | 924 | "Return the total height or width of window WINDOW. |
| 925 | WINDOW can be any window and defaults to the selected one. The | 925 | If WINDOW is omitted or nil, it defaults to the selected window. |
| 926 | return value includes WINDOW's mode line and header line, if any. | 926 | |
| 927 | If WINDOW is internal the return value is the sum of the total | 927 | If HORIZONTAL is omitted or nil, return the total height of |
| 928 | number of lines of WINDOW's child windows if these are vertically | 928 | WINDOW, in lines, like `window-total-height'. Otherwise return |
| 929 | combined and the height of WINDOW's first child otherwise. | 929 | the total width, in columns, like `window-total-width'." |
| 930 | 930 | (if horizontal | |
| 931 | Note: This function does not take into account the value of | 931 | (window-total-width window) |
| 932 | `line-spacing' when calculating the number of lines in WINDOW." | 932 | (window-total-height window))) |
| 933 | (window-total-size window)) | ||
| 934 | 933 | ||
| 935 | ;; Eventually we should make `window-height' obsolete. | 934 | ;; Eventually we should make `window-height' obsolete. |
| 936 | (defalias 'window-height 'window-total-height) | 935 | (defalias 'window-height 'window-total-height) |
| @@ -946,16 +945,6 @@ one." | |||
| 946 | (= (window-total-size window) | 945 | (= (window-total-size window) |
| 947 | (window-total-size (frame-root-window window)))) | 946 | (window-total-size (frame-root-window window)))) |
| 948 | 947 | ||
| 949 | (defsubst window-total-width (&optional window) | ||
| 950 | "Return the total number of columns of WINDOW. | ||
| 951 | WINDOW can be any window and defaults to the selected one. The | ||
| 952 | return value includes any vertical dividers or scrollbars of | ||
| 953 | WINDOW. If WINDOW is internal, the return value is the sum of | ||
| 954 | the total number of columns of WINDOW's child windows if these | ||
| 955 | are horizontally combined and the width of WINDOW's first child | ||
| 956 | otherwise." | ||
| 957 | (window-total-size window t)) | ||
| 958 | |||
| 959 | (defsubst window-full-width-p (&optional window) | 948 | (defsubst window-full-width-p (&optional window) |
| 960 | "Return t if WINDOW is as wide as the containing frame. | 949 | "Return t if WINDOW is as wide as the containing frame. |
| 961 | More precisely, return t if and only if the total width of WINDOW | 950 | More precisely, return t if and only if the total width of WINDOW |
| @@ -965,40 +954,17 @@ WINDOW can be any window and defaults to the selected one." | |||
| 965 | (= (window-total-size window t) | 954 | (= (window-total-size window t) |
| 966 | (window-total-size (frame-root-window window) t))) | 955 | (window-total-size (frame-root-window window) t))) |
| 967 | 956 | ||
| 968 | (defsubst window-body-height (&optional window) | 957 | (defun window-body-size (&optional window horizontal) |
| 969 | "Return the number of lines of WINDOW's body. | 958 | "Return the height or width of WINDOW's text area. |
| 970 | WINDOW must be a live window and defaults to the selected one. | 959 | If WINDOW is omitted or nil, it defaults to the selected window. |
| 971 | 960 | Signal an error if the window is not live. | |
| 972 | The return value does not include WINDOW's mode line and header | ||
| 973 | line, if any. If a line at the bottom of the window is only | ||
| 974 | partially visible, that line is included in the return value. If | ||
| 975 | you do not want to include a partially visible bottom line in the | ||
| 976 | return value, use `window-text-height' instead. | ||
| 977 | |||
| 978 | Note that the return value is measured in canonical units, i.e. for | ||
| 979 | the default frame's face. If the window shows some characters with | ||
| 980 | non-default face, e.g., if the font of some characters is larger or | ||
| 981 | smaller than the default font, the value returned by this function | ||
| 982 | will not match the actual number of lines shown in the window. To | ||
| 983 | get the actual number of lines, use `posn-at-point'." | ||
| 984 | (window-body-size window)) | ||
| 985 | |||
| 986 | (defsubst window-body-width (&optional window) | ||
| 987 | "Return the number of columns of WINDOW's body. | ||
| 988 | WINDOW must be a live window and defaults to the selected one. | ||
| 989 | 961 | ||
| 990 | The return value does not include any vertical dividers or scroll | 962 | If HORIZONTAL is omitted or nil, return the height of the text |
| 991 | bars owned by WINDOW. On a window-system the return value does | 963 | area, like `window-body-height'. Otherwise, return the width of |
| 992 | not include the number of columns used for WINDOW's fringes or | 964 | the text area, like `window-body-width'." |
| 993 | display margins either. | 965 | (if horizontal |
| 994 | 966 | (window-body-width window) | |
| 995 | Note that the return value is measured in canonical units, i.e. for | 967 | (window-body-height window))) |
| 996 | the default frame's face. If the window shows some characters with | ||
| 997 | non-default face, e.g., if the font of some characters is larger or | ||
| 998 | smaller than the default font, the value returned by this function | ||
| 999 | will not match the actual number of characters per line shown in the | ||
| 1000 | window. To get the actual number of columns, use `posn-at-point'." | ||
| 1001 | (window-body-size window t)) | ||
| 1002 | 968 | ||
| 1003 | ;; Eventually we should make `window-height' obsolete. | 969 | ;; Eventually we should make `window-height' obsolete. |
| 1004 | (defalias 'window-width 'window-body-width) | 970 | (defalias 'window-width 'window-body-width) |
diff --git a/src/ChangeLog b/src/ChangeLog index 54d8af7c708..8d413a21fa5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-11-08 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * window.c (Fwindow_left_column, Fwindow_top_line): Doc fix. | ||
| 4 | (Fwindow_body_height, Fwindow_body_width): Move from Lisp. Signal | ||
| 5 | an error if not a live window. | ||
| 6 | (Fwindow_total_width, Fwindow_total_height): Move from Lisp. | ||
| 7 | (Fwindow_total_size, Fwindow_body_size): Move to Lisp. | ||
| 8 | |||
| 1 | 2011-11-07 Juanma Barranquero <lekktu@gmail.com> | 9 | 2011-11-07 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 10 | ||
| 3 | * lisp.h (syms_of_abbrev): Remove declaration. | 11 | * lisp.h (syms_of_abbrev): Remove declaration. |
diff --git a/src/window.c b/src/window.c index 162ae08a00f..00e887436d3 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -539,27 +539,34 @@ selected one. */) | |||
| 539 | return decode_window (window)->use_time; | 539 | return decode_window (window)->use_time; |
| 540 | } | 540 | } |
| 541 | 541 | ||
| 542 | DEFUN ("window-total-size", Fwindow_total_size, Swindow_total_size, 0, 2, 0, | 542 | DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 1, 0, |
| 543 | doc: /* Return the total number of lines of window WINDOW. | 543 | doc: /* Return the total height, in lines, of window WINDOW. |
| 544 | If WINDOW is omitted or nil, it defaults to the selected window. | 544 | If WINDOW is omitted or nil, it defaults to the selected window. |
| 545 | 545 | ||
| 546 | The return value includes WINDOW's mode line and header line, if any. | 546 | The return value includes the mode line and header line, if any. |
| 547 | If WINDOW is internal, the return value is the sum of the total number | 547 | If WINDOW is an internal window, the total height is the height |
| 548 | of lines of WINDOW's child windows if these are vertically combined | 548 | of the screen areas spanned by its children. |
| 549 | and the height of WINDOW's first child otherwise. | 549 | |
| 550 | 550 | On a graphical display, this total height is reported as an | |
| 551 | Optional argument HORIZONTAL non-nil means return the total number of | 551 | integer multiple of the default character height. */) |
| 552 | columns of WINDOW. In this case the return value includes any vertical | 552 | (Lisp_Object window) |
| 553 | dividers or scrollbars of WINDOW. If WINDOW is internal, the return | ||
| 554 | value is the sum of the total number of columns of WINDOW's child | ||
| 555 | windows if they are horizontally combined and the width of WINDOW's | ||
| 556 | first child otherwise. */) | ||
| 557 | (Lisp_Object window, Lisp_Object horizontal) | ||
| 558 | { | 553 | { |
| 559 | if (NILP (horizontal)) | 554 | return decode_any_window (window)->total_lines; |
| 560 | return decode_any_window (window)->total_lines; | 555 | } |
| 561 | else | 556 | |
| 562 | return decode_any_window (window)->total_cols; | 557 | DEFUN ("window-total-width", Fwindow_total_width, Swindow_total_width, 0, 1, 0, |
| 558 | doc: /* Return the total width, in columns, of window WINDOW. | ||
| 559 | If WINDOW is omitted or nil, it defaults to the selected window. | ||
| 560 | |||
| 561 | The return value includes any vertical dividers or scroll bars | ||
| 562 | belonging to WINDOW. If WINDOW is an internal window, the total width | ||
| 563 | is the width of the screen areas spanned by its children. | ||
| 564 | |||
| 565 | On a graphical display, this total width is reported as an | ||
| 566 | integer multiple of the default character width. */) | ||
| 567 | (Lisp_Object window) | ||
| 568 | { | ||
| 569 | return decode_any_window (window)->total_cols; | ||
| 563 | } | 570 | } |
| 564 | 571 | ||
| 565 | DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, | 572 | DEFUN ("window-new-total", Fwindow_new_total, Swindow_new_total, 0, 1, 0, |
| @@ -592,6 +599,10 @@ If WINDOW is omitted or nil, it defaults to the selected window. */) | |||
| 592 | 599 | ||
| 593 | DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, | 600 | DEFUN ("window-left-column", Fwindow_left_column, Swindow_left_column, 0, 1, 0, |
| 594 | doc: /* Return left column of window WINDOW. | 601 | doc: /* Return left column of window WINDOW. |
| 602 | This is the distance, in columns, between the left edge of WINDOW and | ||
| 603 | the left edge of the frame's window area. For instance, the return | ||
| 604 | value is 0 if there is no window to the left of WINDOW. | ||
| 605 | |||
| 595 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 606 | If WINDOW is omitted or nil, it defaults to the selected window. */) |
| 596 | (Lisp_Object window) | 607 | (Lisp_Object window) |
| 597 | { | 608 | { |
| @@ -600,6 +611,10 @@ If WINDOW is omitted or nil, it defaults to the selected window. */) | |||
| 600 | 611 | ||
| 601 | DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, | 612 | DEFUN ("window-top-line", Fwindow_top_line, Swindow_top_line, 0, 1, 0, |
| 602 | doc: /* Return top line of window WINDOW. | 613 | doc: /* Return top line of window WINDOW. |
| 614 | This is the distance, in lines, between the top of WINDOW and the top | ||
| 615 | of the frame's window area. For instance, the return value is 0 if | ||
| 616 | there is no window above WINDOW. | ||
| 617 | |||
| 603 | If WINDOW is omitted or nil, it defaults to the selected window. */) | 618 | If WINDOW is omitted or nil, it defaults to the selected window. */) |
| 604 | (Lisp_Object window) | 619 | (Lisp_Object window) |
| 605 | { | 620 | { |
| @@ -655,34 +670,34 @@ window_body_cols (struct window *w) | |||
| 655 | return width; | 670 | return width; |
| 656 | } | 671 | } |
| 657 | 672 | ||
| 658 | DEFUN ("window-body-size", Fwindow_body_size, Swindow_body_size, 0, 2, 0, | 673 | DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 1, 0, |
| 659 | doc: /* Return the number of lines or columns of WINDOW's body. | 674 | doc: /* Return the height, in lines, of WINDOW's text area. |
| 660 | WINDOW must be a live window and defaults to the selected one. | 675 | If WINDOW is omitted or nil, it defaults to the selected window. |
| 676 | Signal an error if the window is not live. | ||
| 661 | 677 | ||
| 662 | If the optional argument HORIZONTAL is omitted or nil, the function | 678 | The returned height does not include the mode line or header line. |
| 663 | returns the number of WINDOW's lines, excluding the mode line and | 679 | On a graphical display, the height is expressed as an integer multiple |
| 664 | header line, if any. | 680 | of the default character height. If a line at the bottom of the text |
| 665 | 681 | area is only partially visible, that counts as a whole line; to | |
| 666 | If HORIZONTAL is non-nil, the function returns the number of columns | 682 | exclude partially-visible lines, use `window-text-height'. */) |
| 667 | excluding any vertical dividers or scroll bars owned by WINDOW. On a | 683 | (Lisp_Object window) |
| 668 | window-system the return value also excludes the number of columns | ||
| 669 | used for WINDOW's fringes or display margins. | ||
| 670 | |||
| 671 | Note that the return value is measured in canonical units, i.e. for | ||
| 672 | the default frame's face. If the window shows some characters with | ||
| 673 | non-default face, e.g., if the font of some characters is larger or | ||
| 674 | smaller than the default font, the value returned by this function | ||
| 675 | will not match the actual number of lines or characters per line | ||
| 676 | shown in the window. To get the actual number of columns and lines, | ||
| 677 | use `posn-at-point'. */) | ||
| 678 | (Lisp_Object window, Lisp_Object horizontal) | ||
| 679 | { | 684 | { |
| 680 | struct window *w = decode_any_window (window); | 685 | struct window *w = decode_window (window); |
| 686 | return make_number (window_body_lines (w)); | ||
| 687 | } | ||
| 681 | 688 | ||
| 682 | if (NILP (horizontal)) | 689 | DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 1, 0, |
| 683 | return make_number (window_body_lines (w)); | 690 | doc: /* Return the width, in columns, of WINDOW's text area. |
| 684 | else | 691 | If WINDOW is omitted or nil, it defaults to the selected window. |
| 685 | return make_number (window_body_cols (w)); | 692 | Signal an error if the window is not live. |
| 693 | |||
| 694 | The return value does not include any vertical dividers, fringe or | ||
| 695 | marginal areas, or scroll bars. On a graphical display, the width is | ||
| 696 | expressed as an integer multiple of the default character width. */) | ||
| 697 | (Lisp_Object window) | ||
| 698 | { | ||
| 699 | struct window *w = decode_window (window); | ||
| 700 | return make_number (window_body_cols (w)); | ||
| 686 | } | 701 | } |
| 687 | 702 | ||
| 688 | DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, | 703 | DEFUN ("window-hscroll", Fwindow_hscroll, Swindow_hscroll, 0, 1, 0, |
| @@ -5218,10 +5233,10 @@ and redisplay normally--don't erase and redraw the frame. */) | |||
| 5218 | DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, | 5233 | DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, |
| 5219 | 0, 1, 0, | 5234 | 0, 1, 0, |
| 5220 | doc: /* Return the height in lines of the text display area of WINDOW. | 5235 | doc: /* Return the height in lines of the text display area of WINDOW. |
| 5221 | WINDOW defaults to the selected window. | 5236 | If WINDOW is omitted or nil, it defaults to the selected window. |
| 5222 | 5237 | ||
| 5223 | The return value does not include the mode line, any header line, nor | 5238 | The returned height does not include the mode line, any header line, |
| 5224 | any partial-height lines in the text display area. */) | 5239 | nor any partial-height lines at the bottom of the text area. */) |
| 5225 | (Lisp_Object window) | 5240 | (Lisp_Object window) |
| 5226 | { | 5241 | { |
| 5227 | struct window *w = decode_window (window); | 5242 | struct window *w = decode_window (window); |
| @@ -6583,14 +6598,16 @@ function `window-nest' and altered by the function `set-window-nest'. */); | |||
| 6583 | defsubr (&Swindow_use_time); | 6598 | defsubr (&Swindow_use_time); |
| 6584 | defsubr (&Swindow_top_line); | 6599 | defsubr (&Swindow_top_line); |
| 6585 | defsubr (&Swindow_left_column); | 6600 | defsubr (&Swindow_left_column); |
| 6586 | defsubr (&Swindow_total_size); | 6601 | defsubr (&Swindow_total_height); |
| 6602 | defsubr (&Swindow_total_width); | ||
| 6587 | defsubr (&Swindow_normal_size); | 6603 | defsubr (&Swindow_normal_size); |
| 6588 | defsubr (&Swindow_new_total); | 6604 | defsubr (&Swindow_new_total); |
| 6589 | defsubr (&Swindow_new_normal); | 6605 | defsubr (&Swindow_new_normal); |
| 6590 | defsubr (&Sset_window_new_total); | 6606 | defsubr (&Sset_window_new_total); |
| 6591 | defsubr (&Sset_window_new_normal); | 6607 | defsubr (&Sset_window_new_normal); |
| 6592 | defsubr (&Swindow_resize_apply); | 6608 | defsubr (&Swindow_resize_apply); |
| 6593 | defsubr (&Swindow_body_size); | 6609 | defsubr (&Swindow_body_height); |
| 6610 | defsubr (&Swindow_body_width); | ||
| 6594 | defsubr (&Swindow_hscroll); | 6611 | defsubr (&Swindow_hscroll); |
| 6595 | defsubr (&Sset_window_hscroll); | 6612 | defsubr (&Sset_window_hscroll); |
| 6596 | defsubr (&Swindow_redisplay_end_trigger); | 6613 | defsubr (&Swindow_redisplay_end_trigger); |