From b18bcec73dad0372bd9115e5f56ae43c0f6b418b Mon Sep 17 00:00:00 2001 From: nuintun Date: Fri, 4 Dec 2015 16:56:00 +0800 Subject: [PATCH] update files --- static/js/terminal/canvas-xterm.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/static/js/terminal/canvas-xterm.js b/static/js/terminal/canvas-xterm.js index d4fffba..d476f60 100644 --- a/static/js/terminal/canvas-xterm.js +++ b/static/js/terminal/canvas-xterm.js @@ -78,6 +78,7 @@ CanvasXTerm.prototype = { var context = this; var rows = screen.rows; var cols = screen.cols; + var lineCache = null; var attrCache = null; var stylesCache = null; var width, height; @@ -120,10 +121,10 @@ CanvasXTerm.prototype = { x = 0; y = i * this.font.lineHeight; - line = this.lru.get(line.id); + lineCache = this.lru.get(line.id); - if (line && line.version === screen.buffer[i].version) { - this.brush.drawImage(line.canvas, 0, y, line.canvas.width, line.canvas.height); + if (lineCache && lineCache.version === line.version) { + this.brush.drawImage(lineCache.canvas, 0, y, lineCache.canvas.width, lineCache.canvas.height); continue; } @@ -134,7 +135,7 @@ CanvasXTerm.prototype = { brush = canvas.getContext('2d'); for (j = 0; j < cols; j++) { - node = screen.buffer[i].cells[j]; + node = line.cells[j]; if (!node) { continue; @@ -160,9 +161,11 @@ CanvasXTerm.prototype = { } this.brush.drawImage(canvas, 0, y, canvas.width, canvas.height); - this.lru.set(screen.buffer[i].id, { + + // cache line + this.lru.set(line.id, { canvas: canvas, - version: screen.buffer[i].version + version: line.version }); } },