Re: Gtk2::TextView Troubles

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->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);

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