# Get\_iter\_at\_cursor?

**URL:** <https://www.ruby-forum.com/t/get-iter-at-cursor/92582>\
**Category:** Ruby-Gnome 2\
**Created:** [April 21, 2007, 3:18am UTC](https://www.ruby-forum.com/t/get-iter-at-cursor/92582 "2007-04-21T03:18:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 21, 2007, 3:18am UTC](https://www.ruby-forum.com/t/get-iter-at-cursor/92582/1 "2007-04-21T03:18:23Z")

</div>

Hi there, again me 😉 another problem

I would need a method such as:  
get\_iter\_at\_cursor  
which gives back the iter at the current cursor.

I have looked but found no easy way to find out where the  
cursor is located (+the iter it has)

My problem right now:

start\_pos = buffer.get\_iter\_at\_line(3)  
end\_pos = buffer.get\_iter\_at\_line(20)  
buffer.delete( start\_pos, end\_pos )

This snippet will/should delete lines 3-20.  
However the first one for start\_pos should be something like  
this instead:

start\_pos = buffer.get\_iter\_at\_cursor

So that I could delete all rows up to a specified number  
beginning with the cursor.

Does anyone know of a workaround at least?

=

–  
Powered by Outblaze

* * *

This [SF.net](http://SF.net) email is sponsored by DB2 Express  
Download DB2 Express C - the FREE version of DB2 express and take  
control of your XML. No limits. Just data. Click to get it now.  
[http://sourceforge.net/powerbar/db2/](http://sourceforge.net/powerbar/db2/)

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [April 21, 2007, 3:54am UTC](https://www.ruby-forum.com/t/get-iter-at-cursor/92582/2 "2007-04-21T03:54:27Z")

</div>

On Sat, Apr 21, 2007 at 02:17:37AM +0100, Roebe XXX wrote:

> Hi there, again me 😉 another problem
> 
> I would need a method such as:  
> get\_iter\_at\_cursor  
> which gives back the iter at the current cursor.

The way you do this with TextBuffer is by grabbing the mark named  
“insert” and using that. See the attached script that prints the  
character under the cursor every second.

hth,

-pete
