mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-15 08:54:05 +09:00
more pipe stuffs
This commit is contained in:
@@ -28,7 +28,12 @@ function bootFromPort(port) {
|
|||||||
else throw "No Bootsector"
|
else throw "No Bootsector"
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
printerrln(`No bootable medium on COM ${port+1}`)
|
if ("No Bootsector" == e)
|
||||||
|
printerrln(`No bootable medium on COM ${port+1}`)
|
||||||
|
else
|
||||||
|
printerrln(`Boot failed with errors:\n\n${e}`)
|
||||||
|
|
||||||
|
serial.printerr(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +157,7 @@ showHowtoEnterMenu()
|
|||||||
let bootable = probeBootable()
|
let bootable = probeBootable()
|
||||||
let sysRq = false
|
let sysRq = false
|
||||||
let tmr = sys.nanoTime()
|
let tmr = sys.nanoTime()
|
||||||
while (sys.nanoTime() - tmr < 5 * 1000000000.0) {
|
while (sys.nanoTime() - tmr < 3 * 1000000000.0) {
|
||||||
sysRq = sys.getSysrq()
|
sysRq = sys.getSysrq()
|
||||||
if (sysRq) break
|
if (sysRq) break
|
||||||
sys.spin()
|
sys.spin()
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ filesystem._close = (portNo) => {
|
|||||||
filesystem._flush = (portNo) => {
|
filesystem._flush = (portNo) => {
|
||||||
com.sendMessage(portNo, "FLUSH");
|
com.sendMessage(portNo, "FLUSH");
|
||||||
};
|
};
|
||||||
// @return true if operation committed successfully, false if:
|
// @return disk status code (0 for successful operation)
|
||||||
// - opening file with R-mode and target file does not exists
|
|
||||||
// throws if:
|
// throws if:
|
||||||
// - java.lang.NullPointerException if path is null
|
// - java.lang.NullPointerException if path is null
|
||||||
// - Error if operation mode is not "R", "W" nor "A"
|
// - Error if operation mode is not "R", "W" nor "A"
|
||||||
|
|||||||
@@ -456,6 +456,34 @@ shell.execute = function(line) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
shell.pipes = {}; // syntax: _G.shell.pipes[name] = contents; all pipes are named pipes just like in Windows
|
shell.pipes = {}; // syntax: _G.shell.pipes[name] = contents; all pipes are named pipes just like in Windows
|
||||||
|
shell.currentlyActivePipes = []; // pipe queue. Use shell.getPipe() to dequeue and shell.pushPipe() to enqueue.
|
||||||
|
shell._rndstr = '0123456789+qwfpgjluyarstdhneiozxcvbkm/QWFPGJLUYARSTDHNEIOZXCVBKM'
|
||||||
|
shell.generateRandomName = function() {
|
||||||
|
let name = ''
|
||||||
|
while (true) {
|
||||||
|
name = "anonpipe_"
|
||||||
|
for (let k = 0; k < 32; k++) {
|
||||||
|
name += shell._rndstr[(Math.random() * 64)|0]
|
||||||
|
}
|
||||||
|
if (shell.pipes[name] == undefined) break
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
shell.getPipe = function() {
|
||||||
|
let n = shell.currentlyActivePipes.shift()
|
||||||
|
return (n != undefined) ? shell.pipes[n] : undefined
|
||||||
|
}
|
||||||
|
shell.pushAnonPipe = function(contents) {
|
||||||
|
let name = shell.generateRandomName()
|
||||||
|
shell.pushPipe(name, contents)
|
||||||
|
}
|
||||||
|
shell.pushPipe = function(name, contents) {
|
||||||
|
shell.pipes[name] = contents
|
||||||
|
shell.currentlyActivePipes.unshift(name)
|
||||||
|
}
|
||||||
|
shell.hasPipe = function() {
|
||||||
|
return shell.currentlyActivePipes[0] != undefined
|
||||||
|
}
|
||||||
Object.freeze(shell);
|
Object.freeze(shell);
|
||||||
_G.shell = shell;
|
_G.shell = shell;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
if (exec_args[1] === undefined) {
|
let filename = exec_args[1]
|
||||||
println('Missing filename ("less -?" for help)');
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*let help = "\n
|
/*let help = "\n
|
||||||
SUMMARY OF COMMANDS\n
|
SUMMARY OF COMMANDS\n
|
||||||
@@ -10,27 +7,46 @@ SUMMARY OF COMMANDS\n
|
|||||||
q Q Exit
|
q Q Exit
|
||||||
\n"*/
|
\n"*/
|
||||||
|
|
||||||
if (exec_args[1].startsWith("-?")) {
|
|
||||||
println("less <filename>");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
let fileOpened = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(exec_args[1]).string, "R");
|
|
||||||
if (!fileOpened) {
|
|
||||||
printerrln(_G.shell.resolvePathInput(exec_args[1]).string+": cannot open");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let scroll = 0;
|
let scroll = 0;
|
||||||
let pan = -1;
|
let pan = -1;
|
||||||
let termW = con.getmaxyx()[1];
|
let termW = con.getmaxyx()[1];
|
||||||
let termH = con.getmaxyx()[0] - 1;
|
let termH = con.getmaxyx()[0] - 1;
|
||||||
let buf = "";
|
let buf = "";
|
||||||
let fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
|
let fileContent = undefined
|
||||||
let key = -1;
|
let key = -1;
|
||||||
let panSize = termW >> 1;
|
let panSize = termW >> 1;
|
||||||
let scrollSize = termH >> 3;
|
let scrollSize = termH >> 3;
|
||||||
|
|
||||||
|
let startAddr = -1;
|
||||||
|
let paintCur = 0;
|
||||||
|
let cy = 1;
|
||||||
|
let cx = 1;
|
||||||
|
let char = -1;
|
||||||
|
|
||||||
|
let numbuf = 0;
|
||||||
|
|
||||||
|
if (filename === undefined && _G.shell.hasPipe()) {
|
||||||
|
fileContent = _G.shell.getPipe()
|
||||||
|
}
|
||||||
|
else if (filename === undefined) {
|
||||||
|
println('Missing filename ("less -?" for help)');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (filename.startsWith("-?")) {
|
||||||
|
println("less <filename>");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let fileOpened = filesystem.open(_G.shell.getCurrentDrive(), _G.shell.resolvePathInput(filename).string, "R");
|
||||||
|
if (fileOpened != 0) {
|
||||||
|
printerrln(_G.shell.resolvePathInput(filename).string+": cannot open");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileContent = filesystem.readAll(_G.shell.getCurrentDrive());
|
||||||
|
}
|
||||||
|
|
||||||
// initialise some helper variables
|
// initialise some helper variables
|
||||||
let lineToBytes = [0];
|
let lineToBytes = [0];
|
||||||
let maxPan = 0;
|
let maxPan = 0;
|
||||||
@@ -45,13 +61,8 @@ for (let i = 0; i < fileContent.length; i++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let startAddr = -1;
|
|
||||||
let paintCur = 0;
|
|
||||||
let cy = 1;
|
|
||||||
let cx = 1;
|
|
||||||
let char = -1;
|
|
||||||
|
|
||||||
let numbuf = 0;
|
|
||||||
|
|
||||||
let resetKeyReadStatus = function() {
|
let resetKeyReadStatus = function() {
|
||||||
numbuf = 0;
|
numbuf = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user