--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jan 15, 2005 at 11:21:13PM +0900, oxman wrote:
> The code :
> 
> #!/usr/bin/ruby1.8
> require 'gtk2'
> Gtk.init
> window = Gtk::Window.new
> window.signal_connect("destroy") {
>         puts "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,first_char,text,length|
>         if (text == '#')
>                 first_char.offset -= 1
>                 last_char = buffer.get_iter_at_offset(first_char.offset)
>                 last_char.forward_to_line_end
>                 buffer.apply_tag(buffer.tag_table.lookup("blue"), 
> first_char, last_char)
>                 update_window
>         end
> end
> 
> def update_window
>                 while Gtk.events_pending? do
>                         Gtk.main_iteration
>                 end
> end
> Gtk.main

I guess in this case update_window isn't going to have an effect because
no Gtk events are actually pending.

I can only see this problem when I type # and then wait. If I continue to
type or quickly switch lines using the arrow keys then it changes the color
right away. So the problem is that it's not detecting the need for an 
update very quickly. I think this has to do with the priority of redraws.

I did find information about redraw priority here:
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ATextView#PRIORITY_VALIDATE

I have not found any way to adjust the priority of redraws in the Ruby-
GNOME2 docs or in the regular GNOME API docs. But I thought I'd mention it
in case it help you find more info.

You might look at GtkSourceView as well... if not for using it, to see 
how it handles this problem.

 -Michael

--Qxx1br4bt0+wmkIi
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFB6US44ClW9KMwqnMRAsK0AJ0Wh85zdwkhhu/sd3pi7Xw8vmMpZgCcDs1q
HwhAGIp9BACYp12KX/ZJyBwライ
ュュュュュナホト ミヌミ モノヌホチヤユメナュュュュュ

ュュムアエーォノュュ