Compare commits

..

No commits in common. "4105cbda0993081856fcdf5714293217a8ad8df3" and "c79b764f00b6f487e1bd2461ff815d6a86dc31dd" have entirely different histories.

2 changed files with 17 additions and 38 deletions

View File

@ -109,7 +109,8 @@ AFRAME.registerComponent('codemirror', {
// we don't do via shellcmd: isoterminal.exec(`echo '${str}' > ${file}`,1) // we don't do via shellcmd: isoterminal.exec(`echo '${str}' > ${file}`,1)
// as it would require all kindof ugly stringescaping // as it would require all kindof ugly stringescaping
console.log("updating "+file) console.log("updating "+file)
await this.isoterminal.worker['emulator.update_file'](file, this.isoterminal.convert.toUint8Array(str) ) console.log(str)
await this.isoterminal.worker['emulator.update_file'](file, term.convert.toUint8Array(str) )
}, },
events:{ events:{

View File

@ -551,28 +551,25 @@ VT100.prototype.clearpos = function VT100_clearpos(row, col)
this.redraw_[row] = 1; this.redraw_[row] = 1;
} }
VT100.prototype.curs_set = function(vis, grab, offscreenKB) VT100.prototype.curs_set = function(vis, grab, eventist)
{ {
// offscreenKB is a div which receives keys from physical kb's
// but not from touch keyboards (they require an input-field)
// hence setupTouchInputFallback()..this is how we seperate the two
this.info("curs_set:: vis: " + vis + ", grab: " + grab); this.info("curs_set:: vis: " + vis + ", grab: " + grab);
if (vis !== undefined){ if (vis !== undefined){
this.cursor_vis_ = (vis > 0); this.cursor_vis_ = (vis > 0);
} }
if (offscreenKB === undefined) if (eventist === undefined)
offscreenKB = this.scr_; eventist = this.scr_;
if (grab === true || grab === false) { if (grab === true || grab === false) {
if (grab === this.grab_events_) if (grab === this.grab_events_)
return; return;
if (grab) { if (grab) {
this.grab_events_ = true; this.grab_events_ = true;
VT100.the_vt_ = this; VT100.the_vt_ = this;
offscreenKB.addEventListener("keypress", VT100.handle_onkeypress_, false); eventist.addEventListener("keypress", VT100.handle_onkeypress_, false);
offscreenKB.addEventListener("keydown", VT100.handle_onkeypress_, false); eventist.addEventListener("keydown", VT100.handle_onkeypress_, false);
} else { } else {
offscreenKB.removeEventListener("keypress", VT100.handle_onkeypress_, false); eventist.removeEventListener("keypress", VT100.handle_onkeypress_, false);
offscreenKB.removeEventListener("keydown", VT100.handle_onkeypress_, false); eventist.removeEventListener("keydown", VT100.handle_onkeypress_, false);
this.grab_events_ = false; this.grab_events_ = false;
VT100.the_vt_ = undefined; VT100.the_vt_ = undefined;
} }
@ -1340,19 +1337,18 @@ VT100.prototype.setupTouchInputFallback = function(){
this.form.appendChild(this.input) this.form.appendChild(this.input)
this.scr_.parentElement.appendChild(this.form) this.scr_.parentElement.appendChild(this.form)
this.input.addEventListener('blur', () => {
this.key_buf_.push('\n')
setTimeout(VT100.go_getch_, 0);
})
this.input.addEventListener("keydown", VT100.handle_onkeypress_, false); this.input.addEventListener("keydown", VT100.handle_onkeypress_, false);
this.input.handler = (e) => { this.input.handler = (e) => {
let ch let ch
let isEnter = String(e?.code).toLowerCase() == "enter" || e?.code == 13 let isEnter = String(e?.code).toLowerCase() == "enter" || e?.code == 13
let isBackspace = String(e?.code).toLowerCase() == "backspace" || e?.code == 8 ch = isEnter ? '\n' : this.input.value.substr(-1)
if( isEnter ){ if( this.input.lastValue && this.input.value.length < this.input.lastValue.length ) ch = '\b' // naive
ch = '\n'
}else if( isBackspace ){
ch = '\b' // naive
}else{
ch = this.input.value.substr(-1)
}
// detect backspace // detect backspace
if( !ch ) return if( !ch ) return
this.key_buf_.push(ch); this.key_buf_.push(ch);
@ -1364,33 +1360,15 @@ VT100.prototype.setupTouchInputFallback = function(){
this.scr_.addEventListener('touchend', (e) => this.focus() ) this.scr_.addEventListener('touchend', (e) => this.focus() )
this.scr_.addEventListener('click', (e) => this.focus() ) this.scr_.addEventListener('click', (e) => this.focus() )
} }
this.useFallbackInput = true
this.focus() this.focus()
} }
VT100.prototype.focus = function(){ VT100.prototype.focus = function(){
setTimeout( () => { setTimeout( () => {
const el = this[ this.useFallbackInput ? 'input' : 'scr_' ] this.input.focus()
el.focus()
console.dir(el)
}, 10 ) }, 10 )
} }
window.keyboard = function(n){
let msg = 'unknown keyboard'
if( n == 0 ){
msg = "using onscreen keyboard"
VT100.the_vt_.useFallbackInput = true
VT100.the_vt_.focus()
}
if( n == 1 ){
msg = "using offscreen keyboard"
VT100.the_vt_.useFallbackInput = false
VT100.the_vt_.focus()
}
return msg
}
function dump(x) { function dump(x) {
// Do nothing // Do nothing
console.log(x) console.log(x)