Codebase list ruby-fxruby / 9fb3e9b
Fix examples/input.rb It only works on POSIX systems unfortunately. Lars Kanis 4 years ago
1 changed file(s) with 9 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
2020
2121 # Output will be displayed in a multiline text area
2222 @cmdOutput = FXText.new(textFrame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
23 @cmdInput.text = "ping rubyinstaller.org"
2324
2425 # Initialize the pipe
2526 @pipe = nil
2930 def create
3031 super
3132 show(PLACEMENT_SCREEN)
33 @cmdInput.setFocus
3234 end
3335
3436 # Remove previous input (if any)
5355 getApp().addInput(@pipe, INPUT_READ|INPUT_EXCEPT) do |sender, sel, ptr|
5456 case FXSELTYPE(sel)
5557 when SEL_IO_READ
56 text = @pipe.read_nonblock(256)
57 if text && text.length > 0
58 begin
59 text = @pipe.read_nonblock(256)
60 rescue IO::WaitReadable
61 rescue EOFError
62 @cmdOutput.appendText("[EOF]")
63 closePipe
64 else
5865 @cmdOutput.appendText(text)
59 else
60 closePipe
6166 end
6267 when SEL_IO_EXCEPT
6368 # puts 'onPipeExcept'