(cells: Array<{
tokens?: Token[];
}>, isHeader: boolean)
| 186 | // Render a single row with potential multi-line cells |
| 187 | // Returns an array of strings, one per line of the row |
| 188 | function renderRowLines(cells: Array<{ |
| 189 | tokens?: Token[]; |
| 190 | }>, isHeader: boolean): string[] { |
| 191 | // Get wrapped lines for each cell (preserving ANSI formatting) |
| 192 | const cellLines = cells.map((cell, colIndex_1) => { |
| 193 | const formattedText = formatCell(cell.tokens); |
| 194 | const width = columnWidths[colIndex_1]!; |
| 195 | return wrapText(formattedText, width, { |
| 196 | hard: needsHardWrap |
| 197 | }); |
| 198 | }); |
| 199 | |
| 200 | // Find max number of lines in this row |
| 201 | const maxLines_0 = Math.max(...cellLines.map(lines => lines.length), 1); |
| 202 | |
| 203 | // Calculate vertical offset for each cell (to center vertically) |
| 204 | const verticalOffsets = cellLines.map(lines_0 => Math.floor((maxLines_0 - lines_0.length) / 2)); |
| 205 | |
| 206 | // Build each line of the row as a single string |
| 207 | const result: string[] = []; |
| 208 | for (let lineIdx = 0; lineIdx < maxLines_0; lineIdx++) { |
| 209 | let line = '│'; |
| 210 | for (let colIndex_2 = 0; colIndex_2 < cells.length; colIndex_2++) { |
| 211 | const lines_1 = cellLines[colIndex_2]!; |
| 212 | const offset = verticalOffsets[colIndex_2]!; |
| 213 | const contentLineIdx = lineIdx - offset; |
| 214 | const lineText = contentLineIdx >= 0 && contentLineIdx < lines_1.length ? lines_1[contentLineIdx]! : ''; |
| 215 | const width_0 = columnWidths[colIndex_2]!; |
| 216 | // Headers always centered; data uses table alignment |
| 217 | const align = isHeader ? 'center' : token.align?.[colIndex_2] ?? 'left'; |
| 218 | line += ' ' + padAligned(lineText, stringWidth(lineText), width_0, align) + ' │'; |
| 219 | } |
| 220 | result.push(line); |
| 221 | } |
| 222 | return result; |
| 223 | } |
| 224 | |
| 225 | // Render horizontal border as a single string |
| 226 | function renderBorderLine(type: 'top' | 'middle' | 'bottom'): string { |
no test coverage detected