# Cursor position in a Gtk::TextBuffer

**URL:** <https://www.ruby-forum.com/t/cursor-position-in-a-gtk-textbuffer/76044>\
**Category:** Ruby\
**Created:** [November 15, 2006, 2:21pm UTC](https://www.ruby-forum.com/t/cursor-position-in-a-gtk-textbuffer/76044 "2006-11-15T14:21:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WoodHacker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ac8455/32.png) [@WoodHacker](https://www.ruby-forum.com/u/WoodHacker)\
**Post date:** [November 15, 2006, 2:21pm UTC](https://www.ruby-forum.com/t/cursor-position-in-a-gtk-textbuffer/76044/1 "2006-11-15T14:21:54Z")

</div>

I have not had great luck asking Gtk questions on this site, but I  
don’t know where else to turn…

I am writing my own editor and want to have syntax coloring. I scan  
the file and sets tags to get what I want and it works fine for an  
existing file. However, I need also to be able to add text to the  
file and to create new files and have the coloring work as I type.  
My question is, how do I get the number of the line I’m on? This will  
allow me to get the iterator of that line and allow me to color the  
line as I type. I can get the line from the window coordinates, but  
how do I get the window coordinates? I can get them from the cursor  
position, but how do I get the cursor position? How do I tell where I  
am in the text buffer? The signal “changed” does not seem to return  
an event structure that would allow me to get event.x and event.y.

Obviously, I’m not the first person who’s had this problem, and I’m  
sure I’m missing something, but as of right now I’m lost.

Bill
