Merge pull request #12 from johnspackman/element-bg-char

Added a background fill character to Element
This commit is contained in:
Christopher Jeffrey 2013-08-12 06:50:19 -07:00
commit 4b6cf96030
1 changed files with 6 additions and 4 deletions

View File

@ -1767,6 +1767,7 @@ function Element(options) {
this.wrap = options.wrap !== false; this.wrap = options.wrap !== false;
this.shrink = options.shrink; this.shrink = options.shrink;
this.fixed = options.fixed; this.fixed = options.fixed;
this.bgChar = options.bgChar || ' ';
if (typeof options.padding === 'number' || !options.padding) { if (typeof options.padding === 'number' || !options.padding) {
options.padding = { options.padding = {
@ -2998,7 +2999,8 @@ Element.prototype.render = function() {
, c , c
, rtop , rtop
, visible , visible
, i; , i
, bgChar = this.bgChar;
if (coords.base >= this._clines.ci.length) { if (coords.base >= this._clines.ci.length) {
ci = this._pcontent.length; ci = this._pcontent.length;
@ -3051,7 +3053,7 @@ Element.prototype.render = function() {
cell = lines[y][x]; cell = lines[y][x];
if (!cell) break; if (!cell) break;
ch = content[ci++] || ' '; ch = content[ci++] || bgChar;
// Handle escape codes. // Handle escape codes.
while (ch === '\x1b') { while (ch === '\x1b') {
@ -3063,7 +3065,7 @@ Element.prototype.render = function() {
&& this.parent.items[this.parent.selected] === this) { && this.parent.items[this.parent.selected] === this) {
attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9)); attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9));
} }
ch = content[ci] || ' '; ch = content[ci] || bgChar;
ci++; ci++;
} else { } else {
break; break;
@ -3082,7 +3084,7 @@ Element.prototype.render = function() {
} }
// We could use fillRegion here, name the // We could use fillRegion here, name the
// outer loop, and continue to it instead. // outer loop, and continue to it instead.
ch = ' '; ch = bgChar;
for (; x < xl; x++) { for (; x < xl; x++) {
cell = lines[y][x]; cell = lines[y][x];
if (!cell) break; if (!cell) break;