| 23 | * for the focused input widget. |
| 24 | */ |
| 25 | export function renderToDrawlist(params: RenderToDrawlistParams): void { |
| 26 | const theme = params.theme ?? defaultTheme; |
| 27 | const tick = |
| 28 | typeof params.tick === "number" && Number.isFinite(params.tick) && params.tick >= 0 |
| 29 | ? Math.trunc(params.tick) |
| 30 | : 0; |
| 31 | // Clear the framebuffer each frame to a deterministic base style so terminals |
| 32 | // with non-black defaults don't leak through when the UI doesn't explicitly |
| 33 | // paint every cell. |
| 34 | params.builder.clearTo(params.viewport.cols, params.viewport.rows, DEFAULT_BASE_STYLE); |
| 35 | |
| 36 | const layoutIndex = params.layoutIndex ?? indexLayoutRects(params.layout, params.tree); |
| 37 | const idRectIndex = params.idRectIndex ?? indexIdRects(params.tree, layoutIndex); |
| 38 | |
| 39 | /* Deterministic order: traverse the committed instance tree. */ |
| 40 | const resolvedCursor = renderTree( |
| 41 | params.builder, |
| 42 | params.focusState, |
| 43 | params.layout, |
| 44 | idRectIndex, |
| 45 | params.viewport, |
| 46 | theme, |
| 47 | tick, |
| 48 | DEFAULT_BASE_STYLE, |
| 49 | params.tree, |
| 50 | params.animatedRectByInstanceId, |
| 51 | params.animatedOpacityByInstanceId, |
| 52 | params.cursorInfo, |
| 53 | params.virtualListStore, |
| 54 | params.tableStore, |
| 55 | params.treeStore, |
| 56 | params.loadedTreeChildrenById, |
| 57 | params.commandPaletteItemsById, |
| 58 | params.commandPaletteLoadingById, |
| 59 | params.toolApprovalFocusedActionById, |
| 60 | params.dropdownSelectedIndexById, |
| 61 | params.dropdownWindowStartById, |
| 62 | params.diffViewerFocusedHunkById, |
| 63 | params.diffViewerExpandedHunksById, |
| 64 | params.tableRenderCacheById, |
| 65 | params.logsConsoleRenderCacheById, |
| 66 | params.diffRenderCacheById, |
| 67 | params.codeEditorRenderCacheById, |
| 68 | params.focusAnnouncement, |
| 69 | undefined, |
| 70 | params.terminalProfile, |
| 71 | params.pressedId ?? null, |
| 72 | ); |
| 73 | |
| 74 | /* Cursor protocol: emit SET_CURSOR for focused input */ |
| 75 | if (resolvedCursor) { |
| 76 | params.builder.setCursor({ |
| 77 | x: resolvedCursor.x, |
| 78 | y: resolvedCursor.y, |
| 79 | shape: resolvedCursor.shape, |
| 80 | visible: true, |
| 81 | blink: resolvedCursor.blink, |
| 82 | }); |