VT: shit is still rolling

- We might need virtual disk image...

Former-commit-id: c3278cd9fe1ddad8b26b45577fecb0500365d38b
This commit is contained in:
Song Minjae
2017-03-31 17:27:53 +09:00
parent 5bfc5c3a38
commit 1057e7d442
7 changed files with 24 additions and 51 deletions

View File

@@ -37,8 +37,6 @@ class GraphicsTerminal(private val host: TerrarumComputer) : Terminal {
private val colourKey: Int
get() = backColour.shl(4) or (foreColour).and(0xFF)
override var lastInputByte = -1
override fun getColor(index: Int) = videoCard.CLUT[index]
override val displayW: Int; get() = videoCard.width //+ 2 * borderSize
@@ -272,11 +270,6 @@ class GraphicsTerminal(private val host: TerrarumComputer) : Terminal {
}
}
override fun getKeyPress(): Int? {
//TODO("not implemented")
return null
}
companion object {
private val WHITE7500 = Color(0xe4eaff)

View File

@@ -30,7 +30,7 @@ open class SimpleTextTerminal(
* Terminals must support AT LEAST 4 colours.
* Color index 0 must be default background, index 3 must be default foreground
*/
open protected val colours = if (colour) CLUT else CLUT.copyOfRange(0, 3)
open protected val colours = if (colour) CLUT else CLUT.copyOfRange(0, 4)
val phosphor = if (colour) WHITE7500 else phosphorColour
open val colourScreen = if (colour) Color(8, 8, 8) else Color(19, 19, 19)
@@ -339,26 +339,10 @@ open class SimpleTextTerminal(
}
}
override var lastInputByte: Int = -1
var sb: StringBuilder = StringBuilder()
private var inputOpen = false
private var keyPressVisible = false
override fun keyPressed(key: Int, c: Char) {
lastInputByte = c.toInt()
if (inputOpen) {
if (c == ASCII_CR)
printChar(ASCII_LF)
else if (keyPressVisible)
printChar(c)
if (!asciiControlInUse.contains(c)) sb.append(c)
else if (key == Key.BACKSPACE && sb.isNotEmpty()) sb.deleteCharAt(sb.length - 1)
}
host.keyPressed(key, c)
}
override fun getKeyPress(): Int? = lastInputByte
private fun isOOB(x: Int, y: Int) =
(x < 0 || y < 0 || x >= width || y >= height)

View File

@@ -25,8 +25,6 @@ interface Terminal : Teletype {
var backColour: Int
var foreColour: Int
var lastInputByte: Int
// to be used in UI
override val displayW: Int
val displayH: Int
@@ -65,17 +63,4 @@ interface Terminal : Teletype {
fun emitTone(duration: Millisec, freq: Double)
override fun bell(pattern: String)
/** Requires keyPressed() event to be processed.
*
* null indicates the input stream is waiting for an input
*
* implementation:
*
* private var lastInputByte: Int? = null
* override fun keyPressed(key: Int, c: Char) {
lastInputByte = c.toInt()
lastInputByte = null
}
*/
fun getKeyPress(): Int?
}