Package jay.yydebug
Class yyJInputStream
- java.lang.Object
-
- java.io.InputStream
-
- jay.yydebug.yyJInputStream
-
- All Implemented Interfaces:
KeyListener
,Closeable
,AutoCloseable
,EventListener
public class yyJInputStream extends InputStream implements KeyListener
used to reroute standard input from aJTextArea
. 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
Fields Modifier and Type Field Description protected StringBuffer
line
line edit buffer.protected ArrayList
queue
completed lines, ready to be read.
-
Constructor Summary
Constructors Constructor Description yyJInputStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
protected void
doKey(JTextArea ta, char ch, boolean paste)
process one typed or pasted character.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.void
keyReleased(KeyEvent ke)
void
keyTyped(KeyEvent ke)
int
read()
int
read(byte[] b, int off, int len)
long
skip(long len)
returns 0: cannot skip on a terminal.-
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, transferTo
-
-
-
-
Field Detail
-
line
protected final StringBuffer line
line edit buffer.
-
-
Method Detail
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
public long skip(long len)
returns 0: cannot skip on a terminal.- Overrides:
skip
in classInputStream
-
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.
- Specified by:
keyPressed
in interfaceKeyListener
-
keyTyped
public void keyTyped(KeyEvent ke)
- Specified by:
keyTyped
in interfaceKeyListener
-
doKey
protected void doKey(JTextArea ta, char ch, boolean paste)
process one typed or pasted character. The caret position is not updated for pasting.
-
keyReleased
public void keyReleased(KeyEvent ke)
- Specified by:
keyReleased
in interfaceKeyListener
-
-