texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Document tree manipulation


From: Henri Lesourd
Subject: Re: [Texmacs-dev] Document tree manipulation
Date: Mon, 28 May 2007 20:08:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821

address@hidden wrote:

Hi everybody

I was thinking of making a texmacs plug-in and for that I would like to start off by making a scheme file with provision for changing the text colors according to a given parameter. I have made a parser and suppose I would like the text to appear green if a string was parsed correctly depending on my parser's output and red otherise.

OK.


I could parse the string when the mouse pointer has been taken off the string.

This you cannot do it, it is currently impossible to
detect the movements of the mouse from inside Scheme.
But you can redefine a keyboard shortcut for this
purpose. Have a look at : http://www.ags.uni-sb.de/~henri/texmacs/aTeXmacsTutorial.pdf

for information about exactly how to make a TeXmacs
plugin (location of the different files you must create),
how to write stylesheets (this includes defining macros),
and how to redefine keyboard shortcuts, menus, etc. by
means of Scheme.


The colors should be changed by manipulating the document tree and I would like to know the files where I would find the appropriate functions for doing the same.

You should write a little stylesheet for changing colors, for example
you could define a markup "colored" with two parameters :
[[
<assign|colored|<macro|c|body|<with|color|<arg|c>|<arg|body>>>>
]]

, and then change a chunk (e.g. : "Hello!") of the document by
means of embedding it inside a "colored" markup, e.g. :
[[
<colored|green|Hello !>
]]

The embedding itself could be performed by means of a (tree-set! ...)
function call from inside Scheme.


Any further advice is welcome as well.  Please help!

For manipulating the document tree, have a look at the
attached archive, which contains the a demo plugin with
a function "xmlize-tree" that recursively traverses the
current buffer (from the current location of the cursor).

The basic tree API of TeXmacs is :
[[
(path->tree PATH) -> TREE
   /* the path (i) is the path of the buffer #i */
(tree-label TREE) -> INT
(tree-ref TREE INT) -> TREE
(tree-set! TREE INT TREE) -> VOID
(tree-insert TREE INT TREE) -> VOID
   /* performs an insert *before* the  given position */
(tree-remove ...)
]]

If you read a little bit Scheme, you can probably extract
all the info you need from the tutorial & from the code
of the attached example plugin.

Any other question welcomed anyway.


Best, Henri

Attachment: spreadsheet0.tar
Description: Unix tar archive


reply via email to

[Prev in Thread] Current Thread [Next in Thread]