Re: Still some question about row & column number. (Re: How to get the row & column number of cursor in GtkTextView?)



Hi,

On Mon, 2002-08-26 at 04:47, Padraig O'Briain wrote:
> >   I tested your code piece. There's still two questions:
> >   1. The resulted rect is a GdkRectangle, it's members x,y is pixel, so how 
> > can I convert it to line number and column number?
> 
> I am not sure what you mean by column number as each character may have a 
> different width. If you are asling how many characters are on the line before 
> the current position, you could call gtk_text_iter_get_offset(), 
> gtk_text_view_backward_display_line_start() and then call 
> gtk_text_iter_get_offset() again.
> 
> The determine the line number you could call 
> gtk_text_view_backward_display_line() until gtk_text_iter_is_start() is TRUE 
> counting the number of times you call the function. I am not sure whether there 
> is a better way.

Maybe gtk_text_iter_get_line() and gtk_text_iter_get_line_offset() are
what you're looking for.  The test program for gtksourceview uses those
(See http://cvs.gnome.org/lxr/source/gtksourceview/src/test-widget.c).

HTH,
Gustavo





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