Working beeper (it can send morse)

Former-commit-id: 02553a52405ef4bba0d3f8f781f710b6c5b3ae16
Former-commit-id: 6cee7d2b44563a664756651d73a4b1ddfa70cf2f
This commit is contained in:
Song Minjae
2016-09-26 23:28:15 +09:00
parent 49fc723e66
commit bd4c95b321
12 changed files with 242 additions and 101 deletions

View File

@@ -22,11 +22,11 @@ internal class HostAccessProvider(globals: Globals, computer: BaseTerrarumComput
globals["native"]["println"] = PrintLn()
globals["native"]["isHalted"] = IsHalted(computer)
globals["native"]["closeInputString"] = NativeCloseInputString(computer.term!!)
globals["native"]["closeInputKey"] = NativeCloseInputKey(computer.term!!)
globals["native"]["openInput"] = NativeOpenInput(computer.term!!)
globals["native"]["getLastStreamInput"] = NativeGetLastStreamInput(computer.term!!)
globals["native"]["getLastKeyPress"] = NativeGetLastKeyPress(computer.term!!)
globals["native"]["closeInputString"] = NativeCloseInputString(computer.term)
globals["native"]["closeInputKey"] = NativeCloseInputKey(computer.term)
globals["native"]["openInput"] = NativeOpenInput(computer.term)
globals["native"]["getLastStreamInput"] = NativeGetLastStreamInput(computer.term)
globals["native"]["getLastKeyPress"] = NativeGetLastKeyPress(computer.term)
// while lua's dofile/require is fixiated to fs, this command allows
// libraries in JAR to be loaded.

View File

@@ -24,6 +24,7 @@ internal class Term(globals: Globals, term: Teletype) {
globals["term"]["width"] = Term.GetWidth(term)
globals["term"]["scroll"] = Term.Scroll(term)
globals["term"]["isTeletype"] = Term.IsTeletype(term)
globals["term"]["bell"] = Term.Bell(term)
if (term is Terminal) {
globals["term"]["emitRaw"] = Term.EmitRaw(term)
@@ -59,7 +60,14 @@ internal class Term(globals: Globals, term: Teletype) {
throw LuaError("bad argument (string expected, got ${this.typename()})")
}
}
class Bell(val tty: Teletype) : OneArgFunction() {
override fun call(pattern: LuaValue): LuaValue {
tty.bell(pattern.checkjstring())
return LuaValue.NONE
}
}
class WriteString(val tty: Teletype) : LuaFunction() {
override fun call(p0: LuaValue): LuaValue {
if (tty is Terminal)