[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add a function that returns pixel distance between points?

From: Eli Zaretskii
Subject: Re: Add a function that returns pixel distance between points?
Date: Sun, 31 Jan 2021 17:24:56 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Sun, 31 Jan 2021 00:17:58 -0500
> Cc: emacs-devel@gnu.org
> I want to align text-based tables by pixel size, as in:
> | header | header | header |
> | 1      | 1      | 8      |
> | 2      | 6      | 3      |
> When the text is displayed in variable-pitch font, the bars aren’t aligned. 
> I’m using display property (space :align-to) to align those bars. To know 
> with pixel position to align to, I need to calculate each column’s pixel 
> width, and met the difficulties mentioned earlier.

So the columns in your case have width that changes dynamically?  That
is, if I type enough characters into a cell that the current width is
no longer sufficient, the width of the cell's column will be

Also, I don't think I understand why it is a problem for you that
posn-at-point requires point to be visible -- are you generating the
table in a buffer that is not displayed, or in a portion of a buffer
that is not visible?  Or is there some other reason why you have
problems with this requirement of posn-at-point?

Finally, I'm not sure why the behavior of window-text-pixel-size is a
problem: if you use :align-to with pixel units (as opposed to column
units), then you should _want_ it to account for stuff like
line-prefix, no?

reply via email to

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