diff options
Diffstat (limited to 'ext/tk/sample')
-rw-r--r-- | ext/tk/sample/irbtkw.rbw | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/tk/sample/irbtkw.rbw b/ext/tk/sample/irbtkw.rbw index 3fb6dde626..04de3a2022 100644 --- a/ext/tk/sample/irbtkw.rbw +++ b/ext/tk/sample/irbtkw.rbw @@ -48,10 +48,20 @@ console.yscrollbar(TkScrollbar.new(top, :width=>10).pack(:before=>console, :side=>:right, :expand=>false, :fill=>:y)) + +# save original I/O +out = $stdout +err = $stderr + irb_thread = nil ev_loop = Thread.new{ - Tk.mainloop - irb_thread.kill if irb_thread + begin + Tk.mainloop + ensure + $stdout = out + $stderr = err + irb_thread.kill if irb_thread + end } # window position control @@ -142,5 +152,5 @@ console.bind('Control-c'){ irb_thread.join # exit -ev_thread.kill +ev_loop.kill Tk.exit |