working io.read from STDIN

Former-commit-id: b1168a53fd5fbd09c6a5a76506402560fc4e0fd7
Former-commit-id: a0d455da14a6eb7bf0127e136949273ec5a28628
This commit is contained in:
Song Minjae
2017-03-02 22:35:13 +09:00
parent 74250150de
commit 55f7a4ed46
12 changed files with 457 additions and 401 deletions

View File

@@ -206,6 +206,8 @@ class GraphicsTerminal(private val host: TerrarumComputer) : Terminal {
)
(0..displacement - 1).forEach { rgba[it] = 0.toByte() }
}
cursorY += -amount
}
/**

View File

@@ -8,35 +8,16 @@ import java.io.InputStream
*/
class TerminalInputStream(val host: TerrarumComputer) : InputStream() {
private val pauseLock = java.lang.Object()
override fun read(): Int {
System.err.println("TerminalInputStream.read called")
//System.err.println(Thread.currentThread().name)
// would display "LuaJ Separated", which means this InputStream will not block main thread
host.openStdin()
synchronized(this) {
(this as java.lang.Object).wait()
}
System.err.println("TerminalInputStream.read exit")
return host.stdinInput
}
override fun read(b: ByteArray?): Int {
TODO()
}
override fun read(b: ByteArray?, off: Int, len: Int): Int {
TODO()
}
}