To: tim at fungible.com Cc: lablgtk at kaba.or.jp Subject: Re: Need threads for terminal emulator? In-Reply-To: <41-Tue19Mar2002204957-0800-tim at fungible.com> References: <41-Tue19Mar2002204957-0800-tim at fungible.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020320140857K.garrigue at kurims.kyoto-u.ac.jp> Date: Wed, 20 Mar 2002 14:08:57 +0900 From: Jacques Garrigue Lines: 25 From: tim@fungible.com (Tim Freeman) > I'm wanting to write something like a terminal emulator in OCAML with > lablgtk. I had intended initially to keep the application > single-threaded since the bulk of the code is not concerned with > interacting with the subprocess, but I don't see a way to do a select > with lablgtk that will return when either there's input available from > the subprocess or input available from the window system. > > Should I give up on using selects and just write a multi-threaded > program, or did I miss some feature in lablgtk that would let me do > this with only one thread? Going ahead using threads is probably the simplest way. This is a bit tricky, but you can see an example in applications/irc (only in the last snapshot). Note that Gtk doesn't have to be in threaded mode for that, only ocaml threads are used. Otherwise, glib contains a GIOChannel type, which seems to be intended to do that. So another solution might be to interface to it. The trouble is that the channel you get is incompatible with ocaml's channels, so you may have to rewrite lots of stuff. I really wish that file io in ocaml were more OO. Jacques