Hi,

On Sat, 15 Jan 2005 23:21:13 +0900, oxman <no / in-your-dream.net> wrote:
> The code :

Do you get any improvement or idea with this code:

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|
  Gtk.timeout_add(10){
    iter = buffer.start_iter
    while a = iter.forward_search('#', Gtk::TextIter::SEARCH_TEXT_ONLY) do
      iter, = a
      iter2 = buffer.get_iter_at_offset(iter.offset)
      iter2.forward_to_line_end
      buffer.apply_tag(buffer.tag_table.lookup("blue"), iter, iter2)
      iter.forward_line
      p a
    end
    false
  }
end
Gtk.main

It seems that after the first # is colored I get some improvement, but
I haven't come up with a best approach yet, though I'm interested in
this as well. :-)

Cheers,
Joao