Re: Gtk2::TextView Troubles
- From: James Muir <hemlock vtlink net>
- To: gtk-perl-list gnome org
- Subject: Re: Gtk2::TextView Troubles
- Date: Tue, 06 Sep 2005 08:22:01 -0400
Well, I learned something with this example. Things work if you move
$window->show_all before doing the forward_display_line. Sheesh, should
have thought of that before posting. -James
James Muir wrote:
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]