Package jay.yydebug
Class yyJInputStream
java.lang.Object
java.io.InputStream
jay.yydebug.yyJInputStream
- All Implemented Interfaces:
KeyListener,Closeable,AutoCloseable,EventListener
used to reroute standard input from a
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
FieldsModifier and TypeFieldDescriptionprotected final StringBufferline edit buffer.protected ArrayListcompleted lines, ready to be read. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()protected voidprocess 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) voidintread()intread(byte[] b, int off, int len) longskip(long len) returns 0: cannot skip on a terminal.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Field Details
-
line
line edit buffer. -
queue
completed lines, ready to be read. Invariant: null afterclose().
-
-
Constructor Details
-
yyJInputStream
public yyJInputStream()
-
-
Method Details
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
public long skip(long len) returns 0: cannot skip on a terminal.- Overrides:
skipin classInputStream
-
keyPressed
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:
keyPressedin interfaceKeyListener
-
keyTyped
- Specified by:
keyTypedin interfaceKeyListener
-
doKey
process one typed or pasted character. The caret position is not updated for pasting. -
keyReleased
- Specified by:
keyReleasedin interfaceKeyListener
-