Design question: GtkTextView/Buffer



I am experimenting with various ways to edit XML files.  I have tried
various diagram oriented approaches (trees and various graphs) and am
now trying a text oriented approach.  In order to do this, I need to
be able to convert the XML into a text representation then back into
XML.  So far I have tried two approaches: using tags and using
pixbufs.

With tags, the idea is that each element in the XML is translated into
a string representation, added to the buffer, marked with a tag that
makes it read-only.  The problem is how to map between the tagged
regions and the internal representation of the element.

With pixbufs, the idea is similar.  The string representation is
rendered into a pixmap, which is copied into a pixbuf, which is added
to the text buffer.  Here the maping to the internal representation is
easy since the pixbuf is a gobject and can have properties but the
dynamic creation of the pixbufs is a little involved.

A third possiblity is to use both tags and pixbufs.  I would insert an
icon to which I could attach various properties and a textual
representation all inside a tag that prevents modification.

Since this is an experiement, I have tried both ways and have had
problems with both ways but before I try to fix all the problems or
try the third possiblity I wanted to make sure that there was not some
other approach that I was overlooking.  So with all the above
background this is my question:

Given a textual representation of a structure how can I map pieces of
the text back to the internal representation?

Here is an example:  Given this XML:

     <frame id=1234>
     A fair bit of cdata text.
     </frame>

I want a textual representation that looks like:

     FRAME:

       A fair bit of cdata text.

The "FRAME:" should not be modifiable and I want to hide the value of
the id attribute.  It is the hiding of the attributes that is why I
need to map from the piece of text to the internal representation.
Further, the whole point of the text buffer approach is that the cdata
text should be easy to edit.

I hope that I have given enough background for you to understand the
question that I am asking and I hope that you will take the time to
post some ideas.

Thanks in advance,

Dudley Irish



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