(clear: boolean)
| 1306 | |
| 1307 | // Helper to clear scrollback and viewport and render all new lines |
| 1308 | const fullRender = (clear: boolean): void => { |
| 1309 | this.fullRedrawCount += 1; |
| 1310 | let buffer = "\x1b[?2026h"; // Begin synchronized output |
| 1311 | if (clear) { |
| 1312 | buffer += this.deleteKittyImages(this.previousKittyImageIds); |
| 1313 | buffer += "\x1b[2J\x1b[H\x1b[3J"; // Clear screen, home, then clear scrollback |
| 1314 | } |
| 1315 | for (let i = 0; i < newLines.length; i++) { |
| 1316 | if (i > 0) buffer += "\r\n"; |
| 1317 | const line = newLines[i]!; |
| 1318 | const isImage = isImageLine(line); |
| 1319 | const imageReservedRows = isImage ? this.getKittyImageReservedRows(newLines, i) : 1; |
| 1320 | if (imageReservedRows > 1 && imageReservedRows <= height) { |
| 1321 | for (let row = 1; row < imageReservedRows; row++) { |
| 1322 | buffer += "\r\n"; |
| 1323 | } |
| 1324 | buffer += `\x1b[${imageReservedRows - 1}A`; |
| 1325 | buffer += line; |
| 1326 | buffer += `\x1b[${imageReservedRows - 1}B`; |
| 1327 | i += imageReservedRows - 1; |
| 1328 | continue; |
| 1329 | } |
| 1330 | buffer += line; |
| 1331 | } |
| 1332 | buffer += "\x1b[?2026l"; // End synchronized output |
| 1333 | this.terminal.write(buffer); |
| 1334 | this.cursorRow = Math.max(0, newLines.length - 1); |
| 1335 | this.hardwareCursorRow = this.cursorRow; |
| 1336 | // Reset max lines when clearing, otherwise track growth |
| 1337 | if (clear) { |
| 1338 | this.maxLinesRendered = newLines.length; |
| 1339 | } else { |
| 1340 | this.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length); |
| 1341 | } |
| 1342 | const bufferLength = Math.max(height, newLines.length); |
| 1343 | this.previousViewportTop = Math.max(0, bufferLength - height); |
| 1344 | this.positionHardwareCursor(cursorPos, newLines.length, this.previousViewportTop, height); |
| 1345 | this.previousLines = newLines; |
| 1346 | this.previousKittyImageIds = this.collectKittyImageIds(newLines); |
| 1347 | this.previousWidth = width; |
| 1348 | this.previousHeight = height; |
| 1349 | }; |
| 1350 | |
| 1351 | const debugRedraw = process.env['PI_DEBUG_REDRAW'] === "1"; |
| 1352 | const logRedraw = (reason: string): void => { |
nothing calls this directly
no test coverage detected