no such thing as inexplicable

- removed theme setting to 0 in demo constructor
- removed repeated theme setting in demo when not needed
- moved showPage() to a better place in demo to properly wait for load
box-drawing
Ondřej Hruška 7 years ago
parent e9aa3bfba6
commit a72c229ab3
  1. 2
      _debug_replacements.php
  2. 3
      js/term/connection.js
  3. 17
      js/term/demo.js

@ -90,7 +90,7 @@ return [
'uart_stopbits' => 1, 'uart_stopbits' => 1,
'uart_parity' => 2, 'uart_parity' => 2,
'theme' => 1, 'theme' => 0,
'pwlock' => 1, 'pwlock' => 1,
'access_name' => 'espterm', 'access_name' => 'espterm',
]; ];

@ -82,7 +82,7 @@ module.exports = class TermConnection extends EventEmitter {
default: default:
this.screen.load(evt.data) this.screen.load(evt.data)
if (!this.pageShown) { if (!this.pageShown) {
showPage() window.showPage()
this.pageShown = true this.pageShown = true
} }
break break
@ -139,7 +139,6 @@ module.exports = class TermConnection extends EventEmitter {
window.alert('Demoing non-demo build!') // this will catch mistakes when deploying to the website window.alert('Demoing non-demo build!') // this will catch mistakes when deploying to the website
} else { } else {
demo.init(this.screen) demo.init(this.screen)
showPage()
} }
return return
} }

@ -1,5 +1,6 @@
const EventEmitter = require('events') const EventEmitter = require('events')
const { encode2B, encode3B, parse2B } = require('../utils') const { encode2B, encode3B, parse2B } = require('../utils')
const { themes } = require('./themes')
class ANSIParser { class ANSIParser {
constructor (handler) { constructor (handler) {
@ -119,13 +120,15 @@ class ScrollingTerminal {
this.reset() this.reset()
this._lastLoad = Date.now() this._lastLoad = Date.now()
this.termScreen.load(this.serialize(), 0) this.termScreen.load(this.serialize())
window.showPage()
} }
reset () { reset () {
this.style = TERM_DEFAULT_STYLE this.style = TERM_DEFAULT_STYLE
this.cursor = { x: 0, y: 0, style: 1, visible: true } this.cursor = { x: 0, y: 0, style: 1, visible: true }
this.trackMouse = false this.trackMouse = false
this.theme = 0 this.theme = -1
this.rainbow = false this.rainbow = false
this.parser.reset() this.parser.reset()
this.clear() this.clear()
@ -291,6 +294,7 @@ class ScrollingTerminal {
clearTimeout(this._scheduledLoad) clearTimeout(this._scheduledLoad)
if (this._lastLoad < Date.now() - TERM_MIN_DRAW_DELAY) { if (this._lastLoad < Date.now() - TERM_MIN_DRAW_DELAY) {
this.termScreen.load(this.serialize(), this.theme) this.termScreen.load(this.serialize(), this.theme)
this.theme = -1 // prevent useless theme setting next time
} else { } else {
this._scheduledLoad = setTimeout(() => { this._scheduledLoad = setTimeout(() => {
this.termScreen.load(this.serialize()) this.termScreen.load(this.serialize())
@ -441,7 +445,7 @@ let demoshIndex = {
let drawCell = (x, y) => { let drawCell = (x, y) => {
moveTo(x, y) moveTo(x, y)
if (splash[y][x] === '@') { if (splash[y][x] === '@') {
this.emit('write', '\x1b[48;5;8m\x1b[38;5;255m▄\b') this.emit('write', '\x1b[48;5;238m\x1b[38;5;255m▄\b')
} else { } else {
let level = 231 + levels[splash[y][x]] let level = 231 + levels[splash[y][x]]
let character = characters[splash[y][x]] let character = characters[splash[y][x]]
@ -548,9 +552,10 @@ let demoshIndex = {
this.shell = shell this.shell = shell
} }
run (...args) { run (...args) {
let theme = args[0] | 0 let theme = +args[0] | 0
if (!args.length || !Number.isFinite(theme) || theme < 0 || theme > 5) { const maxnum = themes.length
this.emit('write', '\x1b[31mUsage: theme [0–5]\r\n') if (!args.length || !Number.isFinite(theme) || theme < 0 || theme >= maxnum) {
this.emit('write', `\x1b[31mUsage: theme [0–${maxnum-1}]\r\n`)
this.destroy() this.destroy()
return return
} }

Loading…
Cancel
Save