Subject: mailing-list for TeXmacs Users
List archive
From : Miguel de Benito Delgado <address@hidden>- To: "address@hidden" <address@hidden>
- Subject: Re: [TeXmacs] general purpose tags + their manipulation
- Date: Sun, 23 Jun 2013 11:37:59 +0200
Hi,
On Thu, Jun 13, 2013 at 1:42 PM, Peeter Tinits <address@hidden> wrote:
2) Then I am looking for a way to edit the formatting of a particular tag within the interface via mouse
button or keyboard shortcut, such as it is used with switch and fold items at the moment.
- The easiest case could be to make 'Important' parts of the text 'Hidden' or 'Unhidden' on command.
You could start by looking how the folding / unfolding is done. Hit Shift+F1 and look for "fold" among the style files. The first result should be "packages/standard/std-fold.ts". There you'll see how the macros "hidden" and "action" can be used to hide content and trigger actions on clicks. The action will be some scheme command. You can do almost anything there, for instance iterate through all your custom tags in the document and toggle their visibility. Remember that the functions you call must be defined (:secure #t).
To select all subtrees of the document that are <mytag>s, you can use
(select (buffer-tree) '(:* mytag))
Then you can use the standard tree manipulation routines on the list you get.
Alternatively, you could add a button to the focus bar instead of using the <action> tag. Or you could write an overloaded contextual menu for the right mouse click. Something along the lines of:
(menu-bind texmacs-popup-menu
(:require (tree-in? (tree-up (cursor-tree)) '(mytag)))
("Click me!" (noop)))
See tm-modes.scm for the definitions of the in-someenvironment? predicates.
Something I don't know how to do cleanly is to retrieve the current word under the cursor. I achieved this for "developer mode" by emulating a click to change the cursor position, then using cursor-tree and tree-cursor-path (see the definition of cursor-word). A better way would be to write some c++ code to return the cursor position from the mouse position. Maybe it's already hidden somewhere in the code, I don't know.
Yet another possibility is to add a conditional tag <if> to your macro, testing for the value of some environment variable of running a test in scheme, then deciding inside this macro whether to display the argument or not.
Sloppily:
<assign|mytag|<macro|x|<if|<equal|myvisibility|1>|x|<hidden|x>>>>
But this can get tricky because of limitations of the <if> tag.
Best,
--
Miguel de Benito.
Miguel de Benito.
- [TeXmacs] general purpose tags + their manipulation, Peeter Tinits, 06/13/2013
- Re: [TeXmacs] general purpose tags + their manipulation, Sam Liddicott, 06/13/2013
- Re: [TeXmacs] general purpose tags + their manipulation, Miguel de Benito Delgado, 06/23/2013
Archive powered by MHonArc 2.6.19.