Re: last visible word in a Gtk2::TextView

On Tue, 2005-08-30 at 20:35 -0400, James Muir wrote:

How do I determine the last visible word in a Gtk2::TextView ? I think I 
can get to the last visible line as follows:

my $rect = $textview->get_visible_rect();

my $iter = $textview->get_line_at_y($rect->y + $rect->height);

but I'm not sure how to get to the last word on  the line.

I didn't try it, but something like this should work: Move $iter to the
end of the line:

  do {
  } until ($iter->ends_line);

Get a copy and move it back one word:

  $reti = $iter->copy;

Get the text in between:

  warn $reti->get_visible_text ($iter);

If this doesn't work, try some other stuff from:

Also, what is the 'line_top' returned by get_line_at_y  ?


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