[texworks] Regex for DTX mode

Jérome Laurens jerome.laurens at u-bourgogne.fr
Fri Sep 26 21:45:44 CEST 2008


On 26 sept. 08, at 16:35, Jonathan Kew wrote:

> On 26 Sep 2008, at 3:12 PM, Joseph Wright wrote:
>
>> Will Robertson wrote:
>>> On 26/09/2008, at 10:17 PM, Joseph Wright wrote:
>>>
>>>> I'm trying to get the regex system to give me something similar  
>>>> to "DTX
>>>> Mode" in WinEdt.  I note that I can't (1) make things bold or  
>>>> italic, or
>>>> (2) alter the background colour, both of which would be nice.
>>>
>>> I'm not so fussed about #1 but #2 would be excellent :)
>>
>> Yes, background is more of an issue for me too.  I'm thinking that  
>> this
>> allows combinations of properties, which I like the idea of.
>
> So something like "green,bold,bg:yellow"?
>
> I don't want to go too far with this... different fonts, etc... but  
> maybe something more than just text color would be possible.
>
> Note that the current implementation, at least, applies the first  
> match it finds and then skips to the end of the matched text; do you  
> feel there's a need to layer multiple styles on top of each other,  
> rather than this "exclusive" model?


Welcome to the GUI world.
On one hand, it is helpful if the syntax parser is smart enough to  
anticipate errors or malformed code.
This syntax coloring model is a bit simple for that.
On the other end, a really smart syntax parser is expensive and can be  
a pain on average machines.
It is not comfortable if you have to wait half a second after each  
character typed just because of syntax coloring...
You will have to make some tests to see where you can go.
For example, using colors to indicate the grouping level is extremely  
expensive because inserting a '{' can change everything up to the end.
For that purpose, the xcode trick to indicate levels in the margin is  
very handy and efficient.

FYI, in iTeXMac2, I use an utf8 rtf file to store the style.
Actually, you have a mapping between regex keys and attributes.
In my style file, the keys -have- the attributes.
That way, you just use rtf syntax behind the scene to encode the font  
name, background color, boldness and so on.
People will only need to use a standard rtf text editor to alter the  
different colors.
And they see the result as they make the change.

JL


More information about the texworks mailing list