diff --git a/com/isoterminal/feat/boot.js b/com/isoterminal/feat/boot.js index 9432074..9cd5cc0 100644 --- a/com/isoterminal/feat/boot.js +++ b/com/isoterminal/feat/boot.js @@ -2,14 +2,17 @@ ISOTerminal.addEventListener('ready', function(e){ setTimeout( () => this.boot(), 50 ) // because of autorestore.js }) -ISOTerminal.addEventListener('bootmenu', function(e){ +ISOTerminal.prototype.bootMenu = function(e){ + this.boot.menu.selected = false // reset let msg = '\n\r' this.boot.menu.map( (m) => { msg += `\r ${m.key}) ${m.title(this.opts)}\n` }) msg += `\n\r enter choice> ` this.emit('serial-output-string', msg) -}) +} + +ISOTerminal.addEventListener('bootmenu', function(e){ this.bootMenu() }) ISOTerminal.prototype.boot = async function(e){ // set environment @@ -32,15 +35,22 @@ ISOTerminal.prototype.boot = async function(e){ } } -ISOTerminal.prototype.boot.menu = [ +// here REPL's can be defined +ISOTerminal.prototype.boot.menu = [] + +// REPL: iso +ISOTerminal.prototype.boot.menu.push( { key: "1", title: (opts) => `boot ${String(opts.iso || "").replace(/.*\//,'')} Linux ❤️ `, init: function(){ this.bootISO() }, keyHandler: function(ch){ this.send(ch) } // send to v86 webworker - }, + } +) +// REPL: jsconsole +ISOTerminal.prototype.boot.menu.push( { key: "2", title: (opts) => "just give me an javascript-console in WebXR instantly", @@ -49,7 +59,9 @@ ISOTerminal.prototype.boot.menu = [ this.emit('enable-console',{stdout:true}) this.emit('status',"javascript console") this.console = "" - setTimeout( () => this.emit('serial-output-string', this.prompt), 100 ) + setTimeout( () => { + if( this.boot.menu.selected ) this.emit('serial-output-string', this.prompt) + }, 100 ) }, keyHandler: function(ch){ let erase = false @@ -80,4 +92,4 @@ ISOTerminal.prototype.boot.menu = [ } } } -] +) diff --git a/com/isoterminal/feat/jsconsole.js b/com/isoterminal/feat/jsconsole.js index c5ea3fa..a4db1e6 100644 --- a/com/isoterminal/feat/jsconsole.js +++ b/com/isoterminal/feat/jsconsole.js @@ -58,6 +58,7 @@ ISOTerminal.prototype.enableConsole = function(opts){ }); if( opts.stdout ){ + window.menu = () => this.bootMenu() this.emit('serial-output-string', "\n\n\r☑ initialized javascript console\n"); this.emit('serial-output-string', "\r☑ please use these functions to print:\n"); this.emit('serial-output-string', "\r└☑ console.log(\"foo\")\n"); @@ -65,6 +66,8 @@ ISOTerminal.prototype.enableConsole = function(opts){ this.emit('serial-output-string', "\r└☑ console.dir({foo:12})\n"); this.emit('serial-output-string', "\r└☑ console.error(\"foo\")\n"); this.emit('serial-output-string', "\r\n"); + this.emit('serial-output-string', "\rtype 'menu()' to return to mainmenu"); + this.emit('serial-output-string', "\r\n"); } } diff --git a/com/isoterminal/feat/term.js b/com/isoterminal/feat/term.js index 4cd6014..ea6b84c 100644 --- a/com/isoterminal/feat/term.js +++ b/com/isoterminal/feat/term.js @@ -87,7 +87,10 @@ ISOTerminal.prototype.TermInit = function(){ let menuitem = this.boot.menu.find( (m) => m.key == this.lastChar ) if( menuitem ){ this.boot.menu.selected = menuitem - menuitem.init.call(this) + menuitem.init.call(this, () => { + this.term.write("\n\r") + this.bootMenu() + }) } }else{ this.term.write(ch)