xterm improvment
/ mirror_to_github (push) Successful in 20s Details
/ test (push) Successful in 4s Details

This commit is contained in:
Leon van Kammen 2024-09-24 09:53:23 +00:00
parent 9d69ef9c57
commit bc82d87541
1 changed files with 25 additions and 14 deletions

View File

@ -27,21 +27,32 @@ ISOTerminal.prototype.xtermInit = function(){
}) })
term.onRender( () => { term.onRender( () => {
console.log("render")
let _window = term._core._coreBrowserService._window
if( !_window.requestAnimationFrameAFRAME ){ // patch the planet!
// xterm relies on requestAnimationFrame (which does not called in immersive mode) // xterm relies on requestAnimationFrame (which does not called in immersive mode)
const _window = term._core._coreBrowserService._window _window.requestAnimationFrameAFRAME =
const requestAnimationFrame = _window.requestAnimationFrame AFRAME.utils.throttleLeadingAndTrailing( function(cb){
// luckily xterm allows a swappable window object
let newWindow = function(){}.bind(window)
for( var i in window ) newWindow[i] = window[i]
newWindow.requestAnimationFrame = (cb) => {
if( term.tid != null ) return
setTimeout( () => {
cb() cb()
term.tid = null },150 )
},200)
// we proxy the _window object of xterm, and reroute
// requestAnimationFrame to requestAnimationFrameAFRAME
_window = new Proxy(_window,{
get(me,k){
if( k == 'requestAnimationFrame' ){
return me.requestAnimationFrameAFRAME
}
return me[k]
},
set(me,k,v){
me[k] = v
return true
}
})
term._core._coreBrowserService._window = _window
} }
term._core._coreBrowserService._window = newWindow
}) })