From: Gilles Filippini Date: 2002-06-17T20:16:24+09:00 Subject: Re: Embedding irb Joel VanderWerf wrote: > > Gilles Filippini wrote: > > > > Bob X wrote: > > > > > > Into an FXRuby app would be even better. : ) > > > > That's what I'd like to do actually. > > I think IRB should run in a separate thread. But then I don't know how > > to redirect IRB's standard input, output and error. > > Any help appreciated. > > > > _gilles. > > If you can figure out how to associate an input and output stream with a > text editing window, then, IIUC, you can set readline to work on those > streams, using rl_instream and rl_outstream: > > http://cnswww.cns.cwru.edu/~chet/readline/readline.html#SEC28 Thanks for the pointer. Anyway, I don't think readline streams redirection is enough because IRB uses statements such as print and printf for its output. So I have to redirect standard streams. I've tried this: @input = IO.pipe @output = IO.pipe @err = IO.pipe @irb = Thread.new { STDIN.reopen(@input[0]) STDOUT.reopen(@output[1]) STDERR.reopen(@input[1]) IRB.start } but it freezes my app :/ > (Assuming you've set irb up to use readline.) I have no idea how to > accomplish the first part, though. Maybe look at the source for a > terminal emulator? I'll use FXScintilla. As soon as I'll have figured out how to manage IRB standard streams it shouldn't be difficult to branch them on the text editor. SciTE already does this with Scintilla. _gilles.