potentially allow newlines in text content.

This commit is contained in:
Christopher Jeffrey 2013-06-06 04:33:10 -05:00
parent ed2b9ae4d0
commit d0473749c9

View File

@ -197,6 +197,7 @@ Screen.prototype.alloc = function() {
this.lines[y] = [];
for (x = 0; x < this.cols; x++) {
this.lines[y][x] = [this.dattr, ' '];
//this.lines[y][x].dirty = true;
}
this.lines[y].dirty = true;
}
@ -600,10 +601,9 @@ Box.prototype.render = function() {
// Scroll the content
if (this.childBase != null) {
var cb = this.childBase
, xx;
while (cb--) {
for (xx = this.left; xx < xl; xx++) ci++;
}
, xxl = xl - (this.border ? 1 : 0)
, xxi;
while (cb--) for (xxi = xi + (this.border ? 1 : 0); xxi < xxl; xxi++) ci++;
}
var ret = {
@ -614,10 +614,10 @@ Box.prototype.render = function() {
};
for (; yi < yl; yi++) {
if (!lines[yi]) continue;
if (!lines[yi]) break;
for (xi = this.left; xi < xl; xi++) {
cell = lines[yi][xi];
if (!cell) continue;
if (!cell) break;
if (this.border && (yi === this.top || xi === this.left || yi === yl - 1 || xi === xl - 1)) {
attr = ((this.border.bold << 18) + (this.border.underline << 18)) | (this.border.fg << 9) | this.border.bg;
if (this.border.type === 'ascii') {
@ -639,10 +639,28 @@ Box.prototype.render = function() {
attr = ((this.bold << 18) + (this.underline << 18)) | (this.fg << 9) | this.bg;
ch = this.content[ci++] || ' ';
}
// TODO: Allow newlines.
//if (ch === '\n' || ch === '\r') {
// ch = ' ';
// xl = xl - 1 - (this.border ? 1 : 0);
// for (; xi < xl; xi++) {
// cell = lines[yi][xi];
// if (!cell) break;
// if (attr !== cell[0] || ch !== cell[1]) {
// lines[yi][xi][0] = attr;
// lines[yi][xi][1] = ch;
// lines[yi].dirty = true;
// //lines[yi][xi].dirty = true;
// }
// }
//}
if (attr !== cell[0] || ch !== cell[1]) {
lines[yi][xi][0] = attr;
lines[yi][xi][1] = ch;
lines[yi].dirty = true;
//lines[yi][xi].dirty = true;
}
}
}
@ -716,8 +734,10 @@ Text.prototype.render = function() {
var dattr = ((this.bold << 18) + (this.underline << 18)) | (this.fg << 9) | this.bg;
for (; yi < yl; yi++) {
if (!lines[yi]) break;
for (xi = this.left; xi < xl; xi++) {
cell = lines[yi][xi];
if (!cell) break;
attr = dattr;
ch = this.content[ci++];
if (!ch) {
@ -732,10 +752,28 @@ Text.prototype.render = function() {
break;
}
}
// TODO: Allow newlines.
//if (ch === '\n' || ch === '\r') {
// ch = ' ';
// xl = xl - 1 - (this.border ? 1 : 0);
// for (; xi < xl; xi++) {
// cell = lines[yi][xi];
// if (!cell) break;
// if (attr !== cell[0] || ch !== cell[1]) {
// lines[yi][xi][0] = attr;
// lines[yi][xi][1] = ch;
// lines[yi].dirty = true;
// //lines[yi][xi].dirty = true;
// }
// }
//}
if (attr !== cell[0] || ch !== cell[1]) {
lines[yi][xi][0] = attr;
lines[yi][xi][1] = ch;
lines[yi].dirty = true;
//lines[yi][xi].dirty = true;
}
}
}
@ -1038,16 +1076,17 @@ ProgressBar.prototype.render = function() {
var dattr = ((this.bold << 18) + (this.underline << 18)) | (this.barFg << 9) | this.barBg;
for (y = yi; y < yl; y++) {
if (!lines[y]) continue;
if (!lines[y]) break;
for (x = xi; x < xl; x++) {
attr = dattr;
ch = this.ch;
cell = lines[y][x];
if (!cell) continue;
if (!cell) break;
if (attr !== cell[0] || ch !== cell[1]) {
lines[y][x][0] = attr;
lines[y][x][1] = ch;
lines[y].dirty = true;
//lines[y][x].dirty = true;
}
}
}