emacs-pretest-bug
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]