MCPcopy Create free account
hub / github.com/cli-table/cli-table3 / drawLine

Method drawLine

src/cell.js:242–263  ·  view source on GitHub ↗

* Renders a line of text. * @param lineNum - Which line of text to render. This is not necessarily the line within the cell. * There may be top-padding above the first line of text. * @param drawRight - true if this method should render the right edge of the cell. * @param forceTruncatio

(lineNum, drawRight, forceTruncationSymbol, spanningCell)

Source from the content-addressed store, hash-verified

240 * @returns {String}
241 */
242 drawLine(lineNum, drawRight, forceTruncationSymbol, spanningCell) {
243 let left = this.chars[this.x == 0 ? 'left' : 'middle'];
244 if (this.x && spanningCell && this.cells) {
245 let cellLeft = this.cells[this.y + spanningCell][this.x - 1];
246 while (cellLeft instanceof ColSpanCell) {
247 cellLeft = this.cells[cellLeft.y][cellLeft.x - 1];
248 }
249 if (!(cellLeft instanceof RowSpanCell)) {
250 left = this.chars['rightMid'];
251 }
252 }
253 let leftPadding = utils.repeat(' ', this.paddingLeft);
254 let right = drawRight ? this.chars['right'] : '';
255 let rightPadding = utils.repeat(' ', this.paddingRight);
256 let line = this.lines[lineNum];
257 let len = this.width - (this.paddingLeft + this.paddingRight);
258 if (forceTruncationSymbol) line += this.truncate || '…';
259 let content = utils.truncate(line, len, this.truncate);
260 content = utils.pad(content, len, ' ', this.hAlign);
261 content = leftPadding + content + rightPadding;
262 return this.stylizeLine(left, content, right);
263 }
264
265 stylizeLine(left, content, right) {
266 left = this.wrapWithStyleColors('border', left);

Callers 1

drawMethod · 0.95

Calls 1

stylizeLineMethod · 0.95

Tested by

no test coverage detected