From a2ae340e28b463d6b37f252cab2ad13c0cc063eb Mon Sep 17 00:00:00 2001 From: nuintun Date: Wed, 2 Dec 2015 12:57:31 +0800 Subject: [PATCH] update files --- canvas.html | 15 ++++++++++++++- static/js/terminal/index.js | 34 ++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/canvas.html b/canvas.html index a4c02dc..f527b5e 100644 --- a/canvas.html +++ b/canvas.html @@ -4,9 +4,17 @@ Title + +
\ No newline at end of file diff --git a/static/js/terminal/index.js b/static/js/terminal/index.js index c0338b5..24ab100 100644 --- a/static/js/terminal/index.js +++ b/static/js/terminal/index.js @@ -1030,6 +1030,7 @@ AnsiTerminal.prototype.toString = function (type){ var rows = this.screen.buffer.length; if (type === 'html') { + var style = ''; var styleBuffer; var attrCache; var stylesBuffer = this.stylesBuffer || []; @@ -1053,15 +1054,39 @@ AnsiTerminal.prototype.toString = function (type){ } if (j === 0) { - s += ''; + style = ''; attrCache = node.attr; + + if (styleBuffer.foreground) { + style += 'color:' + styleBuffer.foreground + ';'; + } + + if (styleBuffer.background) { + style += 'background-color:' + styleBuffer.background + ';'; + } + + if (styleBuffer.bold) { + style += 'font-weight:bold;'; + } + + if (styleBuffer.italic) { + style += 'font-style: italic;'; + } + + if (styleBuffer.underline) { + style += 'text-decoration: underline;'; + } + + s += ''; } else if (j === cols - 1) { s += ''; } if (node.value) { if (node.attr !== attrCache) { - s += ''; + s += ''; + + style = ''; attrCache = node.attr; } @@ -2687,10 +2712,7 @@ function styles(node){ var background = attributes.background; var styles = { wide: node.width === 2 }; - [ - 'bold', 'italic', 'underline', - 'blink', 'inverse', 'conceal' - ].forEach(function (key){ + ['bold', 'italic', 'underline', 'blink', 'conceal'].forEach(function (key){ styles[key] = attributes[key]; });