various fixes to get the shell working better with a tty

This commit is contained in:
Lisa Milne 2023-12-12 20:50:42 +10:00
parent d8604b3e3b
commit abf9dbad6c
2 changed files with 27 additions and 28 deletions

View file

@ -55,19 +55,20 @@ var clite = {
reboot:function() {
clite.log.write('The system is rebooting');
// TODO: this all needs redoing with bios calls
//setTimeout(function() {
//clite.term.ttyctrl('hide');
//clite.log.write('Bringing down the system');
//var l = clite.core.load.script;
//var s = Array.from(document.getElementsByTagName('src'));
//s.forEach(function(el,i) {
//el.parentNode.removeChild(el);
//});
//clite.log.write('Resetting system core');
//delete clite;
//clite = null;
//l('clite/core.js',function() {setTimeout('clite.init();',500)});
//},10);
setTimeout(function() {
clite.log.write('Bringing down the system');
var s = Array.from(document.getElementsByTagName('src'));
s.forEach(function(el,i) {
if (i>0)
el.parentNode.removeChild(el);
});
clite.console.clear();
clite.log.write('Resetting system core');
var b = clite.state.bios;
delete clite;
clite = null;
setTimeout(b.boot.preBoot,100);
},10);
},
shutdown:function() {
clite.log.write('The system is shutting down');
@ -77,7 +78,7 @@ var clite = {
s.forEach(function(el) {
el.parentNode.removeChild(el);
});
clite.term.ttyctrl('hide');
clite.console.clear();
delete clite;
clite = null;
},10);
@ -2295,7 +2296,7 @@ clite.tty = {
if (key.code != 10)
return;
var l = clite.tty.internal.popLine(t);
if (!l)
if (l == null)
return;
var f = t.rcb;

View file

@ -246,10 +246,8 @@ clite.commands.load('sh',function(args,env,io) {
function run(txt,interactive) {
if (txt.length < 1) {
if (interactive) {
stdio.write(io.stdout,prompt);
if (interactive)
inputRead();
}
return;
}
history.add(txt);
@ -281,7 +279,7 @@ clite.commands.load('sh',function(args,env,io) {
var path = resolvePATH(args[0]);
if (!path) {
stdio.write(io.stderr,'Shell: unknown command: '+args[0]);
stdio.fprintf(io.stderr,'Shell: unknown command: %s\n',args[0]);
if (interactive)
inputRead();
return;
@ -293,23 +291,23 @@ clite.commands.load('sh',function(args,env,io) {
return;
if (r == -1) {
stdlib.write(io.stderr,'Shell: unknown command: '+args[0]);
stdlib.fprintf(io.stderr,'Shell: unknown command: %s\n',args[0]);
io.exit(-1);
}
if (r == -2) {
stdio.write(io.stderr,'Shell: error in command:'+args[0]);
stdio.fprintf(io.stderr,'Shell: error in command: %s\n',args[0]);
io.exit(-1);
}
if (r == -3 || r == -4) {
stdio.write(io.stderr,'Shell: not an executable file:'+args[0]);
stdio.fprintf(io.stderr,'Shell: not an executable file: %s\n',args[0]);
io.exit(-3);
}
}
var pid = stdlib.fork(env,fio,execFunc);
if (pid == 0) {
stdio.write(io.stderr,'Shell: internal error');
stdio.write(io.stderr,'Shell: internal error\n');
if (interactive)
inputRead();
return;
@ -352,11 +350,11 @@ clite.commands.load('sh',function(args,env,io) {
}
}
function input(str) {
if (str[0] == '\1') {
inputControl(str.substring(1));
inputRead();
return;
}
//if (str[0] == '\1') {
//inputControl(str.substring(1));
//inputRead();
//return;
//}
run(str,true);
}