Gtk2::TextView Troubles
- From: James Muir <hemlock vtlink net>
- To: gtk-perl-list gnome org
- Subject: Gtk2::TextView Troubles
- Date: Mon, 05 Sep 2005 10:32:11 -0400
First, Thanks Torsten for the suggestion to try:
do {
$iter->forward_visible_word_end;
} until ($iter->ends_line);
to get me to the last visible word. Unfortunately, this puts me into an
infinite loop on the last word in the Gtk2::TextBuffer. The
$iter->ends_line flag is never set to true! =-O
While further exploring Gtk2::TextView I think I may have discovered a
bug with $textview->forward_display_line($iter), or it may be that I
just don't understand how to use these methods. Here is the test case:
# $view->foward_display_line($iter) working???
#
# Supposedly moves an iterator iter forward to the position one line
# below the current location of iter in the view. This is not necessarily
# the current line offset into the next line in the buffer, it could be
# in the same text buffer line due to word wrapping.
#
# In this example word wrapping is enabled.
use strict;
use Gtk2 '-init';
my $window = Gtk2::Window->new();
$window->signal_connect('destroy'=>\&_closeapp);
$window->set_default_size(150,50); # Make text wrap with small window.
my $text = 'Hello World! What a wonderful morning it is!';
my $view = Gtk2::TextView->new();
$view->set_wrap_mode('word');
$view->set_buffer(Gtk2::TextBuffer->new);
my $buffer = $view->get_buffer();
$buffer->set_text($text);
my $rect = $view->get_visible_rect();
my $iter = ($view->get_line_at_y($rect->y + $rect->height))[0];
_show_word_at($iter); # Shows "Hello" - OK.
my $flag1 = $view->forward_display_line($iter);
warn 'flag1: ', $flag1;
_show_word_at($iter); # Shows "World" Huh? I was expecting 'wonderful'
$window->add($view);
$window->show_all();
Gtk2->main();
exit 0;
sub _closeapp
{
Gtk2->main_quit();
return 0;
}
sub _show_word_at
{
my $iter = shift(@_);
my $reti = $iter->copy();
$reti->forward_visible_word_end();
warn 'word found: ', $reti->get_visible_text($iter);
}
So is there a bug in the perl interface, or in the c code, or am I
misunderstanding something?
-James
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]