[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting column position accounting for overlays
From: |
Eli Zaretskii |
Subject: |
Re: Getting column position accounting for overlays |
Date: |
Sat, 08 Aug 2015 18:43:31 +0300 |
> From: Yuri D'Elia <address@hidden>
> Date: Sat, 8 Aug 2015 17:19:02 +0200
>
> On 08/08/15 16:45, Eli Zaretskii wrote:
> >> Ah yes, but that's precisely the problem: I need to calculate POS
> >> beforehand.
> >
> > Yes, of course. But you will have the same problem if you do get the
> > text dimensions: you need to compare that with something to do useful
> > things with the value. Right?
>
> Getting text dimensions was/is sort of a work-around.
> If I could get displayed text easily, the iteration over overlays
> wouldn't be needed: I could just take the string length.
Take the string length and do what with it?
And please don't assume that given a string you can compute its
visual length easily: you can't, not with variable-pitch fonts. And
then you have images, stretches, etc.
> Again, it would have problems on its own as we discussed, so far none of
> the solutions work perfectly.
Solutions to what problem(s)?
> To be more concrete, what about a (visual-column) function, that just
> gives what's currently needed?
I've already shown you a way to compute that, several message ago.
Let me repeat:
(/ (car (window-text-pixel-size nil (line-beginning-position) (point)))
(default-font-width))
> (visual-column &optional logical)
>
> Return the horizontal position of point. Beginning of the *visual* line
> is column 0. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^
This is contrary to current-column conventions: it counts from the
beginning of the physical line, not visual line. If you want to count
from the beginning of the visual line, replace line-beginning-position
above with something like
(save-excursion (beginning-of-visual-line) (point))
- Re: Getting column position accounting for overlays, (continued)
- Re: Getting column position accounting for overlays, Eli Zaretskii, 2015/08/04
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/05
- Re: Getting column position accounting for overlays, Eli Zaretskii, 2015/08/05
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/05
- Re: Getting column position accounting for overlays, Eli Zaretskii, 2015/08/05
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/07
- Re: Getting column position accounting for overlays, Eli Zaretskii, 2015/08/07
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/08
- Re: Getting column position accounting for overlays, Eli Zaretskii, 2015/08/08
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/08
- Re: Getting column position accounting for overlays,
Eli Zaretskii <=
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/08
- Re: Getting column position accounting for overlays, Eli Zaretskii, 2015/08/08
- Re: Getting column position accounting for overlays, Yuri D'Elia, 2015/08/08