# Delete child\_anchor from textbuffer

**URL:** <https://www.ruby-forum.com/t/delete-child-anchor-from-textbuffer/69820>\
**Category:** Ruby-Gnome 2\
**Created:** [September 24, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/delete-child-anchor-from-textbuffer/69820 "2006-09-24T14:19:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackedder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blackedder](https://www.ruby-forum.com/u/blackedder)\
**Post date:** [September 24, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/delete-child-anchor-from-textbuffer/69820/1 "2006-09-24T14:19:05Z")

</div>

Hi,

Does anyone know how to delete a child\_anchor from a text buffer. I read  
something about unreffing it, but couldn’t figure out how.

On a related note there seems to be a bug in get\_iter\_at\_child\_anchor.  
In  
contrast to the documentation I need to provide two arguments to the  
method, although as far as I can tell it only uses the first argument  
(the  
anchor).

Edwin

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![blackedder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blackedder](https://www.ruby-forum.com/u/blackedder)\
**Post date:** [September 24, 2006, 3:29pm UTC](https://www.ruby-forum.com/t/delete-child-anchor-from-textbuffer/69820/2 "2006-09-24T15:29:50Z")

</div>

Hi,

In [op.tgdtpdx1ngac0g@localhost](mailto:op.tgdtpdx1ngac0g@localhost)  
“[ruby-gnome2-devel-en] Delete child\_anchor from textbuffer.” on Sun,  
24 Sep 2006 13:16:15 +0100,  
Edwin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does anyone know how to delete a child\_anchor from a text buffer. I read  
> something about unreffing it, but couldn’t figure out how.

Use Gtk::TextBuffer#delete.

start\_iter = buffer.get\_iter\_at\_child\_anchor(anchor)  
end\_iter = buffer.get\_iter\_at\_child\_anchor(anchor)  
end\_iter.forward\_char  
buffer.delete(start\_iter, end\_iter)

Gtk::ChildAnchor is represented as a char. See:  
[http://developer.gnome.org/doc/API/2.4/gtk/GtkTextBuffer.html#gtk-text-buffer-insert-child-anchor](http://developer.gnome.org/doc/API/2.4/gtk/GtkTextBuffer.html#gtk-text-buffer-insert-child-anchor)

> On a related note there seems to be a bug in get\_iter\_at\_child\_anchor. In  
> contrast to the documentation I need to provide two arguments to the  
> method, although as far as I can tell it only uses the first argument (the  
> anchor).

You’re right. I fixed the bug.

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![blackedder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blackedder](https://www.ruby-forum.com/u/blackedder)\
**Post date:** [September 24, 2006, 5:01pm UTC](https://www.ruby-forum.com/t/delete-child-anchor-from-textbuffer/69820/3 "2006-09-24T17:01:56Z")

</div>

On Sun, 24 Sep 2006 14:29:35 +0100, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> buffer.delete(start\_iter, end\_iter)  
> Thanks, this works:

But earlier I tried something very similar:

start\_iter = buffer.get\_iter\_at\_child\_anchor(anchor)  
end\_iter = buffer.get\_iter\_at\_offset( start\_iter.offset + 1 )  
buffer.delete(start\_iter, end\_iter)

and that didn’t work. Any idea why?

> You’re right. I fixed the bug.  
> Great!

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![blackedder](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@blackedder](https://www.ruby-forum.com/u/blackedder)\
**Post date:** [September 25, 2006, 3:02am UTC](https://www.ruby-forum.com/t/delete-child-anchor-from-textbuffer/69820/4 "2006-09-25T03:02:56Z")

</div>

Hi,

2006/9/24, Edwin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> But earlier I tried something very similar:
> 
> start\_iter = buffer.get\_iter\_at\_child\_anchor(anchor)  
> end\_iter = buffer.get\_iter\_at\_offset( start\_iter.offset + 1 )  
> buffer.delete(start\_iter, end\_iter)
> 
> and that didn’t work. Any idea why?

Really? This works well on my environment.

## Thanks,

kou

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys – and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
