GtkText - how to delete text completely



The following code deletes text from the visible widget, but does not
remove it from the "text" member of the GtkText data structure:

   len = gtk_text_get_length(GTK_TEXT(textwidget));
   gtk_text_set_point(GTK_TEXT(textwidget), 0);
   gtk_text_forward_delete(GTK_TEXT(textwidget), len);

Is this the proper way of deleteing all text from the text widget or is
there some other routine that does this?  Do I need to manually free the
storage in GtkText->text, along with updating the other relevent elements?

One thing I noticed is that the GtkText->text structure member still points to
the old data, and if you type in the text widget the characters you type
overwrite the buffer starting at the beginning of the buffer.  It looks
like the widget is cleared but either the buffer pointed to by
GtkText->text is not freed or (at least) its not null terminated at the
first byte.

On a similar question:  I can get to the text by using GtkText->text, but
is that the way I'm supposed to get to it?  Or is there a routine for
accessing it opaquely?  I looked at all the routines in gtktext.c, but none
seemed to fit the bill (or maybe my eyes were just glazing over - hard to
tell, I've missed a lot of obvious stuff lately).
-- 
Michael J. Hammel           | It would be terrible if the Red Cross
The Graphics Muse           | Bloodmobile got into an accident.  No,
mjhammel@graphics-muse.org  | wait. That would be good because if anyone
http://www.graphics-muse.org  needed it, the blood would be right there.



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