Message from discussion sciTe editor IRB window getting double characters
From: Neil Hodgson <nyamatongwe+thun...@gmail.com>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: en-us, en
Subject: Re: sciTe editor IRB window getting double characters
References: <jdbke.15939$tM3.firstname.lastname@example.org> <email@example.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Date: Mon, 30 May 2005 01:21:54 GMT
X-Trace: news-server.bigpond.net.au 1117416114 188.8.131.52 (Mon, 30 May 2005 11:21:54 EST)
NNTP-Posting-Date: Mon, 30 May 2005 11:21:54 EST
Organization: BigPond Internet Services
> a) Clicking into the output pane (which gains focus then).
> Now you can type in some string, enter return two times and all
> output is shown then.
The way that SciTE's output pane works is that it has two file
handles open: one writing to the subprocess and one reading from it.
Characters typed are added to the buffer and then written to the write
Data from the read pipe is added to the display when it is received.
Programs often buffer output differently when writing to a pipe (maximum
buffering) and writing to a console (line buffering) as a console
implies a human interacting with the program who needs to see prompts.
SciTE has no way to stop the subprocess buffering data (there is no
equivalent of a pseudo-terminal on Windows) except for invocation
options. Some programs such as Python have flags (-u) to turn off
buffering. For other languages, there is often a call like C's setvbuf
that can be used to change buffering on a stream.
> You have to insert '$stdout.flush' here too after each 'puts' line.
> Also the cursor stays in the code pane and focus must be changed by
> explicitly clicking into the output pane.
SciTE can not see that the subprocess wants to read input. There
could be an option to switch focus when running particular applications
but for many commands like build it is better for the focus to stay in
the editor pane. A focus switching option also needs to handle whether
to return focus to the edit pane after command completion.
> SOLUTION: is to simply change the subsystem to '2'. An extra Window is
> opened and all works as expected.
Subsystem 2 is ShellExecute which has its own set of idiosyncrasies.
> Starting irb with the command setup as in ruby.properties opens the irb prompt
> in the scite output pane, but every input is echoed double.
This means that irb is echoing input. The ordering of the events in
SciTE make it difficult to change from the SciTE end. SciTE is
performing the character write upon receiving the SCN_CHARADDED
notification where the character has already been added to the buffer.
The reason it uses SCN_CHARADDED is because it is sent for cooked
characters after processing commands.
It may be possible to switch to reading key events and sending
through to the subprocess while running a command but this would be a
lot of work.
The biggest problem with SciTE's output pane for many is that it
interprets command characters. For example, typing ab[Backspace]c sends
the three characters abc through to the subprocess although the pane
shows ac. It has been proposed that there could be a line buffering
option where SciTE would build up a whole line and only send it when
Enter is pressed to handle this.
SciTE's output pane is not clever: the original goal in making it
interactive was to be able to respond to CVS prompts. Possible changes
will often make other scenarios fail so should be implemented as
options. As the output pane is currently sufficient for my needs, I
won't be working on improvements.