[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: line-pixel-height beyond eol
From: |
Tak Kunihiro |
Subject: |
Re: line-pixel-height beyond eol |
Date: |
Sat, 23 Sep 2017 21:57:00 +0900 (JST) |
Thank you for the response.
>> Thus I have to know height of pixel on the top window line.
>
> Can you use vertical-motion for that?
After try and error, I learned how to get height of pixel on
visual-line using `vertical-motion' and `posn-x-y' as shown below.
However, when (window-hscroll) is large, I cannot get y location of
cursor using `posn-x-y'. Can you give me suggestion how to get y
location of cursor even when when (window-hscroll) is large?
(defun pixel-visual-line-height ()
"Return height in pixels of text line in the selected window.
Value is the height of pixels in the line visually shown by
current screen. Note that `line-pixel-height' returns the
maximum height of a line."
(let ((pos-save (window-start)) ; save window configuration
(vs-save (window-vscroll nil t))
(height (frame-char-height)) ; (line-pixel-height)
pos-a pos-b y-a y-b
height-meas)
(save-excursion ; measure actual height
(beginning-of-visual-line)
(set-window-vscroll nil 0 t)
(set-window-start nil (point) t)
(and (setq pos-a (posn-at-point))
(vertical-motion 1)
(setq pos-b (posn-at-point))
(integerp (setq y-a (cdr (posn-x-y pos-a))))
(integerp (setq y-b (cdr (posn-x-y pos-b))))
(integerp (setq height-meas (- y-b y-a)))
(setq height height-meas))
(set-window-start nil pos-save t) ; restore window configuration
(set-window-vscroll nil vs-save t))
height))
- line-pixel-height beyond eol, Tak Kunihiro, 2017/09/12
- Re: line-pixel-height beyond eol, Eli Zaretskii, 2017/09/12
- Re: line-pixel-height beyond eol, Tak Kunihiro, 2017/09/12
- Re: line-pixel-height beyond eol, Eli Zaretskii, 2017/09/13
- Re: line-pixel-height beyond eol, Tak Kunihiro, 2017/09/13
- Re: line-pixel-height beyond eol, Eli Zaretskii, 2017/09/14
- Re: line-pixel-height beyond eol, Tak Kunihiro, 2017/09/14
- Re: line-pixel-height beyond eol, Eli Zaretskii, 2017/09/15
- Re: line-pixel-height beyond eol,
Tak Kunihiro <=
- Re: line-pixel-height beyond eol, Eli Zaretskii, 2017/09/23