From: Jean Louis <bugs@gnu.support>
To: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Function to present few centered lines
Date: Wed, 14 Apr 2021 16:03:45 +0300 [thread overview]
Message-ID: <courier.000000006076E841.00006777@stw1.rcdrun.com> (raw)
I would like to show few lines in the center of whole monitor window
by using Emacs. And I miss probably knowledge of some built-in
functions.
In this below for now degraded function I do not know how to enlarge
the font so that the (window-width) and (window-height) also change,
so that I can get realistic numbers which I can use to center lines.
What does not work:
- enlarging font, I don't know how to enlarge it, so that width and
height of window is adjusted to new enlarged font
- centering, I am trying to center line by using window-width and
setting fill-column, it seem it does not center nicely.
(defun present-snippet (snippet)
"This is expected to show few lines with large font in the middle
of maximized frame."
(let* ((snippet (split-string snippet))
(buffer (car snippet)))
(switch-to-buffer-other-frame buffer)
(set-frame-parameter nil 'fullscreen 'maximized)
;; (text-scale-adjust 3) ;;
(let* ((width (window-width))
(height (window-height))
(first-line (- height (length snippet))))
(mapc 'insert (make-list first-line "\n"))
(while snippet
(let* ((line (pop snippet))
(line-length (length line))
(fill-column width)
(place (- (/ width 2) (/ line-length 2))))
(insert line)
(center-line)
(insert "\n"))))))
(present-snippet "Phone: +1234456578")
next reply other threads:[~2021-04-14 13:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 13:03 Jean Louis [this message]
2021-04-14 13:13 ` Function to present few centered lines Eli Zaretskii
2021-04-14 13:35 ` Jean Louis
2021-04-14 14:09 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=courier.000000006076E841.00006777@stw1.rcdrun.com \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.