From ffd98d0f8ea355bd09bc6842ca9f775d815e2377 Mon Sep 17 00:00:00 2001 From: John Spackman Date: Mon, 12 Aug 2013 14:12:18 +0100 Subject: [PATCH] Added a background fill character to Element This is used to fill the background of the element, EG for text area I typically set this to '_' to show the extent of the field --- lib/widget.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index d5b392f..4de4174 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -1756,6 +1756,7 @@ function Element(options) { this.wrap = options.wrap !== false; this.shrink = options.shrink; this.fixed = options.fixed; + this.bgChar = options.bgChar || ' '; if (typeof options.padding === 'number' || !options.padding) { options.padding = { @@ -2987,7 +2988,8 @@ Element.prototype.render = function() { , c , rtop , visible - , i; + , i + , bgChar = this.bgChar; if (coords.base >= this._clines.ci.length) { ci = this._pcontent.length; @@ -3040,7 +3042,7 @@ Element.prototype.render = function() { cell = lines[y][x]; if (!cell) break; - ch = content[ci++] || ' '; + ch = content[ci++] || bgChar; // Handle escape codes. while (ch === '\x1b') { @@ -3052,7 +3054,7 @@ Element.prototype.render = function() { && this.parent.items[this.parent.selected] === this) { attr = (attr & ~(0x1ff << 9)) | (dattr & (0x1ff << 9)); } - ch = content[ci] || ' '; + ch = content[ci] || bgChar; ci++; } else { break; @@ -3071,7 +3073,7 @@ Element.prototype.render = function() { } // We could use fillRegion here, name the // outer loop, and continue to it instead. - ch = ' '; + ch = bgChar; for (; x < xl; x++) { cell = lines[y][x]; if (!cell) break;