all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Dedicated buffer with buttons that show messages in a central display area
@ 2022-11-11 14:33 Heime
  2022-11-11 15:15 ` Emanuel Berg
  2022-11-11 18:38 ` Jean Louis
  0 siblings, 2 replies; 10+ messages in thread
From: Heime @ 2022-11-11 14:33 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I would like to have a dedicated buffer that has a number of buttons that display messages in a central display area
when pressed.  Can this be done?    
 





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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-11 14:33 Dedicated buffer with buttons that show messages in a central display area Heime
@ 2022-11-11 15:15 ` Emanuel Berg
  2022-11-11 18:38 ` Jean Louis
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2022-11-11 15:15 UTC (permalink / raw)
  To: help-gnu-emacs

Heime wrote:

> I would like to have a dedicated buffer that has a number of
> buttons that display messages in a central display area when
> pressed. Can this be done?

Sure, start with a (1) button ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-11 14:33 Dedicated buffer with buttons that show messages in a central display area Heime
  2022-11-11 15:15 ` Emanuel Berg
@ 2022-11-11 18:38 ` Jean Louis
  2022-11-12  7:58   ` Heime
  1 sibling, 1 reply; 10+ messages in thread
From: Jean Louis @ 2022-11-11 18:38 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-11-11 17:35]:
> I would like to have a dedicated buffer that has a number of buttons that display messages in a central display area
> when pressed.  Can this be done?    

It can be done, but you do not define your desires clearly.

Each buffer in Emacs is dedicated, that I know.

"number of buttons", what kind of buttons? Do you mean like button
links as explained in (info "(elisp) Buttons") ?

Define "central display area", do you mean center of the visible
window? Or center of the buffer? Horizontally and vertically to window
or buffer? Or center of the text width before wrap?

I have this function:

(defun rcd-button-insert (button-text action-function &optional how-many revert-key revert-value)
  "Insert button BUTTON-TEXT with ACTION-FUNCTION.

Optional number HOW-MANY adds superscript digits to BUTTON-TEXT."
  (let* ((revert-key (or revert-key "revert-key"))
	 (revert-key (intern revert-key))
	 (rever-value (or revert-value button-text)))
  (insert-text-button button-text
		      'action
                      action-function
		      'follow-link t
		      revert-key revert-value)
  (when how-many
    (insert (rcd-superscript-digits how-many)))))

Which uses this one:

(defun rcd-superscript-digits (number)
  "Return unicode digits for NUMBER."
  (let* ((string (cond ((numberp number) (number-to-string number))
		       ((stringp number) number)))
	 (digits (split-string string "" t " ")))
    (with-temp-buffer
      (while digits
	(insert (rcd-superscript-digit-1 (string-to-number (pop digits)))))
      (buffer-string))))

Then you go like this:

(rcd-button-insert "Display my message" 
 (lambda (_) (message "My message"))) <-- evaluate it here

or like this:

(rcd-button-insert "Display my message" 
 (lambda (_) (message "My message")) 21)Display my message²¹

Function is made so that buttons displayed may be reverted, but that
is not subject of your interest now.

(defun rcd-button-revert-source (&optional revert-key)
  "Revert the button source.

REVERT-KEY is optional and by default the symbol 'REVERT-KEY. The
value of REVERT-KEY will be returned as source."
;; (rcd-button-insert "Hello" (lambda (_) (message-box "Hello")) nil nil "⟦ (hyperscope 123) ⟧")
  (let ((point (point))
	(revert-key (or revert-key 'revert-key)))
    (save-excursion
      (goto-char (point-min))
      (let (my-prop)
	(while (setq my-prop 
		     (text-property-search-forward 
		      revert-key))
	  (when my-prop
	    (let ((begin (prop-match-beginning my-prop))
		  (end (prop-match-end my-prop))
		  (value (prop-match-value my-prop)))
	      (set-text-properties (1- begin) end nil)
	      (delete-region begin end)
	      (goto-char begin)
	      (insert (format "%s" value)))))))
    (goto-char point)))

-- 
Jean

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

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



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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-11 18:38 ` Jean Louis
@ 2022-11-12  7:58   ` Heime
  2022-11-12  8:31     ` Jean Louis
  0 siblings, 1 reply; 10+ messages in thread
From: Heime @ 2022-11-12  7:58 UTC (permalink / raw)
  To: Jean Louis; +Cc: Heime via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

------- Original Message -------
On Friday, November 11th, 2022 at 6:38 PM, Jean Louis <bugs@gnu.support> wrote:


> * Heime heimeborgia@protonmail.com [2022-11-11 17:35]:
> 
> > I would like to have a dedicated buffer that has a number of buttons that display messages in a central display area
> > when pressed. Can this be done?
> 
> 
> It can be done, but you do not define your desires clearly.
> 
> Each buffer in Emacs is dedicated, that I know.
> 
> "number of buttons", what kind of buttons? Do you mean like button
> links as explained in (info "(elisp) Buttons") ?
> 
> Define "central display area", do you mean center of the visible
> window? Or center of the buffer? Horizontally and vertically to window
> or buffer? Or center of the text width before wrap?

To look like MCDU (Multi-Function Control Display Unit) on aircraft.

https://www.uasc.com/home/shop/avionics/mcdu

> I have this function:
> 
> (defun rcd-button-insert (button-text action-function &optional how-many revert-key revert-value)
> "Insert button BUTTON-TEXT with ACTION-FUNCTION.
> 
> Optional number HOW-MANY adds superscript digits to BUTTON-TEXT."
> (let* ((revert-key (or revert-key "revert-key"))
> (revert-key (intern revert-key))
> (rever-value (or revert-value button-text)))
> (insert-text-button button-text
> 'action
> action-function
> 'follow-link t
> revert-key revert-value)
> (when how-many
> (insert (rcd-superscript-digits how-many)))))
> 
> Which uses this one:
> 
> (defun rcd-superscript-digits (number)
> "Return unicode digits for NUMBER."
> (let* ((string (cond ((numberp number) (number-to-string number))
> ((stringp number) number)))
> (digits (split-string string "" t " ")))
> (with-temp-buffer
> (while digits
> (insert (rcd-superscript-digit-1 (string-to-number (pop digits)))))
> (buffer-string))))
> 
> Then you go like this:
> 
> (rcd-button-insert "Display my message"
> (lambda () (message "My message"))) <-- evaluate it here
> 
> or like this:
> 
> (rcd-button-insert "Display my message"
> (lambda () (message "My message")) 21)Display my message²¹
> 
> Function is made so that buttons displayed may be reverted, but that
> is not subject of your interest now.
> 
> (defun rcd-button-revert-source (&optional revert-key)
> "Revert the button source.
> 
> REVERT-KEY is optional and by default the symbol 'REVERT-KEY. The
> value of REVERT-KEY will be returned as source."
> ;; (rcd-button-insert "Hello" (lambda (_) (message-box "Hello")) nil nil "⟦ (hyperscope 123) ⟧")
> (let ((point (point))
> (revert-key (or revert-key 'revert-key)))
> (save-excursion
> (goto-char (point-min))
> (let (my-prop)
> (while (setq my-prop
> (text-property-search-forward
> revert-key))
> (when my-prop
> (let ((begin (prop-match-beginning my-prop))
> (end (prop-match-end my-prop))
> (value (prop-match-value my-prop)))
> (set-text-properties (1- begin) end nil)
> (delete-region begin end)
> (goto-char begin)
> (insert (format "%s" value)))))))
> (goto-char point)))
> 
> --
> Jean
> 
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
> 
> In support of Richard M. Stallman
> https://stallmansupport.org/



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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-12  7:58   ` Heime
@ 2022-11-12  8:31     ` Jean Louis
  2022-11-13 10:02       ` Heime
  2022-11-13 11:26       ` Emanuel Berg
  0 siblings, 2 replies; 10+ messages in thread
From: Jean Louis @ 2022-11-12  8:31 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-11-12 10:59]:
> > Define "central display area", do you mean center of the visible
> > window? Or center of the buffer? Horizontally and vertically to window
> > or buffer? Or center of the text width before wrap?
> 
> To look like MCDU (Multi-Function Control Display Unit) on aircraft.
> 
> https://www.uasc.com/home/shop/avionics/mcdu

Hey, why not tell me earlier. 

That is already built-in Emacs feature, just do M-x mcdu and the
control panel is displayed.


-- 
Jean

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

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



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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-12  8:31     ` Jean Louis
@ 2022-11-13 10:02       ` Heime
  2022-11-13 15:42         ` Jean Louis
  2022-11-13 11:26       ` Emanuel Berg
  1 sibling, 1 reply; 10+ messages in thread
From: Heime @ 2022-11-13 10:02 UTC (permalink / raw)
  To: Jean Louis; +Cc: Heime via Users list for the GNU Emacs text editor

Would you give me an example of how to place a button at a specified buffer position? 



------- Original Message -------
On Saturday, November 12th, 2022 at 8:31 AM, Jean Louis <bugs@gnu.support> wrote:


> * Heime heimeborgia@protonmail.com [2022-11-12 10:59]:
> 
> > > Define "central display area", do you mean center of the visible
> > > window? Or center of the buffer? Horizontally and vertically to window
> > > or buffer? Or center of the text width before wrap?
> > 
> > To look like MCDU (Multi-Function Control Display Unit) on aircraft.
> > 
> > https://www.uasc.com/home/shop/avionics/mcdu
> 
> 
> Hey, why not tell me earlier.
> 
> That is already built-in Emacs feature, just do M-x mcdu and the
> control panel is displayed.
> 
> 
> --
> Jean
> 
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
> 
> In support of Richard M. Stallman
> https://stallmansupport.org/



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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-12  8:31     ` Jean Louis
  2022-11-13 10:02       ` Heime
@ 2022-11-13 11:26       ` Emanuel Berg
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2022-11-13 11:26 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

>>> Define "central display area", do you mean center of the
>>> visible window? Or center of the buffer? Horizontally and
>>> vertically to window or buffer? Or center of the text
>>> width before wrap?
>> 
>> To look like MCDU (Multi-Function Control Display Unit)
>> on aircraft.
>> 
>> https://www.uasc.com/home/shop/avionics/mcdu
>
> Hey, why not tell me earlier. 
>
> That is already built-in Emacs feature, just do M-x mcdu and
> the control panel is displayed.

In US and western fighter jets they have HUDs - Head-up
displays - so can we have M-x hud RET as well, please?

Actually development seems to have gone forward since I played
F/A-18 Hornet in the 90s, as it says

  Although they were initially developed for military
  aviation, HUDs are now used in commercial aircraft,
  automobiles, and other (mostly professional)
  applications. [1]

And isn't this what geek guys now build for their homes from
old monitors, so-called smart/magic mirrors?

So you see? There is absolutely no reason for us not to have
it!

[1] https://en.wikipedia.org/wiki/Head-up_display

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-13 10:02       ` Heime
@ 2022-11-13 15:42         ` Jean Louis
  2022-11-15  0:54           ` Emanuel Berg
  0 siblings, 1 reply; 10+ messages in thread
From: Jean Louis @ 2022-11-13 15:42 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

* Heime <heimeborgia@protonmail.com> [2022-11-13 13:02]:
> Would you give me an example of how to place a button at a specified buffer position? 

How would you specify it?

You may use function `goto-char' as linear movement.

You could as well use `goto-line' and then (goto-char (point-at-bol))
and after `forward-char' to go to some column of the text, this
reminds me as coordinate with X and Y.

(defun goto-x-y (x y)
  "Goto to line X, char Y."
  (goto-line x)
  (goto-char (point-at-bol))
  (forward-char y))

(goto-x-y 10 20)

-- 
Jean

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

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



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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-13 15:42         ` Jean Louis
@ 2022-11-15  0:54           ` Emanuel Berg
  2022-11-15 19:39             ` Heime
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2022-11-15  0:54 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis wrote:

> You may use function `goto-char' as linear movement.
>
> You could as well use `goto-line' and then (goto-char
> (point-at-bol)) and after `forward-char' to go to some
> column of the text, this reminds me as coordinate with
> X and Y.
>
> (defun goto-x-y (x y)
>   "Goto to line X, char Y."
>   (goto-line x)
>   (goto-char (point-at-bol))
>   (forward-char y))

Problematic, you can use gamegrid for this

M-x tetris RET

>   (goto-char (point-at-bol))

It's called `line-beginning-position' now ...

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: Dedicated buffer with buttons that show messages in a central display area
  2022-11-15  0:54           ` Emanuel Berg
@ 2022-11-15 19:39             ` Heime
  0 siblings, 0 replies; 10+ messages in thread
From: Heime @ 2022-11-15 19:39 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs


------- Original Message -------
On Tuesday, November 15th, 2022 at 12:54 AM, Emanuel Berg <incal@dataswamp.org> wrote:


> Jean Louis wrote:
> 
> > You may use function `goto-char' as linear movement.
> > 
> > You could as well use `goto-line' and then (goto-char (point-at-bol)) and after` forward-char' to go to some
> > column of the text, this reminds me as coordinate with
> > X and Y.
> > 
> > (defun goto-x-y (x y)
> > "Goto to line X, char Y."
> > (goto-line x)
> > (goto-char (point-at-bol))
> > (forward-char y))
 
This does not work when buffer does not have position (x,y) as whitespace.

 
> Problematic, you can use gamegrid for this
> 
> M-x tetris RET
> 
> > (goto-char (point-at-bol))
> 
> 
> It's called `line-beginning-position' now ...
> 
> --
> underground experts united
> https://dataswamp.org/~incal



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

end of thread, other threads:[~2022-11-15 19:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-11 14:33 Dedicated buffer with buttons that show messages in a central display area Heime
2022-11-11 15:15 ` Emanuel Berg
2022-11-11 18:38 ` Jean Louis
2022-11-12  7:58   ` Heime
2022-11-12  8:31     ` Jean Louis
2022-11-13 10:02       ` Heime
2022-11-13 15:42         ` Jean Louis
2022-11-15  0:54           ` Emanuel Berg
2022-11-15 19:39             ` Heime
2022-11-13 11:26       ` Emanuel Berg

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.