From: Paul Duncan Date: 2004-08-24T22:33:24+09:00 Subject: Re: Threads + Ncurses --v2Uk6McLiE8OV1El Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tobias Peters (tpeters@invalid.uni-oldenburg.de) wrote: > Julius Plenz wrote: [snipped] > >I just want to run the thread continuously until one key is pressed... > >What other possibilities do I have? >=20 > Ncurses.getch blocks not only other ncurses-functions. It blocks the=20 > complete ruby interpreter, all threads. >=20 > This has to change, obviously, and it will change before the 1.0 release= =20 > of ncurses-ruby. In the meantime, you can work around the limitation in= =20 > the way Lennon suggested [ruby-talk:109697]. Raggle uses this approach, and it does have at least one caveat: terminal resize events (and possibly mouse events as well, although I believe those are still broken in Ncurses-Ruby) are not handled properly. =20 That said, here's the code from Raggle: timeout =3D $config['input_select_timeout'] # defaults to 0.2 $done =3D false until $done # handle keyboard input r =3D select [$stdin], nil, nil, timeout if r && r.size > 0 c =3D Ncurses::getch $config['keys'][c].call($wins[$a_win],c) \ if $config['keys'].has_key? c end =20 # snipped irrelevant stuff end [snipped] > regards, > Tobias --=20 Paul Duncan pabs in #ruby-lang (OPN IRC) http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562 --v2Uk6McLiE8OV1El Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBK0OgzdlT34LClWIRAoaWAKDGLoEpZBYTXUI59iUQ3WbS0ZoxAgCgqMFV HKh39isDuo2ZooBklXueKio= =/Cjv -----END PGP SIGNATURE----- --v2Uk6McLiE8OV1El--