Re: last visible word in a Gtk2::TextView
- From: Torsten Schoenfeld <kaffeetisch gmx de>
- To: gtk-perl-list gnome org
- Subject: Re: last visible word in a Gtk2::TextView
- Date: Wed, 31 Aug 2005 18:14:00 +0200
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 {
$iter->forward_visible_word_end;
} until ($iter->ends_line);
Get a copy and move it back one word:
$reti = $iter->copy;
$reti->backward_visible_word_start;
Get the text in between:
warn $reti->get_visible_text ($iter);
If this doesn't work, try some other stuff from:
http://developer.gnome.org/doc/API/2.0/gtk/gtk-GtkTextIter.html
Also, what is the 'line_top' returned by get_line_at_y ?
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextView.html#gtk-text-view-get-line-at-y
--
Bye,
-Torsten
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]