update files

This commit is contained in:
nuintun 2015-12-03 14:18:47 +08:00
parent 82f178d728
commit c8b7de1fce
3 changed files with 17 additions and 3 deletions

View File

@ -68,6 +68,8 @@
console.log('C + a: ', C + a);
console.log('Ca: ', context.measureText('Ca').width);
canvas.style.backgroundColor = 'transparent';
var xterm = new AnsiTerminal(120, 80, 0);
xterm.debug = false;
@ -89,7 +91,7 @@
write();
var canvasXTerm = new CanvasXTerm();
canvasXTerm.draw(xterm.stylesBuffer);
console.log(canvasXTerm.canvas);

View File

@ -15,7 +15,7 @@ function textRepeat(text, n){
function CanvasXTerm(font){
this.font = font || { family: 'Consolas', lineHeight: 20, size: 13, color: '#fff' };
this.canvas = document.createElement('canvas');
this.canvas.backgroundAlpha = 0;
this.canvas.style.backgroundColor = 'transparent';
this.brush = this.canvas.getContext('2d');
this.brush.font = this.font + ' ' + this.fontSize;
this.brush.fillStyle = this.font.color;
@ -23,8 +23,11 @@ function CanvasXTerm(font){
CanvasXTerm.prototype = {
draw: function (screen){
var text = '';
var i, j, x, y, attrCache;
var rows = screen.length;
var cols = rows ? screen[0].length : 0;
var baseY = (this.font.lineHeight + this.font.size) / 2;
if (!this.rows || !this.cols || this.rows !== rows || this.cols !== cols) {
this.rows = rows;
@ -39,6 +42,15 @@ CanvasXTerm.prototype = {
this.canvas.height = rows * this.font.lineHeight;
}
for (i = 0; i < rows; i++) {
x = 0;
y = i * 20 + baseY;
for (j = 0; j < rows; j++) {
}
}
},
measureWidth: function (text, styles){
this.brush.save();

View File

@ -1032,8 +1032,8 @@ AnsiTerminal.prototype.toString = function (type){
if (type === 'html') {
var line = '';
var style = '';
var styleBuffer;
var attrCache;
var styleBuffer;
var stylesBuffer = this.stylesBuffer || [];
stylesBuffer = stylesBuffer.slice(0, rows);