Hi,

On Sun, 16 Jan 2005 03:21:10 +0900, oxman <no / in-your-dream.net> wrote:
> This :
>         2.times{
>           buffer.apply_tag(buffer.tag_table.lookup("blue"), iter,
> limit_iter)
>         }
> 
> Perfect.
> Thanks :)

No problem. :-)

I just created another one, a little better:

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_after('insert-text') do |a,iter,text,length|
  orig_iter = buffer.get_iter_at_offset(iter.offset - 1)
  iter.forward_to_line_end
  limit_iter = buffer.get_iter_at_offset(iter.offset)
  iter.line_offset = 0
  iter.offset = iter.offset - 1
  if a = iter.forward_search('#', Gtk::TextIter::SEARCH_TEXT_ONLY,
limit_iter) or text == '#'
    if a
      iter, = a 
    else
      iter = orig_iter
    end
    2.times{
      buffer.apply_tag(buffer.tag_table.lookup("blue"), iter, limit_iter)
    }
  end
end
Gtk.main

Cheers,
Joao