Monday, June 25, 2007

Show don't tell

I have been working heavily in my SoC project. Right now if you want to edit Mono XML documentation you have to open your editor of choice and get going with all the XML stuff.
So if you want to edit for example WrapMode.xml from gtk-sharp you will see this:


This has many shortcomings:
  • Typos can and will break the validity of the document.
  • No help of the valid tags that can be used.
  • Etc.
At first I had some problems with the design. I had the idea of making a whole set of code that will model a Monodoc document and define methods to create, change and remove tags. The problem with this approach is the time to implement and the need of a new custom widget that will handle the view of this model. So Miguel proposed the use of the Text* set of classes in GTK#.
This set of classes implement a MVC pattern around a text. An excellent example of the power of TextView and TextBuffer is Tomboy, this app is like a manager of notes that are linked between them and with many options to format the text of the note.
So I decided to try this path mainly because of the beauty that is TextTag, which represents a region of text, that can have a huge number of properties affecting the text, like color, size, visibility, etc. So a TextBuffer can have any amount of TextTags that affect the text of the buffer, this properties will then be rendered by a TextView.

Now after several weeks of hacking I have a screenshot of the the initial work on the editor:


As you can see from the screenshot the formatting is very light, I have been mainly working in doing a transformation of a Monodoc document to a TextBuffer and back. In this example I have changed the color property of several tags that contains values from elements of the XML document.
This week I will complete the work in the transformations so even the most complex documents can be transformed and design a basic layout of the information.

No comments: