REPL update
This commit is contained in:
parent
e2fd89e691
commit
ef890c8c34
3 changed files with 25 additions and 7 deletions
|
|
@ -2,14 +2,17 @@ ISOTerminal.addEventListener('ready', function(e){
|
||||||
setTimeout( () => this.boot(), 50 ) // because of autorestore.js
|
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'
|
let msg = '\n\r'
|
||||||
this.boot.menu.map( (m) => {
|
this.boot.menu.map( (m) => {
|
||||||
msg += `\r[36m ${m.key})[0m ${m.title(this.opts)}\n`
|
msg += `\r[36m ${m.key})[0m ${m.title(this.opts)}\n`
|
||||||
})
|
})
|
||||||
msg += `\n\r enter choice> `
|
msg += `\n\r enter choice> `
|
||||||
this.emit('serial-output-string', msg)
|
this.emit('serial-output-string', msg)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
ISOTerminal.addEventListener('bootmenu', function(e){ this.bootMenu() })
|
||||||
|
|
||||||
ISOTerminal.prototype.boot = async function(e){
|
ISOTerminal.prototype.boot = async function(e){
|
||||||
// set environment
|
// 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",
|
key: "1",
|
||||||
title: (opts) => `boot [31m${String(opts.iso || "").replace(/.*\//,'')}[0m Linux ❤️ `,
|
title: (opts) => `boot [31m${String(opts.iso || "").replace(/.*\//,'')}[0m Linux ❤️ `,
|
||||||
init: function(){ this.bootISO() },
|
init: function(){ this.bootISO() },
|
||||||
keyHandler: function(ch){ this.send(ch) } // send to v86 webworker
|
keyHandler: function(ch){ this.send(ch) } // send to v86 webworker
|
||||||
},
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// REPL: jsconsole
|
||||||
|
ISOTerminal.prototype.boot.menu.push(
|
||||||
{
|
{
|
||||||
key: "2",
|
key: "2",
|
||||||
title: (opts) => "just give me an javascript-console in WebXR instantly",
|
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('enable-console',{stdout:true})
|
||||||
this.emit('status',"javascript console")
|
this.emit('status',"javascript console")
|
||||||
this.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){
|
keyHandler: function(ch){
|
||||||
let erase = false
|
let erase = false
|
||||||
|
|
@ -80,4 +92,4 @@ ISOTerminal.prototype.boot.menu = [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
)
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ ISOTerminal.prototype.enableConsole = function(opts){
|
||||||
});
|
});
|
||||||
|
|
||||||
if( opts.stdout ){
|
if( opts.stdout ){
|
||||||
|
window.menu = () => this.bootMenu()
|
||||||
this.emit('serial-output-string', "\n\n\r☑ initialized javascript console\n");
|
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☑ please use these functions to print:\n");
|
||||||
this.emit('serial-output-string', "\r└☑ console.log(\"foo\")\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.dir({foo:12})\n");
|
||||||
this.emit('serial-output-string', "\r└☑ console.error(\"foo\")\n");
|
this.emit('serial-output-string', "\r└☑ console.error(\"foo\")\n");
|
||||||
this.emit('serial-output-string', "\r\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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,10 @@ ISOTerminal.prototype.TermInit = function(){
|
||||||
let menuitem = this.boot.menu.find( (m) => m.key == this.lastChar )
|
let menuitem = this.boot.menu.find( (m) => m.key == this.lastChar )
|
||||||
if( menuitem ){
|
if( menuitem ){
|
||||||
this.boot.menu.selected = menuitem
|
this.boot.menu.selected = menuitem
|
||||||
menuitem.init.call(this)
|
menuitem.init.call(this, () => {
|
||||||
|
this.term.write("\n\r")
|
||||||
|
this.bootMenu()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
this.term.write(ch)
|
this.term.write(ch)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue