| 65 | } |
| 66 | |
| 67 | private renderFullFrame(frame: Frame): Diff { |
| 68 | const { screen } = frame |
| 69 | const lines: string[] = [] |
| 70 | let currentStyles: AnsiCode[] = [] |
| 71 | let currentHyperlink: Hyperlink = undefined |
| 72 | for (let y = 0; y < screen.height; y++) { |
| 73 | let line = '' |
| 74 | for (let x = 0; x < screen.width; x++) { |
| 75 | const cell = cellAt(screen, x, y) |
| 76 | if (cell && cell.width !== CellWidth.SpacerTail) { |
| 77 | // Handle hyperlink transitions |
| 78 | if (cell.hyperlink !== currentHyperlink) { |
| 79 | if (currentHyperlink !== undefined) { |
| 80 | line += LINK_END |
| 81 | } |
| 82 | if (cell.hyperlink !== undefined) { |
| 83 | line += oscLink(cell.hyperlink) |
| 84 | } |
| 85 | currentHyperlink = cell.hyperlink |
| 86 | } |
| 87 | const cellStyles = this.options.stylePool.get(cell.styleId) |
| 88 | const styleDiff = diffAnsiCodes(currentStyles, cellStyles) |
| 89 | if (styleDiff.length > 0) { |
| 90 | line += ansiCodesToString(styleDiff) |
| 91 | currentStyles = cellStyles |
| 92 | } |
| 93 | line += cell.char |
| 94 | } |
| 95 | } |
| 96 | // Close any open hyperlink before resetting styles |
| 97 | if (currentHyperlink !== undefined) { |
| 98 | line += LINK_END |
| 99 | currentHyperlink = undefined |
| 100 | } |
| 101 | // Reset styles at end of line so trimEnd doesn't leave dangling codes |
| 102 | const resetCodes = diffAnsiCodes(currentStyles, []) |
| 103 | if (resetCodes.length > 0) { |
| 104 | line += ansiCodesToString(resetCodes) |
| 105 | currentStyles = [] |
| 106 | } |
| 107 | lines.push(line.trimEnd()) |
| 108 | } |
| 109 | |
| 110 | if (lines.length === 0) { |
| 111 | return [] |
| 112 | } |
| 113 | return [{ type: 'stdout', content: lines.join('\n') }] |
| 114 | } |
| 115 | |
| 116 | private getRenderOpsForDone(prev: Frame): Diff { |
| 117 | this.state.previousOutput = '' |