diff --git a/js/term/index.js b/js/term/index.js index f8155a9..99c885c 100644 --- a/js/term/index.js +++ b/js/term/index.js @@ -51,26 +51,29 @@ module.exports = function (opts) { const buttons = initButtons(input) screen.on('button-labels', labels => { buttons.labels = labels }) - // TEMPORARY CODE - screen.on('TEMP:hide-load-failed-msg', () => { + screen.on('full-load', () => { let scr = qs('#screen') let errmsg = qs('#load-failed') if (scr) scr.classList.remove('failed') if (errmsg) errmsg.parentNode.removeChild(errmsg) }) - screen.on('TEMP:show-config-links', show => { + let setLinkVisibility = visible => { let buttons = [...document.querySelectorAll('.x-term-conf-btn')] - if (show) buttons.forEach(x => x.classList.remove('hidden')) + if (visible) buttons.forEach(x => x.classList.remove('hidden')) else buttons.forEach(x => x.classList.add('hidden')) - }) - - screen.on('TEMP:show-buttons', show => { - if (show) qs('#action-buttons').classList.remove('hidden') + } + let setButtonVisibility = visible => { + if (visible) qs('#action-buttons').classList.remove('hidden') else qs('#action-buttons').classList.add('hidden') + } + + screen.on('opts-update', () => { + setLinkVisibility(screen.showLinks) + setButtonVisibility(screen.showButtons) }) - screen.on('TEMP:update-title', text => { + screen.on('title-update', text => { qs('#screen-title').textContent = text if (!text) text = 'Terminal' qs('title').textContent = `${text} :: ESPTerm` diff --git a/js/term/screen.js b/js/term/screen.js index e1aa454..86e67af 100644 --- a/js/term/screen.js +++ b/js/term/screen.js @@ -78,6 +78,10 @@ module.exports = class TermScreen extends EventEmitter { // mouse features this.mouseMode = { clicks: false, movement: false } + this.showLinks = false + this.showButtons = false + this.title = '' + this.bracketedPaste = false this.blinkingCellCount = 0 this.reverseVideo = false @@ -466,8 +470,9 @@ module.exports = class TermScreen extends EventEmitter { this.window.debug &= 0b01 this.window.debug |= (+update.debugEnabled << 1) - this.emit('TEMP:show-buttons', update.showButtons) - this.emit('TEMP:show-links', update.showConfigLinks) + this.showLinks = update.showConfigLinks + this.showButtons = update.showButtons + this.emit('opts-update') break case 'cursor': @@ -482,7 +487,7 @@ module.exports = class TermScreen extends EventEmitter { break case 'title': - this.emit('TEMP:update-title', update.title) + this.emit('title-update', this.title = update.title) break case 'button-labels': @@ -533,7 +538,7 @@ module.exports = class TermScreen extends EventEmitter { break case 'full-load-complete': - this.emit('TEMP:hide-load-failed-msg') + this.emit('full-load') break case 'notification':