[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: moving point over invisible and intangible text
From: |
Kenichi Handa |
Subject: |
Re: moving point over invisible and intangible text |
Date: |
Fri, 17 Oct 2003 18:03:34 +0900 (JST) |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) |
In article <address@hidden>, Richard Stallman <address@hidden> writes:
> On a related issue, maybe line-move (and friends) could be simplified
> if one could query the display engine about "glyph-after", "glyph-before",
> "glyph-below" and "glyph-above" and let them return a buffer position
> (and possibly also an X and Y pixel position).
> One complication in implementing such features is that they must
> work based on the current buffer contents. They cannot use
> the records kept by the display system about the glyphs on the screen,
> since those could be out of date.
As far as I know, there exists one Emacs Lisp API that runs
display engine (i.e. start_display and move_ti_by_lines)
without actually updating a screen. That is
vertical-motion. So, I think it's possible to implement a
similar function that gives various updated information
about how a some portion of a buffer is displayed.
---
Ken'ichi HANDA
address@hidden
PS. This tricky code gives a width of a string in floarting
point (though it's very slow because of non-clever
algorithm, binary search will make it much much faster).
(defun string-float-width (str)
(with-temp-buffer
(font-lock-mode -1)
(let ((i 0) (done nil))
(while (not done)
(erase-buffer)
(setq i (1+ i))
(message "%d" i)
(insert (propertize " " 'display (list 'space :width (/ i 10.0))))
(insert str)
(goto-char 1)
(setq done (= (vertical-motion 1) 1)))
(- (window-width) (/ i 10.0)))))
(string-float-width " ") => 1.0
(string-float-width (propertize "W" 'face 'variable-pitch))
=> 1.7999999999999972
- Re: moving point over invisible and intangible text, (continued)
- Re: moving point over invisible and intangible text, Luc Teirlinck, 2003/10/15
- Re: moving point over invisible and intangible text, Kim F. Storm, 2003/10/16
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/16
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/17
- Re: moving point over invisible and intangible text,
Kenichi Handa <=
- Re: moving point over invisible and intangible text, Stefan Monnier, 2003/10/16
- Re: moving point over invisible and intangible text, Richard Stallman, 2003/10/17