promote more readable this.send() in REPLs
This commit is contained in:
parent
2137af0a48
commit
e00b403dfc
2 changed files with 20 additions and 16 deletions
|
|
@ -47,6 +47,7 @@ ISOTerminal.prototype.serial_input = 0; // can be set to 0,1,2,3 to define stdin
|
||||||
|
|
||||||
ISOTerminal.prototype.send = function(str, ttyNr){
|
ISOTerminal.prototype.send = function(str, ttyNr){
|
||||||
if( ttyNr == undefined) ttyNr = this.serial_input
|
if( ttyNr == undefined) ttyNr = this.serial_input
|
||||||
|
if( (this.emulator || this.worker) && this.ready ){
|
||||||
if( ttyNr == undefined ){
|
if( ttyNr == undefined ){
|
||||||
if( this.emulator.serial_adapter ){
|
if( this.emulator.serial_adapter ){
|
||||||
this.emulator.serial_adapter.term.paste(str)
|
this.emulator.serial_adapter.term.paste(str)
|
||||||
|
|
@ -60,6 +61,9 @@ ISOTerminal.prototype.send = function(str, ttyNr){
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
this.emit('serial-output-string', str)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISOTerminal.prototype.convert = {
|
ISOTerminal.prototype.convert = {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ ISOTerminal.prototype.bootMenu = function(e){
|
||||||
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.send(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
ISOTerminal.addEventListener('bootmenu', function(e){ this.bootMenu() })
|
ISOTerminal.addEventListener('bootmenu', function(e){ this.bootMenu() })
|
||||||
|
|
@ -62,7 +62,7 @@ ISOTerminal.prototype.boot.menu.push(
|
||||||
this.emit('status',"javascript console")
|
this.emit('status',"javascript console")
|
||||||
this.console = ""
|
this.console = ""
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
this.emit('serial-output-string', this.prompt)
|
this.send(this.prompt)
|
||||||
}, 100 )
|
}, 100 )
|
||||||
},
|
},
|
||||||
keyHandler: function(ch){
|
keyHandler: function(ch){
|
||||||
|
|
@ -71,16 +71,16 @@ ISOTerminal.prototype.boot.menu.push(
|
||||||
ch = "\b \b" // why does write() not just support \x7F ?
|
ch = "\b \b" // why does write() not just support \x7F ?
|
||||||
erase = true
|
erase = true
|
||||||
}
|
}
|
||||||
this.emit('serial-output-string', ch)
|
this.send(ch)
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
this.console = ""
|
this.console = ""
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
if( this.boot.menu.selected ) this.emit('serial-output-string', this.prompt)
|
if( this.boot.menu.selected ) this.send(this.prompt)
|
||||||
},100)
|
},100)
|
||||||
}
|
}
|
||||||
if( (ch == "\n" || ch == "\r") ){
|
if( (ch == "\n" || ch == "\r") ){
|
||||||
try{
|
try{
|
||||||
this.emit('serial-output-string', "\n\r")
|
this.send("\n\r")
|
||||||
if( this.console ) eval(this.console)
|
if( this.console ) eval(this.console)
|
||||||
reset()
|
reset()
|
||||||
}catch(e){
|
}catch(e){
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue