Re: GtkTextView : how many lines currently visible?



Eduardo M KALINOWSKI wrote:

Erik de Castro Lopo wrote:

Hi all,

I'm using a GtkTextView widget and I'd like to know things like:

 - How many lines are currently visible
 - What line in the GtkTextBuffer is the top visible line in
   the window.

gtk_text_view_get_line_at_y(), gtk_text_view_get_iter_at_location() or
gtk_text_view_get_iter_at_position(), with appropriate coordinates
(HINT: gtk_text_view_window_to_buffer_coordinates()) followed by
gtk_text_iter_get_line() might do the trick.


Cool, thanks Eduardo, I now have this:

    GtkTextIter iter ;
    int x, y, current_line ;

    gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (widget),
                   GTK_TEXT_WINDOW_TEXT, 0, 0, &x, &y) ;
    gtk_text_view_get_iter_at_position (GTK_TEXT_VIEW (widget),
                   &iter, NULL, x, y) ;
    
    current_line = gtk_text_iter_get_line (&iter)) ;

which gets me the current line, but I still can't figure out how
to get the number of currently visible lines. I supposed I need
the size of the visible part of the GtkTextView widget, but getting
that is no obvious.

Cheers,
Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
http://en.wikipedia.org/wiki/Why_I_Am_Not_a_Christian
http://en.wikipedia.org/wiki/Why_I_Am_Not_a_Muslim
http://en.wikipedia.org/wiki/Strong_atheism



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