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

Re: gtk_text_buffer_get_* should return length? (1.3.6)



On Tue, Aug 07, 2001 at 05:44:33PM -0400, Havoc Pennington wrote:
> Joshua N Pritikin <vishnu@pobox.com> writes:
> > The APIs in question are:
> > 
> >  gchar*      gtk_text_buffer_get_text        (GtkTextBuffer *buffer,
> >                                               const GtkTextIter *start,
> >                                               const GtkTextIter *end,
> >                                               gboolean include_hidden_chars);
> >  gchar*      gtk_text_buffer_get_slice       (GtkTextBuffer *buffer,
> >                                               const GtkTextIter *start,
> >                                               const GtkTextIter *end,
> >                                               gboolean include_hidden_chars);
> > 
> > Why don't these APIs return the length?  It seems dumb to do a strlen()
> > when _gtk_text_btree_get_text() actually had the data nicely wrapped
> > in a GString.
> 
> I think it would make the API a bit less convenient for simple cases. 
> Maybe add gtk_text_buffer_get_text_with_len? That seems a bit
> API-bloatish to me though, so I'm not sure about it.

Why not just return the GString?

(IMHO, the GtkText* API should not be optimized for the simple cases.
 This thing is a monster, and it should offer a monster API.  :-)

To raise the ante, here's a use case: i want to copy a small part
of a long document into a separate GtkTextBuffer, preserving some
or all of the tags.  i can't find an API to do that.  i suspected
that gtk_text_buffer_get_slice might be helpful but it just does padding.

> Of course, we already have the bizarre duplication of API between the
> iter and the buffer for getting text, so maybe if we fix that we have
> a couple functions saved and can spend them elsewhere. ;-)

Oh, i didn't notice that.  Yes, perhaps these functions belong only
in GtkTextIter.

> Maybe file a bug so we at least think about it a bit more.

Will do.

-- 
Get self-realization at <http://sahajayoga.org> ... <http://why-compete.org> ?
  Victory to the Divine Mother!!




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