* Draws the given line of the cell. * This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`. * @param lineNum - can be `top`, `bottom` or a numerical line number. * @param spanningCell - will be a number if being called from a RowSpanCell, and wil
(lineNum, spanningCell)
| 131 | * @returns {String} The representation of this line. |
| 132 | */ |
| 133 | draw(lineNum, spanningCell) { |
| 134 | if (lineNum == 'top') return this.drawTop(this.drawRight); |
| 135 | if (lineNum == 'bottom') return this.drawBottom(this.drawRight); |
| 136 | let content = utils.truncate(this.content, 10, this.truncate); |
| 137 | if (!lineNum) { |
| 138 | info(`${this.y}-${this.x}: ${this.rowSpan - lineNum}x${this.colSpan} Cell ${content}`); |
| 139 | } else { |
| 140 | // debug(`${lineNum}-${this.x}: 1x${this.colSpan} RowSpanCell ${content}`); |
| 141 | } |
| 142 | let padLen = Math.max(this.height - this.lines.length, 0); |
| 143 | let padTop; |
| 144 | switch (this.vAlign) { |
| 145 | case 'center': |
| 146 | padTop = Math.ceil(padLen / 2); |
| 147 | break; |
| 148 | case 'bottom': |
| 149 | padTop = padLen; |
| 150 | break; |
| 151 | default: |
| 152 | padTop = 0; |
| 153 | } |
| 154 | if (lineNum < padTop || lineNum >= padTop + this.lines.length) { |
| 155 | return this.drawEmpty(this.drawRight, spanningCell); |
| 156 | } |
| 157 | let forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height; |
| 158 | return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Renders the top line of the cell. |
no test coverage detected