* Buttons and Labels on three columns
@ 2024-07-08 13:56 Heime
0 siblings, 0 replies; only message in thread
From: Heime @ 2024-07-08 13:56 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
I use the command mudu to have a list of buttons in three columns.
Whet a button is pressed, the corresponding label turns red.
Rather than hardwiring the functions and labels, I want to pass
three list (one list per column), one for each column with arbitrary
functions and labels.
(defun mudu-color (monbf monlb monlit monpt)
"In the buffer MONBF, set the colour MONLIT at the point MONPT."
(with-current-buffer monbf
(save-excursion
(goto-char monpt)
(let ( (start (point))
(end (line-end-position)) )
;; Clear previous colours
(remove-text-properties (point-min) (point-max) '(face nil))
;; Add color to the clicked text
(when (search-forward monlb end t)
(add-text-properties
(match-beginning 0) (match-end 0)
`(face (:foreground ,monlit)))) ))) )
(defun mpdu-outbd (button)
(mudu-data " OUTBD TEXT "))
(defun mpdu-norm (button)
(mudu-data " NORM TEXT "))
(defun mudu-inbd-eng-pri (button)
(mudu-data " INBD ENG PRI "))
(defun mudu-inbd-pfd (button)
(mudu-data " INBD PFD TEXT "))
(defun mudu-inbd-hfd (button)
(mudu-data " INBD HFD TEXT "))
(defun mudu (monbf)
"Set up the MUDU buffer with buttons and text."
(with-current-buffer (get-buffer-create monbf)
;; Clear the buffer to avoid repeated content on multiple invocations
(erase-buffer)
(insert " MAIN PANEL DU \n\n")
(insert " ")
(insert-button "[-]"
'action (lambda (b)
(mudu-color monbf "OUTBD" "red" (point))
(mudu-outbd b)))
(insert " OUTBD ")
(insert-button "[-]"
'action (lambda (b)
(mudu-color monbf "NORM" "red" (point))
(mudu-norm b)))
(mpdu-colorat-insert " NORM " "red")
(insert-button "[-]"
'action (lambda (b)
(mudu-color monbf "INBD ENG PRI" "red" (point))
(mudu-inbd-eng-pri b)))
(insert " INBD ENG PRI \n")
(insert (espz 24))
(insert-button "[-]"
'action (lambda (b)
(mudu-color monbf "INBD PFD" "red" (point))
(mudu-inbd-pfd b)))
(insert " INBD PFD \n")
(insert (espz 24))
(insert-button "[-]"
'action (lambda (b)
(mudu-color monbf "INBD HFD" "red" (point))
(mudu-inbd-hfd b)))
(insert " INBD HFD \n"))
(pop-to-buffer monbf))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-07-08 13:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-08 13:56 Buttons and Labels on three columns Heime
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).