diff --git a/lib/widget.js b/lib/widget.js index f33b7b1..ba9c188 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -7146,7 +7146,7 @@ function Table(options) { // Regular tables do not get custom height (this would // require extra padding). Maybe add in the future. - delete options.height; + // delete options.height; Box.call(this, options); @@ -7288,7 +7288,8 @@ Table.prototype.render = function() { , yl = coords.yl , rx , ry - , i; + , i + , over; var dattr = this.sattr(this.style) , hattr = this.sattr(this.style.header) @@ -7382,13 +7383,15 @@ Table.prototype.render = function() { } // Draw internal borders. - for (ry = 1; ry < self.rows.length * 2; ry++) { + height = this.position.height != null ? this.height : this.rows.length * 2; + for (ry = 1; ry < height; ry++) { if (!lines[yi + ry]) break; + over = this.position.height != null && ry >= this.rows.length * 2; rx = 0; self._maxes.slice(0, -1).forEach(function(max, i) { rx += max; if (!lines[yi + ry][xi + rx + 1]) return; - if (ry % 2 !== 0) { + if (ry % 2 !== 0 || over) { if (self.options.fillCellBorders) { var lbg = (ry <= 2 ? hattr : cattr) & 0x1ff; lines[yi + ry][xi + ++rx][0] = (battr & ~0x1ff) | lbg; @@ -7403,7 +7406,7 @@ Table.prototype.render = function() { rx = 1; self._maxes.forEach(function(max, i) { while (max--) { - if (ry % 2 === 0) { + if (ry % 2 === 0 && !over) { if (!lines[yi + ry]) break; if (!lines[yi + ry][xi + rx + 1]) break; if (self.options.fillCellBorders) { @@ -7420,6 +7423,18 @@ Table.prototype.render = function() { }); } + // Keep drawing if we have a higher height. + rx = 0; + if (over) { + ry = height - 1; + self._maxes.slice(0, -1).forEach(function(max, i) { + rx += max; + if (!lines[yi + ry][xi + rx + 1]) return; + lines[yi + ry][xi + ++rx][0] = battr; + lines[yi + ry][xi + rx][1] = '\u2534'; // '┴' + }); + } + return coords; };