[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [Beginner] How to write at the end of a GtkTextBuffer ?
- From: Paul Pogonyshev <pogonyshev gmx net>
- To: Olivier Ramare math univ-lille1 fr, gtk-app-devel-list gnome org
- Cc:
- Subject: Re: [Beginner] How to write at the end of a GtkTextBuffer ?
- Date: Sat, 23 Apr 2005 23:13:16 +0300
Olivier Ramare wrote:
>
> ...
>
> What I want :
> -- the info written always at the end of the buffer
> -- this end should be in the viewable area (scroll if needed).
> I can't quite get an inkling as to this last one either :-(
[untested]
GtkTextIter end_iterator;
gtk_text_buffer_get_end_iter (text_buffer, &end_iterator);
gtk_text_buffer_insert (text_buffer, &end_iterator, some_text, -1);
gtk_text_view_scroll_to_iter (text_view, &end_iterator,
0.0, FALSE, 0.0, 0.0);
However, the scroll_to_iter() part does not work always. Better to
use gtk_text_view_scroll_to_mark(). If you want the cursor at the
end anyway, you can implement it like this:
GtkTextIter end_iterator;
gtk_text_buffer_get_end_iter (text_buffer, &end_iterator);
gtk_text_buffer_place_cursor (text_buffer, &end_iterator);
gtk_text_buffer_insert_at_cursor (text_buffer, some_text, -1);
gtk_text_view_scroll_to_mark (text_view,
gtk_text_buffer_get_insert (text_buffer),
0.0, FALSE, 0.0, 0.0);
I also suggest that you try to write more readable code. Using spaces
might be a good start at this.
As another side note, I'd like to praise the GTK+ text widgets. They
are not easy to start using, but they are very flexible. Just today
I did some neat things with them and I must say that everything works
just fine.
Paul
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]