all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Function to present few centered lines
@ 2021-04-14 13:03 Jean Louis
  2021-04-14 13:13 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Louis @ 2021-04-14 13:03 UTC (permalink / raw)
  To: Help GNU Emacs

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")





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

end of thread, other threads:[~2021-04-14 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-14 13:03 Function to present few centered lines Jean Louis
2021-04-14 13:13 ` Eli Zaretskii
2021-04-14 13:35   ` Jean Louis
2021-04-14 14:09     ` Eli Zaretskii

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.