Skip to content

Commit 9579bf7

Browse files
improved REPL performance
1 parent 9698caf commit 9579bf7

File tree

4 files changed

+18
-32
lines changed

4 files changed

+18
-32
lines changed

com/isoterminal/feat/jsconsole.js

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,13 @@ ISOTerminal.addEventListener('init', function(){
9494
this.send(this.prompt)
9595
}, 100 )
9696
},
97-
keyHandler: function(ch){
98-
let erase = false
99-
// if( ch == '\x7F' ){
100-
// ch = "\b \b" // why does write() not just support \x7F ?
101-
// erase = true
102-
// }
97+
keyHandler: function(ch){
10398
this.send(ch)
104-
const reset = () => {
105-
this.console = ""
106-
setTimeout( () => {
107-
if( this.boot.menu.selected ) this.send(this.prompt)
108-
},100)
109-
}
110-
if( (ch == "\n" || ch == "\r") ){
111-
try{
112-
this.send("\n\r")
113-
if( this.console ) eval(this.console)
114-
reset()
115-
}catch(e){
116-
reset()
117-
throw e // re throw
118-
}
119-
}else{
120-
if( erase ){
121-
this.console = this.console.split('').slice(0,-1).join('')
122-
}else{
123-
this.console += ch
124-
}
125-
}
99+
},
100+
cmdHandler: function(cmd){
101+
this.send("\n\r")
102+
eval(cmd)
103+
setTimeout( () => this.send(this.prompt) ,10) // because worker vs terminal
126104
}
127105
}
128106
)

com/isoterminal/feat/term.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,18 @@ ISOTerminal.prototype.TermInit = function(){
7878
erase = true
7979
}
8080
if( this.boot.menu.selected ){
81+
this.boot.menu.selected.keyHandler.call(this,ch)
8182
if( isEnter ){
82-
this.boot.menu.selected.cmdHandler.call(this,this.lastCmd)
83+
if( this.boot.menu.selected.cmdHandler ){
84+
this.boot.menu.selected.cmdHandler.call(this,this.lastCmd)
85+
}
8386
this.lastCmd = ""
8487
}
85-
else this.boot.menu.selected.keyHandler.call(this,ch)
8688
}else if( isEnter ){
8789
let menuitem = this.boot.menu.find( (m) => m.key == this.lastChar )
8890
if( menuitem ){
8991
this.boot.menu.selected = menuitem
92+
this.lastCmd = ""
9093
menuitem.init.call(this, () => {
9194
this.term.write("\n\r")
9295
this.bootMenu()

com/lib/aframe-html.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
;
13
(function (three) {
24
'use strict';
35

@@ -676,4 +678,5 @@
676678
});
677679

678680
})(THREE);
679-
//# sourceMappingURL=aframe-html.js.map
681+
682+

com/window.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ AFRAME.registerComponent('window', {
116116
})
117117

118118
AFRAME.utils.positionObjectNextToNeighbor = function positionObjectNextToNeighbor(object, lastNeighbor = null, margin ){
119+
if( lastNeighbor == null || object == null) return
119120
// *FIXME* this could be more sophisticated :)
120121
object.position.x = lastNeighbor.position.x + margin
121122
object.position.y = lastNeighbor.position.y - margin
122123
object.position.z = lastNeighbor.position.z + margin
123-
124124
}
125+
126+

0 commit comments

Comments
 (0)