diff options
| author | Eli Zaretskii | 2013-07-10 19:18:17 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-07-10 19:18:17 +0300 |
| commit | 35cb8a3e0f6712a23d1fb16a0c90aceff45ed0e4 (patch) | |
| tree | 5ff99b36ababdab55c853d04f563005ee7727346 | |
| parent | 45b683a16c289f67079f60ca1a7bc51d75e8d0c1 (diff) | |
| download | emacs-35cb8a3e0f6712a23d1fb16a0c90aceff45ed0e4.tar.gz emacs-35cb8a3e0f6712a23d1fb16a0c90aceff45ed0e4.zip | |
Improve scrolling when line-spacing != 0 and scroll-step = 1.
lisp/simple.el (default-line-height): New function.
(line-move-partial, line-move): Use it instead of computing the
line height inline.
(line-move-partial): Always compute ROWH. If the last line is
partially-visible, but its text is completely visible, allow
cursor to enter such a partially-visible line.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/simple.el | 83 |
2 files changed, 55 insertions, 37 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 008932be738..ce10b033652 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2013-07-10 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (default-line-height): New function. | ||
| 4 | (line-move-partial, line-move): Use it instead of computing the | ||
| 5 | line height inline. | ||
| 6 | (line-move-partial): Always compute ROWH. If the last line is | ||
| 7 | partially-visible, but its text is completely visible, allow | ||
| 8 | cursor to enter such a partially-visible line. | ||
| 9 | |||
| 1 | 2013-07-10 Michael Albinus <michael.albinus@gmx.de> | 10 | 2013-07-10 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 11 | ||
| 3 | Improve error messages. (Bug#14808) | 12 | Improve error messages. (Bug#14808) |
diff --git a/lisp/simple.el b/lisp/simple.el index 1baf0eb6d4e..9774bc0e292 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -4732,18 +4732,35 @@ lines." | |||
| 4732 | (aref (font-info (face-font 'default)) 3)) | 4732 | (aref (font-info (face-font 'default)) 3)) |
| 4733 | (t (frame-char-height)))) | 4733 | (t (frame-char-height)))) |
| 4734 | 4734 | ||
| 4735 | (defun default-line-height () | ||
| 4736 | "Return the pixel height of current buffer's default-face text line. | ||
| 4737 | |||
| 4738 | The value includes `line-spacing', if any, defined for the buffer | ||
| 4739 | or the frame." | ||
| 4740 | (let ((dfh (default-font-height)) | ||
| 4741 | (lsp (if (display-graphic-p) | ||
| 4742 | (or line-spacing | ||
| 4743 | (default-value 'line-spacing) | ||
| 4744 | (frame-parameter nil 'line-spacing) | ||
| 4745 | 0) | ||
| 4746 | 0))) | ||
| 4747 | (if (floatp lsp) | ||
| 4748 | (setq lsp (* dfh lsp))) | ||
| 4749 | (+ dfh lsp))) | ||
| 4750 | |||
| 4735 | (defun window-screen-lines () | 4751 | (defun window-screen-lines () |
| 4736 | "Return the number of screen lines in the text area of the selected window. | 4752 | "Return the number of screen lines in the text area of the selected window. |
| 4737 | 4753 | ||
| 4738 | This is different from `window-text-height' in that this function counts | 4754 | This is different from `window-text-height' in that this function counts |
| 4739 | lines in units of the height of the font used by the default face displayed | 4755 | lines in units of the height of the font used by the default face displayed |
| 4740 | in the window, not in units of the frame's default font. | 4756 | in the window, not in units of the frame's default font, and also accounts |
| 4757 | for `line-spacing', if any, defined for the window's buffer or frame. | ||
| 4741 | 4758 | ||
| 4742 | The value is a floating-point number." | 4759 | The value is a floating-point number." |
| 4743 | (let ((canonical (window-text-height)) | 4760 | (let ((canonical (window-text-height)) |
| 4744 | (fch (frame-char-height)) | 4761 | (fch (frame-char-height)) |
| 4745 | (dfh (default-font-height))) | 4762 | (dlh (default-line-height))) |
| 4746 | (/ (* (float canonical) fch) dfh))) | 4763 | (/ (* (float canonical) fch) dlh))) |
| 4747 | 4764 | ||
| 4748 | ;; Returns non-nil if partial move was done. | 4765 | ;; Returns non-nil if partial move was done. |
| 4749 | (defun line-move-partial (arg noerror to-end) | 4766 | (defun line-move-partial (arg noerror to-end) |
| @@ -4751,31 +4768,24 @@ The value is a floating-point number." | |||
| 4751 | ;; Move backward (up). | 4768 | ;; Move backward (up). |
| 4752 | ;; If already vscrolled, reduce vscroll | 4769 | ;; If already vscrolled, reduce vscroll |
| 4753 | (let ((vs (window-vscroll nil t)) | 4770 | (let ((vs (window-vscroll nil t)) |
| 4754 | (dfh (default-font-height))) | 4771 | (dlh (default-line-height))) |
| 4755 | (when (> vs dfh) | 4772 | (when (> vs dlh) |
| 4756 | (set-window-vscroll nil (- vs dfh) t))) | 4773 | (set-window-vscroll nil (- vs dlh) t))) |
| 4757 | 4774 | ||
| 4758 | ;; Move forward (down). | 4775 | ;; Move forward (down). |
| 4759 | (let* ((lh (window-line-height -1)) | 4776 | (let* ((lh (window-line-height -1)) |
| 4777 | (rowh (car lh)) | ||
| 4760 | (vpos (nth 1 lh)) | 4778 | (vpos (nth 1 lh)) |
| 4761 | (ypos (nth 2 lh)) | 4779 | (ypos (nth 2 lh)) |
| 4762 | (rbot (nth 3 lh)) | 4780 | (rbot (nth 3 lh)) |
| 4763 | (this-lh (window-line-height)) | 4781 | (this-lh (window-line-height)) |
| 4764 | (this-height (nth 0 this-lh)) | 4782 | (this-height (car this-lh)) |
| 4765 | (this-ypos (nth 2 this-lh)) | 4783 | (this-ypos (nth 2 this-lh)) |
| 4766 | (dfh (default-font-height)) | 4784 | (dlh (default-line-height)) |
| 4767 | (lsp (if (display-graphic-p) | 4785 | (wslines (window-screen-lines)) |
| 4768 | (or line-spacing | 4786 | py vs last-line) |
| 4769 | (default-value 'line-spacing) | 4787 | (if (> (mod wslines 1.0) 0.0) |
| 4770 | (frame-parameter nil 'line-spacing) | 4788 | (setq wslines (round (+ wslines 0.5)))) |
| 4771 | 0) | ||
| 4772 | 0)) | ||
| 4773 | py vs rowh dlh) | ||
| 4774 | (if (floatp lsp) | ||
| 4775 | (setq lsp (* dfh lsp))) | ||
| 4776 | ;; Default height of a text line, accounting for the default | ||
| 4777 | ;; face's font and line-spacing, if any. | ||
| 4778 | (setq dlh (+ dfh lsp)) | ||
| 4779 | (when (or (null lh) | 4789 | (when (or (null lh) |
| 4780 | (>= rbot dlh) | 4790 | (>= rbot dlh) |
| 4781 | (<= ypos (- dlh)) | 4791 | (<= ypos (- dlh)) |
| @@ -4798,6 +4808,19 @@ The value is a floating-point number." | |||
| 4798 | (if col-row | 4808 | (if col-row |
| 4799 | (- (cdr col-row) (window-vscroll)) | 4809 | (- (cdr col-row) (window-vscroll)) |
| 4800 | (cdr (posn-col-row ppos)))))) | 4810 | (cdr (posn-col-row ppos)))))) |
| 4811 | ;; VPOS > 0 means the last line is only partially visible. | ||
| 4812 | ;; But if the part that is visible is at least as tall as the | ||
| 4813 | ;; default font, that means the line is actually fully | ||
| 4814 | ;; readable, and something like line-spacing is hidden. So in | ||
| 4815 | ;; that case we accept the last line in the window as still | ||
| 4816 | ;; visible, and consider the margin as starting one line | ||
| 4817 | ;; later. | ||
| 4818 | (if (and vpos (> vpos 0)) | ||
| 4819 | (if (and rowh | ||
| 4820 | (>= rowh (default-font-height)) | ||
| 4821 | (< rowh dlh)) | ||
| 4822 | (setq last-line (min (- wslines scroll-margin) vpos)) | ||
| 4823 | (setq last-line (min (- wslines scroll-margin 1) (1- vpos))))) | ||
| 4801 | (cond | 4824 | (cond |
| 4802 | ;; If last line of window is fully visible, and vscrolling | 4825 | ;; If last line of window is fully visible, and vscrolling |
| 4803 | ;; more would make this line invisible, move forward. | 4826 | ;; more would make this line invisible, move forward. |
| @@ -4811,8 +4834,7 @@ The value is a floating-point number." | |||
| 4811 | ((and (or (null this-height) (<= this-height dlh)) | 4834 | ((and (or (null this-height) (<= this-height dlh)) |
| 4812 | vpos | 4835 | vpos |
| 4813 | (> vpos 0) | 4836 | (> vpos 0) |
| 4814 | (< py | 4837 | (< py last-line)) |
| 4815 | (min (- (window-screen-lines) scroll-margin 1) (1- vpos)))) | ||
| 4816 | nil) | 4838 | nil) |
| 4817 | ;; When already vscrolled, we vscroll some more if we can, | 4839 | ;; When already vscrolled, we vscroll some more if we can, |
| 4818 | ;; or clear vscroll and move forward at end of tall image. | 4840 | ;; or clear vscroll and move forward at end of tall image. |
| @@ -4824,8 +4846,7 @@ The value is a floating-point number." | |||
| 4824 | ;; but also optionally vscroll one line so redisplay won't recenter. | 4846 | ;; but also optionally vscroll one line so redisplay won't recenter. |
| 4825 | ((and vpos | 4847 | ((and vpos |
| 4826 | (> vpos 0) | 4848 | (> vpos 0) |
| 4827 | (= py (min (- (window-screen-lines) scroll-margin 1) | 4849 | (= py last-line)) |
| 4828 | (1- vpos)))) | ||
| 4829 | ;; Don't vscroll if the partially-visible line at window | 4850 | ;; Don't vscroll if the partially-visible line at window |
| 4830 | ;; bottom has the default height (a.k.a. "just one more text | 4851 | ;; bottom has the default height (a.k.a. "just one more text |
| 4831 | ;; line"): in that case, we do want redisplay to behave | 4852 | ;; line"): in that case, we do want redisplay to behave |
| @@ -4880,19 +4901,7 @@ The value is a floating-point number." | |||
| 4880 | ;; If we moved into a tall line, set vscroll to make | 4901 | ;; If we moved into a tall line, set vscroll to make |
| 4881 | ;; scrolling through tall images more smooth. | 4902 | ;; scrolling through tall images more smooth. |
| 4882 | (let ((lh (line-pixel-height)) | 4903 | (let ((lh (line-pixel-height)) |
| 4883 | (dfh (default-font-height)) | 4904 | (dlh (default-line-height))) |
| 4884 | (lsp (if (display-graphic-p) | ||
| 4885 | (or line-spacing | ||
| 4886 | (default-value 'line-spacing) | ||
| 4887 | (frame-parameter nil 'line-spacing) | ||
| 4888 | 0) | ||
| 4889 | 0)) | ||
| 4890 | dlh) | ||
| 4891 | ;; DLH is the default height of a text line, accounting | ||
| 4892 | ;; for the default face's font and line-spacing, if any. | ||
| 4893 | (if (floatp lsp) | ||
| 4894 | (setq lsp (* dfh lsp))) | ||
| 4895 | (setq dlh (+ dfh lsp)) | ||
| 4896 | (if (and (< arg 0) | 4905 | (if (and (< arg 0) |
| 4897 | (< (point) (window-start)) | 4906 | (< (point) (window-start)) |
| 4898 | (> lh dlh)) | 4907 | (> lh dlh)) |