diff --git a/lib/widget.js b/lib/widget.js index 6105635..e572305 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2073,11 +2073,29 @@ Box.prototype.render = function(stop) { if (this.border) yi_++, yl--, xi_++, xl--; + if (this.padding || this.options.valign) { + this.screen.fillRegion(dattr, ' ', xi_, xl, yi_, yl); + } + if (this.padding) { yi_ += this.padding, yl -= this.padding; xi_ += this.padding, xl -= this.padding; } + if (this.options.valign === 'middle' || this.options.valign === 'bottom') { + //visible = (yl - yi_) - (this.border ? 2 : 0) - this.padding; + visible = yl - yi_; + if (this._clines.length < visible) { + if (this.options.valign === 'middle') { + visible = visible / 2 | 0; + visible -= this._clines.length / 2 | 0; + } else if (this.options.valign === 'bottom') { + visible -= this._clines.length; + } + yi_ += visible; + } + } + outer: for (yi = yi_; yi < yl; yi++) { if (!lines[yi]) break; @@ -2171,6 +2189,7 @@ outer: xi_ -= this.padding, xl += this.padding; } +/* if (this.padding) { // Set padding to green for debugging: // dattr = (dattr & ~0x1ff) | colors.convert('green'); @@ -2199,6 +2218,7 @@ outer: yi_ + (this.border ? 1 : 0), yl - (this.border ? 1 : 0)); } +*/ if (this.border) { yi = yi_; diff --git a/test/widget-insert.js b/test/widget-insert.js index f459e7f..ee8a438 100644 --- a/test/widget-insert.js +++ b/test/widget-insert.js @@ -11,7 +11,8 @@ var box = blessed.box({ height: 5, top: 'center', left: 0, - content: 'line 1' + content: 'line 1', + //valign: 'middle' }); screen.render();