--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 :
>=20
> #!/usr/bin/ruby1.8
> require 'gtk2'
> Gtk.init
> window =3D Gtk::Window.new
> window.signal_connect("destroy") {
>         puts "destroy"
>         Gtk.main_quit
> }
> textviewer =3D Gtk::TextView.new
> window.add(textviewer)
> window.set_default_size(600,400)
> window.show_all
> buffer =3D textviewer.buffer
> buffer.create_tag("blue", {"foreground" =3D> "blue"})
> buffer.signal_connect_after('insert-text') do |a,first_char,text,length|
>         if (text =3D=3D '#')
>                 first_char.offset -=3D 1
>                 last_char =3D buffer.get_iter_at_offset(first_char.offset)
>                 last_char.forward_to_line_end
>                 buffer.apply_tag(buffer.tag_table.lookup("blue"),=20
> first_char, last_char)
>                 update_window
>         end
> end
>=20
> 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=20
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_VALID=
ATE

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=20
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=
=UeW2
-----END PGP SIGNATURE-----

--Qxx1br4bt0+wmkIi--