jay.yydebug

Class yyJInputStream

public class yyJInputStream extends InputStream implements KeyListener

used to reroute standard input from a javax.swing.JTextArea. Feeds all read methods from listening to typed keys. Should not deadlock because one should generally not read from within the event thread.

While this implementation avoids Java generics, code for a generic version has simply been commented out.

Field Summary
protected StringBufferline
line edit buffer.
protected ArrayListqueue
completed lines, ready to be read.
Method Summary
intavailable()
voidclose()
protected voiddoKey(JTextArea ta, char ch, boolean paste)
process one typed or pasted character.
voidkeyPressed(KeyEvent ke)
this one ensures that you can only type at the end and implements control-C as copy and control-V as paste key if AWTPermission(accessClipboard) is granted.
voidkeyReleased(KeyEvent ke)
voidkeyTyped(KeyEvent ke)
intread()
intread(byte[] b, int off, int len)
longskip(long len)
returns 0: cannot skip on a terminal.

Field Detail

line

protected final StringBuffer line
line edit buffer.

queue

protected ArrayList queue
completed lines, ready to be read. Invariant: null after yyJInputStream.

Method Detail

available

public int available()

close

public void close()

doKey

protected void doKey(JTextArea ta, char ch, boolean paste)
process one typed or pasted character. The caret position is not updated for pasting.

keyPressed

public void keyPressed(KeyEvent ke)
this one ensures that you can only type at the end and implements control-C as copy and control-V as paste key if AWTPermission(accessClipboard) is granted. This is executed within the event thread.

BUG: paste should be based on the platform paste key; however, Safari does not send that one to an applet.

keyReleased

public void keyReleased(KeyEvent ke)

keyTyped

public void keyTyped(KeyEvent ke)

read

public int read()

read

public int read(byte[] b, int off, int len)

skip

public long skip(long len)
returns 0: cannot skip on a terminal.