punting "invisible text" feature from GtkTextView



Hi,

Right now the new text widget inherits a text attribute "invisible"
from Tk which causes text to be virtually removed from the
buffer. That is, to the user invisible text should appear to be
nonexistent. The intended use of this feature is e.g. collapsing
function bodies in a code editor.

The "invisible" attribute is totally non-working right now. Brief
summary of its impact on the API:

 - all iteration functions need a _visible equivalent, for example:
  
gboolean gtk_text_iter_forward_chars        (GtkTextIter *iter,
                                             gint         count);
gboolean gtk_text_iter_forward_visible_chars (GtkTextIter *iter,
                                              gint         count);

   Important note: while forward_chars() is pretty efficient (btree 
   search), forward_visible_chars() would have to be a linear scan.
   Same for forward_lines() vs. forward_visible_lines().

 - Various API takes a visible_only flag, for example:

gboolean gtk_text_iter_forward_search  (const GtkTextIter *iter,
                                        const gchar       *str,
                                        gboolean           visible_only,
                                        gboolean           slice,
                                        GtkTextIter       *match_start,
                                        GtkTextIter       *match_end,
                                        const GtkTextIter *limit);


Impact on implementation is more serious, implementing the feature is
an enormous pain in the ass. It basically means you have to think
about tags in a bunch of cases where you otherwise don't, and it
creates a "virtual buffer" that isn't indexed by the btree while the
real buffer is. It creates a bunch of code paths that only get tested
when people actually use the invisible text feature.

Without this feature, to implement something like collapsing function
bodies you would have to delete the function body, store it someplace,
and put it back later. If the user deleted the collapsed function, you
would have to somehow detect that and avoid restoring its body.  So
it's a useful feature probably.

Anyhow, I don't think I have time to make the feature work for 2.0.  I
would suggest creating _visible_ API variants where necessary, so
people can use them in their code, and just remove the invisible
attribute from GtkTextTag so you can't actually make anything
invisible.

Havoc





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