MCPcopy Create free account
hub / github.com/Noumena-Network/code / renderFrameSlice

Function renderFrameSlice

src/ink/log-update.ts:1188–1494  ·  view source on GitHub ↗

* Render a slice of rows from the frame's screen. * Each row is rendered followed by a newline. Cursor ends at (0, endY).

(
  screen: VirtualScreen,
  frame: Frame,
  startY: number,
  endY: number,
  stylePool: StylePool,
  options?: RenderFrameSliceOptions,
)

Source from the content-addressed store, hash-verified

1186 * Each row is rendered followed by a newline. Cursor ends at (0, endY).
1187 */
1188function renderFrameSlice(
1189 screen: VirtualScreen,
1190 frame: Frame,
1191 startY: number,
1192 endY: number,
1193 stylePool: StylePool,
1194 options?: RenderFrameSliceOptions,
1195): VirtualScreen {
1196 const renderFrameSliceStart = performance.now()
1197 let currentStyleId = stylePool.none
1198 let currentHyperlink: Hyperlink = undefined
1199 // Track the styleId of the last rendered cell on this line (-1 if none).
1200 // Passed to visibleCellAtIndex to enable fg-only space optimization.
1201 let lastRenderedStyleId = -1
1202 let lastCoveredColumn = 0
1203
1204 const { width: screenWidth, cells, charPool, hyperlinkPool } = frame.screen
1205 let visibleCells = 0
1206 let skippedCells = 0
1207 let rowAdvanceBranchHits = 0
1208 let writeCellCalls = 0
1209 let writeCellSuccesses = 0
1210 let writeCellFailures = 0
1211 let visibleCellLookupDurationMs = 0
1212 let moveCursorDurationMs = 0
1213 let hyperlinkTransitionDurationMs = 0
1214 let styleTransitionDurationMs = 0
1215 let writeCellDurationMs = 0
1216 let bufferedStdoutRuns = 0
1217 let bufferedStdoutCells = 0
1218 let bufferedStdoutBytes = 0
1219 let bufferedGapFillCalls = 0
1220 let bufferedGapFillCells = 0
1221 const scratchCell: Cell = {
1222 char: ' ',
1223 styleId: stylePool.none,
1224 width: CellWidth.Narrow,
1225 hyperlink: undefined,
1226 }
1227 let bufferedStdout = ''
1228 let bufferedStdoutColumns = 0
1229
1230 const flushBufferedStdout = () => {
1231 if (bufferedStdoutColumns === 0) {
1232 return
1233 }
1234 screen.diff.push({ type: 'stdout', content: bufferedStdout })
1235 bufferedStdoutRuns += 1
1236 bufferedStdoutCells += bufferedStdoutColumns
1237 bufferedStdoutBytes += Buffer.byteLength(bufferedStdout)
1238 bufferedStdout = ''
1239 bufferedStdoutColumns = 0
1240 }
1241
1242 let index = startY * screenWidth
1243 for (let y = startY; y < endY; y += 1) {
1244 const rowContentEnd = frame.screen.contentEnd[y] ?? 0
1245 // Advance cursor to this row using LF (not CSI CUD / cursor-down).

Callers 3

renderMethod · 0.85

Calls 15

eraseToEndOfLineFunction · 0.85
visibleCellAtIndexIntoFunction · 0.85
flushBufferedStdoutFunction · 0.85
moveCursorToFunction · 0.85
transitionHyperlinkFunction · 0.85
transitionStyleFunction · 0.85
needsWidthCompensationFunction · 0.85
writeCellWithStyleStrFunction · 0.85
eraseToEndOfScreenFunction · 0.85

Tested by

no test coverage detected