improved REPL performance
All checks were successful
/ mirror_to_github (push) Successful in 30s
/ test (push) Successful in 6s

This commit is contained in:
Leon van Kammen 2025-03-24 17:33:04 +01:00
parent 9698cafefd
commit 9579bf7215
4 changed files with 18 additions and 32 deletions

View file

@ -95,34 +95,12 @@ ISOTerminal.addEventListener('init', function(){
}, 100 ) }, 100 )
}, },
keyHandler: function(ch){ keyHandler: function(ch){
let erase = false
// if( ch == '\x7F' ){
// ch = "\b \b" // why does write() not just support \x7F ?
// erase = true
// }
this.send(ch) this.send(ch)
const reset = () => { },
this.console = "" cmdHandler: function(cmd){
setTimeout( () => { this.send("\n\r")
if( this.boot.menu.selected ) this.send(this.prompt) eval(cmd)
},100) setTimeout( () => this.send(this.prompt) ,10) // because worker vs terminal
}
if( (ch == "\n" || ch == "\r") ){
try{
this.send("\n\r")
if( this.console ) eval(this.console)
reset()
}catch(e){
reset()
throw e // re throw
}
}else{
if( erase ){
this.console = this.console.split('').slice(0,-1).join('')
}else{
this.console += ch
}
}
} }
} }
) )

View file

@ -78,15 +78,18 @@ ISOTerminal.prototype.TermInit = function(){
erase = true erase = true
} }
if( this.boot.menu.selected ){ if( this.boot.menu.selected ){
this.boot.menu.selected.keyHandler.call(this,ch)
if( isEnter ){ if( isEnter ){
this.boot.menu.selected.cmdHandler.call(this,this.lastCmd) if( this.boot.menu.selected.cmdHandler ){
this.boot.menu.selected.cmdHandler.call(this,this.lastCmd)
}
this.lastCmd = "" this.lastCmd = ""
} }
else this.boot.menu.selected.keyHandler.call(this,ch)
}else if( isEnter ){ }else if( isEnter ){
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
this.lastCmd = ""
menuitem.init.call(this, () => { menuitem.init.call(this, () => {
this.term.write("\n\r") this.term.write("\n\r")
this.bootMenu() this.bootMenu()

View file

@ -1,3 +1,5 @@
;
(function (three) { (function (three) {
'use strict'; 'use strict';
@ -676,4 +678,5 @@
}); });
})(THREE); })(THREE);
//# sourceMappingURL=aframe-html.js.map

View file

@ -116,9 +116,11 @@ AFRAME.registerComponent('window', {
}) })
AFRAME.utils.positionObjectNextToNeighbor = function positionObjectNextToNeighbor(object, lastNeighbor = null, margin ){ AFRAME.utils.positionObjectNextToNeighbor = function positionObjectNextToNeighbor(object, lastNeighbor = null, margin ){
if( lastNeighbor == null || object == null) return
// *FIXME* this could be more sophisticated :) // *FIXME* this could be more sophisticated :)
object.position.x = lastNeighbor.position.x + margin object.position.x = lastNeighbor.position.x + margin
object.position.y = lastNeighbor.position.y - margin object.position.y = lastNeighbor.position.y - margin
object.position.z = lastNeighbor.position.z + margin object.position.z = lastNeighbor.position.z + margin
} }