Community
Participate
Working Groups
There are two streams of data: 1. terminal-to-remote (e.g. characters entered into the terminal by the user) 2. remote-to-terminal (e.g. text to be displayed in the terminal) For historic reasons terminal-to-remote (1) is an OutputStream but remote-to-terminal uses ITerminalControl.writeToTerminal(String data). This is a very ugly asymmetry. writeToTerminal has additional problems, because the communication is bytes (8 bit) but the String is chars (16 bit). If the method is not used carefully (e.g. new String(bytes) is used), the platform's default charset determines how the bytes are converted into chars. To fix this: remote-to-terminal should also be an OutputStream!
Added ITerminalControl.getRemoteToTerminalOutputStream() that return an OutputStream for connections to write to the terminal. I created a new class called TerminalInputStream which is essentially an implementation of PipedOutputStream/PipedIntputStream that actually works efficiently. PipedOutputStream/PipedIntputStream is extremely slow (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4404700). For the terminal it was about 1kb/sec (depending of the buffer-size used). My implementation can handle megabytes/sec. TerminalInputStream also starts a Runnable in the Display thread, each time data is written to the OutputStream. The runnable should read data from the TerminalInputStream until no more data is available. The availability of data is time-limited: when the time running the runnable exceeds a certain amount of time, the TerminalInputStream returns 0 on available() and the runnable is rescheduled again. TerminalText now uses a InputStreamReader decorating the TerminalInputStream using an "ISO-8859-1" encoding. Maybe the encoding should be done more flexible...
(In reply to comment #1) > PipedOutputStream/PipedIntputStream is extremely slow (see > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4404700). FYI, the SSH library used by Eclipse (com.jcraft.jsch) also uses PipedInputStrea, with a 32KB buffer: PipedInputStream pis = new PipedInputStream(os, 32*1024) If your implementation is a lot more efficient, it might make sense contributing it to JSch for the next release?
Closing.
[target cleanup] 2.0 M7 was the original target milestone for this bug