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

@@ -213,23 +213,15 @@ class TerrarumComputer(peripheralSlots: Int) {
fun keyPressed(key: Int, c: Char) {
stdinInput = c.toInt()
System.err.println("TerrarumComputer.keyPressed got input: $stdinInput")
// wake thread
runnableRunCommand.resume()
synchronized(stdin!!) {
(stdin as java.lang.Object).notifyAll()
}
}
fun openStdin() {
System.err.println("TerrarumComputer.openStdin")
stdinInput = -1
// sleep the thread
runnableRunCommand.pause()
@@ -344,8 +336,6 @@ class TerrarumComputer(peripheralSlots: Int) {
synchronized(pauseLock) {
paused = false
pauseLock.notifyAll() // Unblocks thread
System.err.println("ThreadRunCommand resume()")
}
}
}