Package jay.yydebug
Class yyInputStream
java.lang.Object
java.io.InputStream
jay.yydebug.yyInputStream
- All Implemented Interfaces:
KeyListener
,Closeable
,AutoCloseable
,EventListener
used to reroute standard input from a
TextArea
.
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 uses Java generics, code for a non-generic version has simply been commented out.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringBuffer
line edit buffer.protected ArrayList
completed lines, ready to be read. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
void
keyPressed
(KeyEvent ke) this one ensures that you can only type at the end.void
keyReleased
(KeyEvent ke) void
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, skipNBytes, transferTo
-
Field Details
-
line
line edit buffer. -
queue
completed lines, ready to be read. Invariant: null afterclose()
.
-
-
Constructor Details
-
yyInputStream
public yyInputStream()
-
-
Method Details
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
public long skip(long len) returns 0: cannot skip on a terminal.- Overrides:
skip
in classInputStream
-
keyPressed
this one ensures that you can only type at the end. This is executed within the event thread.- Specified by:
keyPressed
in interfaceKeyListener
-
keyTyped
- Specified by:
keyTyped
in interfaceKeyListener
-
keyReleased
- Specified by:
keyReleased
in interfaceKeyListener
-