[Top][All Lists]

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

Re: Horizontal centering in the display engine

From: Eli Zaretskii
Subject: Re: Horizontal centering in the display engine
Date: Wed, 14 Apr 2021 09:56:07 +0300

> From: sbaugh@catern.com
> Date: Tue, 13 Apr 2021 16:49:59 -0400
> >> :align-to (- center (0.5 . line-size))
> >> 
> >> [...]
> >> 
> >> As far as I understand the documentation, there's no way to express
> >> something like line-size currently? Maybe that could be easily added?
> >
> > We have window-text-pixel-size, isn't that what you want?
> But that can't be used in a pixel specification, as far as I understand?

I meant to suggest to use that function to compute the pixel value for
the :align-to spec.

> And anyway, I don't think that's right - as the Elisp manual says,
> "window-text-pixel-size treats the text displayed in a window as a whole
> and does not care about the size of individual lines."

That's a surprising interpretation.  The function accepts FROM and TO
arguments; if those are the beginning and the end of a line, you get
the pixel with of that line and nothing else.

> > E.g., are you planning on centering each line separately, or
> > everything together, or something else?
> Each line separately.

So each line should have a different value of :align-to?

> > IOW, how did you envision you'd put the display property on each line?
> The same display property would be applied to every line.

This contradicts my understanding from above, or what am I missing?

> > and how does this work when the user types text to add more lines, or
> > make a line longer than the window? etc. etc.
> When they add more lines, those new lines are also centered.  If a line
> is longer than the window, it's truncated or wrapped depending on
> truncate-lines, word-wrap, etc., as usual.

If the lines are wrapped, you'd want the continuation line to be
centered as well?

And if we go one level higher, I guess you intend to write a
post-command-hook that recalculates the :align-to specs whenever text
changes, is that right?  Or how did you plan on taking text changes
into consideration?

reply via email to

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