all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Heime <heimeborgia@protonmail.com>
To: Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: Re: Highlighting text next to button
Date: Sun, 30 Jun 2024 21:52:12 +0000	[thread overview]
Message-ID: <MquN6MkkG5183WJ5TTxXQNpfnHd180iDaKTOsru_YWudp-si-kjtbqWfaBICTSuS4l147jMF5fjlejs13SjlDHYpBJPy8CcPidieQsKkbVg=@protonmail.com> (raw)
In-Reply-To: <Do8cmPB_DcqE7NdTErwQas2XsVBTXxw11aatqcaVIlbX5xZSHkPMOpuZscKZG0dSk7tQ9jtdTTsfwktKQ2mFHPMMLyoICdeQjnTxWOcTTnE=@protonmail.com>

On Sunday, June 30th, 2024 at 8:00 PM, Heime <heimeborgia@protonmail.com> wrote:

> I have the function monde that displays some buttons with associated text
> describing what the button does.
> 
> I would like to highlight the description text corresponding to the button
> that was pressed, with NORM being the default when calling the function.
> What can I do ?
> 
> (defun spaz (w)
> "Make a string of width W made of spaces."
> (make-string w ?\s))
> 
> (defun mondu ()
> 
> (interactive)
> 
> (with-current-buffer (get-buffer-create "Mondu")
> 
> (insert " MAIN PANEL DU \n\n")
> 
> (insert " ")
> (insert-button "[-]" 'action 'mondu-outbd)
> (insert " OUTBD ")
> 
> (insert-button "[-]" 'action 'mondu-norm)
> (insert " NORM ")
> 
> ;;------------------------------------------------------------
> 
> (insert-button "[-]" 'action 'mondu-inbd-eng-pri)
> (insert " INBD ENG PRI \n")
> 
> (insert (spaz 24))
> (insert-button "[-]" 'action 'mondu-inbd-pfd)
> (insert " INBD PFD \n")
> 
> (insert (spaz 24))
> (insert-button "[-]" 'action 'mondu-inbd-hfd)
> (insert " INBD HFD \n") )
> 
> (pop-to-buffer "Mondu") )

Have made the following.  But I also have to activate the text that is printed
to the help buffer when pressing the button.


(defun mondu-color-text (text color)
  "Color TEXT in the specified COLOR in the Mondu buffer."

  (with-current-buffer "Mondu"
    (save-excursion
      (goto-char (point-min))
      (when (search-forward text nil t)
        (let ((start (match-beginning 0))
              (end (match-end 0)))
          (add-text-properties start end `(face (:foreground ,color))))))))


(defun mondu ()
  "Set up the Mondu buffer with buttons and text."

  (interactive)

  (with-current-buffer (get-buffer-create "Mondu")

    (erase-buffer) ;; Clear the buffer to avoid repeated content on multiple invocations

    (insert " MAIN PANEL DU \n\n")

    (insert " ")
    (insert-button "[-]"
      'action (lambda (_) (mondu-color-text " OUTBD " "red")))
    (insert " OUTBD   ")

    (insert-button "[-]"
      'action (lambda (_) (mondu-color-text " NORM   " "red")))
    (montejura-insert-colorat " NORM   " "red")

    (insert-button "[-]"
      'action (lambda (_) (mondu-color-text " INBD ENG PRI " "red")))
    (insert " INBD ENG PRI  \n")

    (insert (espz 24))
    (insert-button "[-]"
      'action (lambda (_) (mondu-color-text " INBD PFD " "red")))
    (insert " INBD PFD  \n")

    (insert (espz 24))
    (insert-button "[-]"
      'action (lambda (_) (mondu-color-text " INBD HFD " "red")))
    (insert " INBD HFD  \n"))

  (pop-to-buffer "Mondu"))







  reply	other threads:[~2024-06-30 21:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-30 20:00 Highlighting text next to button Heime
2024-06-30 21:52 ` Heime [this message]
2024-06-30 22:11   ` Stephen Berman
2024-06-30 22:32     ` Heime
2024-07-01  7:53       ` Stephen Berman
2024-07-01  8:52         ` Heime
2024-07-01  9:26           ` Stephen Berman

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='MquN6MkkG5183WJ5TTxXQNpfnHd180iDaKTOsru_YWudp-si-kjtbqWfaBICTSuS4l147jMF5fjlejs13SjlDHYpBJPy8CcPidieQsKkbVg=@protonmail.com' \
    --to=heimeborgia@protonmail.com \
    --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.