Thursday, June 24, 2004

Formatting

The task is to apply colors, fonts, and layout attributes to blocks of text accoring to some patterns. It's common practice to write text patterns in form of regular expressions. Thus we could define style for document as a set of pairs of a regular expression and formatting description.

But C# code is structured text. There is a working solution of structured text formatting, that is XML with style sheets. While C# code is not XML, editor could treat the code as XML internally and apply style sheets, and then render the result on screen. Equivalent XML could look like this

<comment>An example of class</comment>
<class>
<keyword>public</keyword>
<keyword>class</keyword> Class1
{
<method>
<keyword>public</keyword>
<keyword>static</keyword>
<MethodName>Main</MethodName>()
{
<MethodBody>
Console.WriteLine("Hello World");
</MethodBody>
} </method>
} </class>

CSS can use regular expressions as well, thus providing possibility of using regular expressions only to describe formatting rules.

Options dialog present in IDE could provide a limited set of funstionality to simplify the process of formatting. Advanced users can type their own style sheets or create them with third party tools.


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?