Gtk2::TextView Troubles

First, Thanks Torsten for the suggestion to try:

do {
 } 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->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();



my $buffer = $view->get_buffer();


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'




exit 0;

sub _closeapp

   return 0;

sub _show_word_at
   my $iter = shift(@_);

   my $reti = $iter->copy();


   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?

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