From 4943abb354e2685296991aab2903706510b5dc4f Mon Sep 17 00:00:00 2001 From: cpsdqs Date: Sat, 30 Sep 2017 09:35:26 +0200 Subject: [PATCH] Prevent unnecessary full screen redraws --- js/term/screen.js | 10 ++++++---- js/term/screen_renderer.js | 13 +++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/js/term/screen.js b/js/term/screen.js index 8cb0161..3fbd187 100644 --- a/js/term/screen.js +++ b/js/term/screen.js @@ -103,10 +103,12 @@ module.exports = class TermScreen extends EventEmitter { const self = this this.window = new Proxy(this._window, { set (target, key, value, receiver) { - target[key] = value - self.scheduleSizeUpdate() - self.renderer.scheduleDraw(`window:${key}=${value}`) - self.emit(`update-window:${key}`, value) + if (target[key] !== value) { + target[key] = value + self.scheduleSizeUpdate() + self.renderer.scheduleDraw(`window:${key}=${value}`) + self.emit(`update-window:${key}`, value) + } return true } }) diff --git a/js/term/screen_renderer.js b/js/term/screen_renderer.js index ed361be..6980169 100644 --- a/js/term/screen_renderer.js +++ b/js/term/screen_renderer.js @@ -52,6 +52,9 @@ module.exports = class ScreenRenderer { resetDrawn () { // used to determine if a cell should be redrawn; storing the current state // as it is on screen + if (this.screen.window && this.screen.window.debug) { + console.log('Resetting drawn screen') + } this.drawnScreen = [] this.drawnScreenFG = [] this.drawnScreenBG = [] @@ -81,10 +84,12 @@ module.exports = class ScreenRenderer { } setDefaultColors (fg, bg) { - this.defaultFgNum = fg - this.defaultBgNum = bg - this.resetDrawn() - this.scheduleDraw('defaultColors') + if (fg !== this.defaultFgNum || bg !== this.defaultBgNum) { + this.resetDrawn() + this.defaultFgNum = fg + this.defaultBgNum = bg + this.scheduleDraw('default-colors') + } } /**