This :
        2.times{
          buffer.apply_tag(buffer.tag_table.lookup("blue"), iter, 
limit_iter)
        }

Perfect.
Thanks :)

Joao Pedrosa wrote:
> Hi,
> 
> On Sat, 15 Jan 2005 14:05:16 -0300, Joao Pedrosa <joaopedrosa / gmail.com> wrote:
> 
>>Hi,
>>
>>On Sat, 15 Jan 2005 23:21:13 +0900, oxman <no / in-your-dream.net> wrote:
>>
>>>The code :
> 
> 
> I think I have found a hack. Check this out:
> 
> require 'gtk2'
> Gtk.init
> window = Gtk::Window.new
> window.signal_connect("destroy") { Gtk.main_quit }
> textviewer = Gtk::TextView.new
> window.add(textviewer)
> window.set_default_size(600,400)
> window.show_all
> buffer = textviewer.buffer
> buffer.create_tag("blue", {"foreground" => "blue"})
> buffer.signal_connect('insert-text') do |a,iter,text,length|
>   offs = iter.offset
>   Gtk.timeout_add(10){
>     iter = buffer.get_iter_at_offset(offs)
>     iter.forward_to_line_end
>     limit_iter = buffer.get_iter_at_offset(iter.offset)
>     iter.line_offset = 0
>     if a = iter.forward_search('#', Gtk::TextIter::SEARCH_TEXT_ONLY,
> limit_iter) or text == '#'
>       iter, = a if a
>       2.times{
>         buffer.apply_tag(buffer.tag_table.lookup("blue"), iter, limit_iter)
>       }
>     end
>     false
>   }
> end
> Gtk.main
> 
> Cheers,
> Joao
> 
>