Subject: mailing-list for TeXmacs Users
List archive
From : Massimiliano Gubinelli <address@hidden>- To: Giovanni Piredda <address@hidden>
- Cc: texmacs-users <address@hidden>
- Subject: Re: Closing a widget automatically
- Date: Tue, 19 Jan 2021 08:29:45 +0100
You can try to use balloon widgets, see here how Joris implemented the link preview with that
Max
On 18. Jan 2021, at 22:18, Giovanni Piredda <address@hidden> wrote:Responding to a forum post (http://forum.texmacs.cn/t/how-can-i-see-list-of-labels/335), together with Jeroen we wrote a widget (very nice in my opinion ;-) ) that displays the list of labels (excluding bibliography labels).
I think it would be good if this widget would close automatically once that it loses focus. Does anyone know how to do it? Right now one could have many of these open at the same time, whose lists are not updated as the user edits labels. A modal widget could be also ok (TeXmacs documents can be modified from other windows too, so the "modal" solution is a bit flawed IMO). I would also appreciate suggestions on how to improve its appearance.
For reference, here is the code of the widget; some of the functions are copied/adapted from TeXmacs code (e.g. biblio-context? is taken from progs/link/ref-edit.scm, the search function is an adaptation of the standard search-labels in progs/links/ref-edit.scm and the menu and the widget itself are elaborations over examples in the Scheme developer guide). Place the code in your TeXmacs initialization file to use it. The widget can be displayed using the context menu (entry "Show labels") when the focus is inside either an inactive label, or reference, or eqref (you can add the cases that interest you by extending the or clause in the tm-menu form). Clicking on an entry inserts it at the cursor position.
;;Label list widget;;
(define (biblio-context? t)
(or (tree-func? t 'bibliography 4)
(tree-func? t 'bibliography* 5)))
(tm-define (in-biblio-context? t) (tree-search-upwards t biblio-context?))
(tm-define (search-doc-labels t)
"A function that finds all labels that are not part of the bibliography."
(tree-search t
(lambda (s) (and (label-context? s) (not (in-biblio-context? s)))
)))
;; use search-doc-labels function instead of the standard search-labels, that
;; finds the labels defined in the bibliography as well
(tm-widget (enum-labels)
(enum (insert answer)
(map cadr (map tree->stree (search-doc-labels (buffer-tree)))) "Choose label ..."
"24em"))
(tm-menu (texmacs-popup-menu)
(:require (or
(and
(tree-is? (focus-tree) 'reference)
(tree-is? (tree-outer (focus-tree)) 'inactive))
(and
(tree-is? (focus-tree) 'eqref)
(tree-is? (tree-outer (focus-tree)) 'inactive))
(and
(tree-is? (focus-tree) 'label)
(tree-is? (tree-outer (focus-tree)) 'inactive))))
(former)
---
("Show labels" (show enum-labels)))
- Closing a widget automatically, Giovanni Piredda, 01/18/2021
- Re: Closing a widget automatically, Giovanni Piredda, 01/18/2021
- Re: Closing a widget automatically, Massimiliano Gubinelli, 01/19/2021
- Re: Closing a widget automatically, Giovanni Piredda, 01/23/2021
- Re: Closing a widget automatically, Giovanni Piredda, 01/23/2021
- Re: Closing a widget automatically, Giovanni Piredda, 01/23/2021
Archive powered by MHonArc 2.6.19.