help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Enclosing text in a box


From: Jean Louis
Subject: Re: Enclosing text in a box
Date: Thu, 17 Nov 2022 09:43:00 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

* Heime <heimeborgia@protonmail.com> [2022-11-16 15:49]:
> 
> Would like to enclose some text in a box?  The box has to automatically 
> adjust its size
> according to the size of the text.
> 
>       (insert "╔══════╗\n")
>       (insert (concat "║" text "║\n" ))
>       (insert "╚══════╝" )

I did not read the rest of answers to your question.

Package is here:

Emacs Lisp: rcd-box.el package for table drawings:
https://hyperscope.link/7/3/9/8/1/Emacs-Lisp-rcd-box-el-package-for-table-drawings-73981.html

Basic function:

(rcd-box-table '(("My text"))) ⇒ "
╔═════════╗
║ My text ║
╚═════════╝

"

If you wish to make it simpler:

(defun rcd-box-text (text)
  (rcd-box-table (list (list text))))

(rcd-box-text "Hello") ⇒ "
╔═══════╗
║ Hello ║
╚═══════╝

"

;; Available box drawing types: DOUBLE, HEAVY, LIGHT

That means you can do:


(rcd-box-table '(("My text")) nil "center" "double") ⇒ "
╔═════════╗
║ My text ║
╚═════════╝

"

(rcd-box-table '(("My text")) nil "center" "heavy") ⇒ "
┏━━━━━━━━━┓
┃ My text ┃
┗━━━━━━━━━┛

"

(rcd-box-table '(("My text")) nil "center" "light") ⇒ "
┌─────────┐
│ My text │
└─────────┘

"

and then you can add it to simpler function like:

(defun rcd-box-text (text &optional type)
  (rcd-box-table (list (list text)) nil "center" type))

(rcd-box-text "And now good bye to all" "heavy") ⇒ "
┏━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ And now good bye to all ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛

"


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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