add valign. simpler way of rendering padding bg.
This commit is contained in:
parent
c8c0d1f269
commit
1561bdef7d
|
@ -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_;
|
||||
|
|
|
@ -11,7 +11,8 @@ var box = blessed.box({
|
|||
height: 5,
|
||||
top: 'center',
|
||||
left: 0,
|
||||
content: 'line 1'
|
||||
content: 'line 1',
|
||||
//valign: 'middle'
|
||||
});
|
||||
|
||||
screen.render();
|
||||
|
|
Loading…
Reference in New Issue