From abf9dbad6c80a167de764fc4c0c719647754a120 Mon Sep 17 00:00:00 2001 From: Lisa Milne Date: Tue, 12 Dec 2023 20:50:42 +1000 Subject: [PATCH] various fixes to get the shell working better with a tty --- clite/core.js | 31 ++++++++++++++++--------------- clite/shell.js | 24 +++++++++++------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/clite/core.js b/clite/core.js index fac0393..a0cd64f 100644 --- a/clite/core.js +++ b/clite/core.js @@ -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; diff --git a/clite/shell.js b/clite/shell.js index 6deed86..f60c4c6 100644 --- a/clite/shell.js +++ b/clite/shell.js @@ -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); }