unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Horizontal centering in the display engine
@ 2021-04-15  5:13 Paul W. Rankin via Emacs development discussions.
  2021-04-15  7:04 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Paul W. Rankin via Emacs development discussions. @ 2021-04-15  5:13 UTC (permalink / raw)
  To: sbaugh; +Cc: Eli Zaretskii, emacs-devel

> From: sbaugh@catern.com
> Date: Wed, 14 Apr 2021 11:25:41 -0400
>
> Yes, that makes sense. So I'm asking about how difficult it would be to
> add a new element to the :align-to expression language, one which
> specifies the width of the current line.

I apologise in advance if I've misunderstood your aims, but you can use the
line-prefix text property and compute the value of :align-to based on the line
width and the window text width:

(defun center-align-line ()
  (let (line-width align-col)
    (setq line-width (- (line-end-position)
                        (line-beginning-position)))
    (setq align-col (/ (- (window-body-width) line-width)
                       2))
    (put-text-property (line-beginning-position)
                       (line-end-position)
                       'line-prefix
                       `(space :align-to ,align-col))))

Achieving this dynamically is dependent upon your major mode; if you're using a
markup syntax, you could use font-lock and a regular expression, or if manually
applied you could use a text property flag.


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Horizontal centering in the display engine
@ 2021-04-13 18:25 sbaugh
  2021-04-13 18:39 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: sbaugh @ 2021-04-13 18:25 UTC (permalink / raw)
  To: emacs-devel


The display engine supports display text left-aligned and right-aligned.
far as I can tell, it doesn't support displaying text centered.  This
would be useful for several things:

- User interfaces
- Presentations (this is my use case)

Currently there are a number of modes which implement a pseudo-centering
by inserting spaces based on the size of the window.  This has several
issues, among them that it doesn't automatically recenter when the
window size changes.

So it would be nice if the display engine natively supported displaying
centered text.

How difficult would this be to implement?  Could someone (namely, me)
with no prior exposure to the notoriously-complex display engine code
implement it in, say, a week of hacking?

Thanks!




^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-04-15 13:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15  5:13 Horizontal centering in the display engine Paul W. Rankin via Emacs development discussions.
2021-04-15  7:04 ` Eli Zaretskii
2021-04-15 11:39   ` Paul W. Rankin via Emacs development discussions.
2021-04-15 12:43     ` Stefan Monnier
2021-04-15 13:05       ` Paul W. Rankin via Emacs development discussions.
  -- strict thread matches above, loose matches on Subject: below --
2021-04-13 18:25 sbaugh
2021-04-13 18:39 ` Eli Zaretskii
2021-04-13 19:28   ` sbaugh
2021-04-13 19:43     ` Eli Zaretskii
2021-04-13 20:49       ` sbaugh
2021-04-14  6:56         ` Eli Zaretskii
2021-04-14 13:28           ` sbaugh
2021-04-14 13:42             ` Yuan Fu
2021-04-14 14:04             ` Stefan Monnier
2021-04-14 15:22               ` sbaugh
2021-04-14 14:42             ` Eli Zaretskii
2021-04-14 15:25               ` sbaugh
2021-04-14 15:52                 ` Eli Zaretskii
2021-04-14  8:28         ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).