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

Re: GtkTextMark



Joshua N Pritikin <vishnu@pobox.com> writes:
> i have some questions about TextBuffer marks and tags.  i tried to read the
> Gtk source code today, but TextBuffers are horrendously complicated.

It's scary in there.

> i understand from the documentation that GtkTextMark is stable with
> respect to editing.  However, what happens if a mark is sitting in
> the middle of a block of text which is deleted?  Is the mark *moved*?
> For example, does it work like this?
> 
>   Here is some text *MARK* and here is more text.
> delete>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   Here is *MARK* more text.


The mark is simply left wherever the deleted text was. If I understand
your diagram above, then it's correct.

That is, deletion does not delete marks, it doesn't move them either,
just leaves them there where the text was previously.

> Do tags work the same way as marks or differently?  If i want some tags
> to correspond to marks then do i need to do some sort of synchronization
> after interactive editing?

You can think of a tag as a pair of marks, defining the two edges of
the text to be tagged.

However these two "marks" are treated specially in a couple ways:

 - if they meet (contain no text in between), then they are both
   deleted. i.e. we don't keep empty ranges around.
 - if two tagged ranges overlap, they are merged, so you have 
   only two "marks" delimiting the range, instead of 4.

So in other words, we always use the minimum number of "marks" to 
delimit the tagged ranges of the buffer.

To give a specific recommendation on implementing tags corresponding
to marks I'd have to understand better exactly what you are trying to
do and what the desired user-visible behavior is.

Havoc




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