Fix examples/input.rb
It only works on POSIX systems unfortunately.
Lars Kanis
4 years ago
20 | 20 | |
21 | 21 | # Output will be displayed in a multiline text area |
22 | 22 | @cmdOutput = FXText.new(textFrame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) |
23 | @cmdInput.text = "ping rubyinstaller.org" | |
23 | 24 | |
24 | 25 | # Initialize the pipe |
25 | 26 | @pipe = nil |
29 | 30 | def create |
30 | 31 | super |
31 | 32 | show(PLACEMENT_SCREEN) |
33 | @cmdInput.setFocus | |
32 | 34 | end |
33 | 35 | |
34 | 36 | # Remove previous input (if any) |
53 | 55 | getApp().addInput(@pipe, INPUT_READ|INPUT_EXCEPT) do |sender, sel, ptr| |
54 | 56 | case FXSELTYPE(sel) |
55 | 57 | 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 | |
58 | 65 | @cmdOutput.appendText(text) |
59 | else | |
60 | closePipe | |
61 | 66 | end |
62 | 67 | when SEL_IO_EXCEPT |
63 | 68 | # puts 'onPipeExcept' |