mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-09 09:34:47 +00:00
potentially allow newlines in text content.
This commit is contained in:
parent
ed2b9ae4d0
commit
d0473749c9
@ -197,6 +197,7 @@ Screen.prototype.alloc = function() {
|
|||||||
this.lines[y] = [];
|
this.lines[y] = [];
|
||||||
for (x = 0; x < this.cols; x++) {
|
for (x = 0; x < this.cols; x++) {
|
||||||
this.lines[y][x] = [this.dattr, ' '];
|
this.lines[y][x] = [this.dattr, ' '];
|
||||||
|
//this.lines[y][x].dirty = true;
|
||||||
}
|
}
|
||||||
this.lines[y].dirty = true;
|
this.lines[y].dirty = true;
|
||||||
}
|
}
|
||||||
@ -600,10 +601,9 @@ Box.prototype.render = function() {
|
|||||||
// Scroll the content
|
// Scroll the content
|
||||||
if (this.childBase != null) {
|
if (this.childBase != null) {
|
||||||
var cb = this.childBase
|
var cb = this.childBase
|
||||||
, xx;
|
, xxl = xl - (this.border ? 1 : 0)
|
||||||
while (cb--) {
|
, xxi;
|
||||||
for (xx = this.left; xx < xl; xx++) ci++;
|
while (cb--) for (xxi = xi + (this.border ? 1 : 0); xxi < xxl; xxi++) ci++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ret = {
|
var ret = {
|
||||||
@ -614,10 +614,10 @@ Box.prototype.render = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (; yi < yl; yi++) {
|
for (; yi < yl; yi++) {
|
||||||
if (!lines[yi]) continue;
|
if (!lines[yi]) break;
|
||||||
for (xi = this.left; xi < xl; xi++) {
|
for (xi = this.left; xi < xl; xi++) {
|
||||||
cell = lines[yi][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)) {
|
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;
|
attr = ((this.border.bold << 18) + (this.border.underline << 18)) | (this.border.fg << 9) | this.border.bg;
|
||||||
if (this.border.type === 'ascii') {
|
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;
|
attr = ((this.bold << 18) + (this.underline << 18)) | (this.fg << 9) | this.bg;
|
||||||
ch = this.content[ci++] || ' ';
|
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]) {
|
if (attr !== cell[0] || ch !== cell[1]) {
|
||||||
lines[yi][xi][0] = attr;
|
lines[yi][xi][0] = attr;
|
||||||
lines[yi][xi][1] = ch;
|
lines[yi][xi][1] = ch;
|
||||||
lines[yi].dirty = true;
|
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;
|
var dattr = ((this.bold << 18) + (this.underline << 18)) | (this.fg << 9) | this.bg;
|
||||||
|
|
||||||
for (; yi < yl; yi++) {
|
for (; yi < yl; yi++) {
|
||||||
|
if (!lines[yi]) break;
|
||||||
for (xi = this.left; xi < xl; xi++) {
|
for (xi = this.left; xi < xl; xi++) {
|
||||||
cell = lines[yi][xi];
|
cell = lines[yi][xi];
|
||||||
|
if (!cell) break;
|
||||||
attr = dattr;
|
attr = dattr;
|
||||||
ch = this.content[ci++];
|
ch = this.content[ci++];
|
||||||
if (!ch) {
|
if (!ch) {
|
||||||
@ -732,10 +752,28 @@ Text.prototype.render = function() {
|
|||||||
break;
|
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]) {
|
if (attr !== cell[0] || ch !== cell[1]) {
|
||||||
lines[yi][xi][0] = attr;
|
lines[yi][xi][0] = attr;
|
||||||
lines[yi][xi][1] = ch;
|
lines[yi][xi][1] = ch;
|
||||||
lines[yi].dirty = true;
|
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;
|
var dattr = ((this.bold << 18) + (this.underline << 18)) | (this.barFg << 9) | this.barBg;
|
||||||
|
|
||||||
for (y = yi; y < yl; y++) {
|
for (y = yi; y < yl; y++) {
|
||||||
if (!lines[y]) continue;
|
if (!lines[y]) break;
|
||||||
for (x = xi; x < xl; x++) {
|
for (x = xi; x < xl; x++) {
|
||||||
attr = dattr;
|
attr = dattr;
|
||||||
ch = this.ch;
|
ch = this.ch;
|
||||||
cell = lines[y][x];
|
cell = lines[y][x];
|
||||||
if (!cell) continue;
|
if (!cell) break;
|
||||||
if (attr !== cell[0] || ch !== cell[1]) {
|
if (attr !== cell[0] || ch !== cell[1]) {
|
||||||
lines[y][x][0] = attr;
|
lines[y][x][0] = attr;
|
||||||
lines[y][x][1] = ch;
|
lines[y][x][1] = ch;
|
||||||
lines[y].dirty = true;
|
lines[y].dirty = true;
|
||||||
|
//lines[y][x].dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user