keyevent reading moved to the tvdos itself

This commit is contained in:
minjaesong
2021-09-24 11:30:55 +09:00
parent 96e23d9019
commit 012bc44845
10 changed files with 632 additions and 70 deletions

View File

@@ -253,9 +253,9 @@ shell.coreutils = {
if (DEBUG_PRINT) serial.println("command.js > cd > pathstr = "+path.string);
// check if path is valid
filesystem.open(CURRENT_DRIVE, path.string, 'R');
var dirOpened = filesystem.isDirectory(CURRENT_DRIVE); // open a dir; if path is nonexistent, file won't actually be opened
if (!dirOpened) { printerrln("CHDIR failed for '"+path.string+"'"); return; } // if file is not opened, FALSE will be returned
var dirOpenedStatus = filesystem.open(CURRENT_DRIVE, path.string, 'R');
var isDir = filesystem.isDirectory(CURRENT_DRIVE); // open a dir; if path is nonexistent, file won't actually be opened
if (!isDir) { printerrln("CHDIR failed for '"+path.string+"'"); return dirOpenedStatus; } // if file is not opened, IO error code will be returned
shell_pwd = path.pwd;
},
@@ -268,9 +268,9 @@ shell.coreutils = {
if (DEBUG_PRINT) serial.println("command.js > mkdir > pathstr = "+path.string);
// check if path is valid
var dirOpened = filesystem.open(CURRENT_DRIVE, path.string, 'W');
var dirOpenedStatus = filesystem.open(CURRENT_DRIVE, path.string, 'W');
var mkdird = filesystem.mkDir(CURRENT_DRIVE);
if (!mkdird) { printerrln("MKDIR failed for '"+path.string+"'"); return; }
if (!mkdird) { printerrln("MKDIR failed for '"+path.string+"'"); return dirOpenedStatus; }
},
cls: function(args) {
con.clear();
@@ -326,8 +326,8 @@ shell.coreutils = {
var pathstr = (args[1] !== undefined) ? args[1] : shell.getPwdString();
// check if path is valid
var pathOpened = filesystem.open(CURRENT_DRIVE, pathstr, 'R');
if (!pathOpened) { printerrln("File not found"); return; }
var pathOpenedStatus = filesystem.open(CURRENT_DRIVE, pathstr, 'R');
if (pathOpenedStatus != 0) { printerrln("File not found"); return pathOpenedStatus; }
var port = filesystem._toPorts(CURRENT_DRIVE)[0]
com.sendMessage(port, "LIST");
@@ -336,8 +336,8 @@ shell.coreutils = {
cat: function(args) {
var pathstr = (args[1] !== undefined) ? args[1] : shell.getPwdString();
var pathOpened = filesystem.open(CURRENT_DRIVE, pathstr, 'R');
if (!pathOpened) { printerrln("File not found"); return; }
var pathOpenedStatus = filesystem.open(CURRENT_DRIVE, pathstr, 'R');
if (pathOpenedStatus != 0) { printerrln("File not found"); return pathOpenedStatus; }
let contents = filesystem.readAll(CURRENT_DRIVE);
// TODO just print out what's there
print(contents);
@@ -381,7 +381,7 @@ shell.execute = function(line) {
serial.println("[command.js > shell.execute] file search path: "+path);
}
if (filesystem.open(CURRENT_DRIVE, path, "R")) {
if (0 == filesystem.open(CURRENT_DRIVE, path, "R")) {
fileExists = true;
break searchLoop;
}

View File

@@ -39,7 +39,7 @@ let bulletinShown = false;
let cursoringCol = 0;
// load existing file if it's there
let editingExistingFile = filesystem.open(driveLetter, filePath, "R");
let editingExistingFile = (0 == filesystem.open(driveLetter, filePath, "R"));
if (editingExistingFile) {
textbuffer = filesystem.readAll(driveLetter).split("\n");
}

View File

@@ -3,10 +3,10 @@ if (exec_args[1] === undefined) {
return 1;
}
let fileOpened = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(exec_args[1]).string, "R");
if (!fileOpened) {
let fileOpenedStatus = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(exec_args[1]).string, "R");
if (fileOpenedStatus != 0) {
printerrln(_G.shell.resolvePathInput(exec_args[1]).string+": cannot open");
return 1;
return fileOpenedStatus;
}
let fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
let visible = "";

View File

@@ -11,10 +11,10 @@ if (exec_args[1] === undefined) {
let path = _G.shell.resolvePathInput(exec_args[2] || exec_args[1]).string;
let driveLetter = _G.shell.getCurrentDrive();
let noNewFile = (exec_args[1] == "/c" || exec_args[1] == "/C");
let fileOpened = filesystem.open(driveLetter, path, "W");
if (!fileOpened) {
let fileOpenedStatus = filesystem.open(driveLetter, path, "W");
if (fileOpenedStatus != 0) {
printerrln("TOUCH: Can't open "+driveLetter+":\\"+path+" due to IO error");
return 1;
return fileOpenedStatus;
}
if (!noNewFile) {