Clean up and add a few comments

pull/1/head
cpsdqs 7 years ago
parent c3f6b4d851
commit a460b5fe89
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 10
      js/term/index.js
  2. 1
      js/term/input.js
  3. 5
      js/term/screen.js
  4. 4
      js/term/screen_parser.js
  5. 7
      js/term/screen_renderer.js

@ -18,6 +18,7 @@ module.exports = function (opts) {
const termUpload = TermUpload(conn, input, screen)
input.termUpload = termUpload
// forward screen input events
screen.on('mousedown', (...args) => input.onMouseDown(...args))
screen.on('mousemove', (...args) => input.onMouseMove(...args))
screen.on('mouseup', (...args) => input.onMouseUp(...args))
@ -25,6 +26,7 @@ module.exports = function (opts) {
screen.on('input-alts', (...args) => input.setAlts(...args))
screen.on('mouse-mode', (...args) => input.setMouseMode(...args))
// touch selection menu (the Copy button)
$.ready(() => {
const touchSelectMenu = qs('#touch-select-menu')
screen.on('show-touch-select-menu', (x, y) => {
@ -40,14 +42,16 @@ module.exports = function (opts) {
const copyButton = qs('#touch-select-copy-btn')
if (copyButton) {
copyButton.addEventListener('click', () => {
this.copySelectionToClipboard()
screen.copySelectionToClipboard()
})
}
})
// buttons
const buttons = initButtons(input)
screen.on('button-labels', labels => { buttons.labels = labels })
// TEMPORARY CODE
screen.on('TEMP:hide-load-failed-msg', () => {
let scr = qs('#screen')
let errmsg = qs('#load-failed')
@ -72,6 +76,8 @@ module.exports = function (opts) {
qs('title').textContent = `${text} :: ESPTerm`
})
// connection status
let showSplashTimeout = null
let showSplash = (obj, delay = 250) => {
clearTimeout(showSplashTimeout)
@ -126,6 +132,8 @@ module.exports = function (opts) {
initSoftKeyboard(screen, input)
if (attachDebugger) attachDebugger(screen, conn)
// fullscreen mode
let fullscreenIcon = {} // dummy
let isFullscreen = false
let properFullscreen = false

@ -1,4 +1,3 @@
const $ = require('../lib/chibi')
const { encode2B } = require('../utils')
/**

@ -5,6 +5,9 @@ const ScreenParser = require('./screen_parser')
const ScreenRenderer = require('./screen_renderer')
const { ATTR_BLINK } = require('./screen_attr_bits')
/**
* A terminal screen.
*/
module.exports = class TermScreen extends EventEmitter {
constructor () {
super()
@ -709,7 +712,7 @@ module.exports = class TermScreen extends EventEmitter {
break
default:
console.log('Unhandled update', update)
console.warn('Unhandled update', update)
}
}
}

@ -18,6 +18,7 @@ const SEQ_SET_FG = 5
const SEQ_SET_BG = 6
const SEQ_SET_ATTR_0 = 7
// decode a number encoded as a unicode code point
function du (str) {
if (!str) return NaN
let num = str.codePointAt(0)
@ -51,6 +52,9 @@ const OPT_REVERSE_VIDEO = (1 << 14)
/* eslint-enable no-multi-spaces */
/**
* A parser for screen update messages
*/
module.exports = class ScreenParser {
constructor () {
// true if full content was loaded

@ -27,7 +27,10 @@ const frakturExceptions = {
'Z': '\u2128'
}
module.exports = class ScreenRenderer {
/**
* A terminal screen renderer, using canvas 2D
*/
module.exports = class CanvasRenderer {
constructor (screen) {
this.screen = screen
this.ctx = screen.ctx
@ -231,7 +234,7 @@ module.exports = class ScreenRenderer {
let overline = false
if (attrs & ATTR_FAINT) ctx.globalAlpha = 0.5
if (attrs & ATTR_UNDERLINE) underline = true
if (attrs & ATTR_FRAKTUR) text = ScreenRenderer.alphaToFraktur(text)
if (attrs & ATTR_FRAKTUR) text = CanvasRenderer.alphaToFraktur(text)
if (attrs & ATTR_STRIKE) strike = true
if (attrs & ATTR_OVERLINE) overline = true

Loading…
Cancel
Save