do not redraw in blink timer if blinking is turned off

cpsdqs/unified-input
Ondřej Hruška 7 years ago
parent ab23d80799
commit 03637dd43e
  1. 25
      jssrc/term_screen.js

@ -143,7 +143,7 @@ class TermScreen {
set (target, key, value, receiver) { set (target, key, value, receiver) {
target[key] = value target[key] = value
self.scheduleSizeUpdate() self.scheduleSizeUpdate()
self.scheduleDraw() self.scheduleDraw('proxy')
return true return true
} }
}) })
@ -168,20 +168,20 @@ class TermScreen {
if (selecting) return if (selecting) return
selecting = true selecting = true
this.selection.start = this.selection.end = this.screenToGrid(x, y) this.selection.start = this.selection.end = this.screenToGrid(x, y)
this.scheduleDraw() this.scheduleDraw('ss')
} }
let selectMove = (x, y) => { let selectMove = (x, y) => {
if (!selecting) return if (!selecting) return
this.selection.end = this.screenToGrid(x, y) this.selection.end = this.screenToGrid(x, y)
this.scheduleDraw() this.scheduleDraw('sm')
} }
let selectEnd = (x, y) => { let selectEnd = (x, y) => {
if (!selecting) return if (!selecting) return
selecting = false selecting = false
this.selection.end = this.screenToGrid(x, y) this.selection.end = this.screenToGrid(x, y)
this.scheduleDraw() this.scheduleDraw('se')
Object.assign(this.selection, this.getNormalizedSelection()) Object.assign(this.selection, this.getNormalizedSelection())
} }
@ -274,7 +274,7 @@ class TermScreen {
// reset selection // reset selection
this.selection.start = this.selection.end = [0, 0] this.selection.start = this.selection.end = [0, 0]
qs('#touch-select-menu').classList.remove('open') qs('#touch-select-menu').classList.remove('open')
this.scheduleDraw() this.scheduleDraw('tap')
} else { } else {
e.preventDefault() e.preventDefault()
this.emit('open-soft-keyboard') this.emit('open-soft-keyboard')
@ -377,7 +377,7 @@ class TermScreen {
set palette (palette) { set palette (palette) {
this._palette = palette this._palette = palette
this.scheduleDraw() this.scheduleDraw('palette')
} }
getColor (i) { getColor (i) {
@ -411,9 +411,9 @@ class TermScreen {
} }
// schedule a draw in the next tick // schedule a draw in the next tick
scheduleDraw (aggregateTime = 1) { scheduleDraw (why, aggregateTime = 1) {
clearTimeout(this._scheduledDraw) clearTimeout(this._scheduledDraw)
this._scheduledDraw = setTimeout(() => this.draw(), aggregateTime) this._scheduledDraw = setTimeout(() => this.draw(why), aggregateTime)
} }
getFont (modifiers = {}) { getFont (modifiers = {}) {
@ -502,7 +502,7 @@ class TermScreen {
this.drawnScreenAttrs = [] this.drawnScreenAttrs = []
// draw immediately; the canvas shouldn't flash // draw immediately; the canvas shouldn't flash
this.draw() this.draw('init')
} }
} }
@ -513,7 +513,7 @@ class TermScreen {
this.cursor.blinkOn = this.cursor.blinking this.cursor.blinkOn = this.cursor.blinking
? !this.cursor.blinkOn ? !this.cursor.blinkOn
: true : true
this.scheduleDraw() if (this.cursor.blinking) this.scheduleDraw('blink')
}, 500) }, 500)
} }
@ -682,7 +682,7 @@ class TermScreen {
return cells.filter(cell => cell >= 0 && cell < screenLength) return cells.filter(cell => cell >= 0 && cell < screenLength)
} }
draw () { draw (why) {
const ctx = this.ctx const ctx = this.ctx
const { const {
width, width,
@ -704,6 +704,7 @@ class TermScreen {
// differentiate static cells from updated cells // differentiate static cells from updated cells
ctx.fillStyle = 'rgba(255, 0, 255, 0.3)' ctx.fillStyle = 'rgba(255, 0, 255, 0.3)'
ctx.fillRect(0, 0, screenWidth, screenHeight) ctx.fillRect(0, 0, screenWidth, screenHeight)
console.log(`draw: ${why}`)
} }
ctx.font = this.getFont() ctx.font = this.getFont()
@ -1035,7 +1036,7 @@ class TermScreen {
} }
} }
this.scheduleDraw(16) this.scheduleDraw('load', 16)
this.emit('load') this.emit('load')
} }

Loading…
Cancel
Save