mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
more input reading|js console app
This commit is contained in:
44
assets/jscon.js
Normal file
44
assets/jscon.js
Normal file
@@ -0,0 +1,44 @@
|
||||
function readConsoleInput() {
|
||||
var cmdbuf = "";
|
||||
var key = -1;
|
||||
while (key != 10 && key != 13) {
|
||||
key = vm.readKey();
|
||||
// printable chars
|
||||
if (key >= 32 && key <= 126) {
|
||||
var s = String.fromCharCode(key);
|
||||
cmdbuf += s;
|
||||
print(s);
|
||||
}
|
||||
// backspace
|
||||
else if (key == 8 && cmdbuf.length > 0) {
|
||||
cmdbuf = cmdbuf.substring(0, cmdbuf.length - 1);
|
||||
print(String.fromCharCode(key));
|
||||
}
|
||||
// up down key
|
||||
else if (key >= 19 && key <= 20) {
|
||||
return key;
|
||||
}
|
||||
// left right key
|
||||
else if (key >= 19 && key <= 20) {
|
||||
//
|
||||
}
|
||||
}
|
||||
return cmdbuf;
|
||||
}
|
||||
|
||||
println("JS Console");
|
||||
while (true) {
|
||||
print("JS> ");
|
||||
|
||||
var cmdbuf = readConsoleInput();
|
||||
|
||||
if (typeof cmdbuf == "string") {
|
||||
println();
|
||||
try {
|
||||
println(eval(cmdbuf));
|
||||
}
|
||||
catch (e) {
|
||||
println(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,16 +22,9 @@ println("Starting TVDOS...");
|
||||
|
||||
greet();
|
||||
|
||||
/*while (true) {
|
||||
while (true) {
|
||||
print(get_prompt_text());
|
||||
var s = read();
|
||||
println();
|
||||
println("String read: " + s + "@");
|
||||
}*/
|
||||
|
||||
println(vm.peek(-4093)); // expecting an odd number
|
||||
vm.poke(-4093, 6);
|
||||
for (i = 0; i < 4096; i++) {
|
||||
print(String.fromCharCode(vm.peek(-4097 - i)));
|
||||
}
|
||||
println();
|
||||
}
|
||||
Reference in New Issue
Block a user