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

Function renderNodeToOutput

src/ink/render-node-to-output.ts:390–1245  ·  view source on GitHub ↗
(
  node: DOMElement,
  output: Output,
  {
    offsetX = 0,
    offsetY = 0,
    prevScreen,
    skipSelfBlit = false,
    inheritedBackgroundColor,
  }: {
    offsetX?: number
    offsetY?: number
    prevScreen: Screen | undefined
    // Force this node to descend instead of blitting its own rect, while
    // still passing prevScreen to children. Used for non-opaque absolute
    // overlays over a dirty clipped region: the overlay's full rect has
    // transparent gaps (stale underlying content in prevScreen), but its
    // opaque descendants' narrower rects are safe to blit.
    skipSelfBlit?: boolean
    inheritedBackgroundColor?: Color
  },
)

Source from the content-addressed store, hash-verified

388
389// After nodes are laid out, render each to output object, which later gets rendered to terminal
390function renderNodeToOutput(
391 node: DOMElement,
392 output: Output,
393 {
394 offsetX = 0,
395 offsetY = 0,
396 prevScreen,
397 skipSelfBlit = false,
398 inheritedBackgroundColor,
399 }: {
400 offsetX?: number
401 offsetY?: number
402 prevScreen: Screen | undefined
403 // Force this node to descend instead of blitting its own rect, while
404 // still passing prevScreen to children. Used for non-opaque absolute
405 // overlays over a dirty clipped region: the overlay's full rect has
406 // transparent gaps (stale underlying content in prevScreen), but its
407 // opaque descendants' narrower rects are safe to blit.
408 skipSelfBlit?: boolean
409 inheritedBackgroundColor?: Color
410 },
411): void {
412 const { yogaNode } = node
413
414 if (yogaNode) {
415 if (yogaNode.getDisplay() === LayoutDisplay.None) {
416 // Clear old position if node was visible before becoming hidden
417 if (node.dirty) {
418 const cached = nodeCache.get(node)
419 if (cached) {
420 output.clear({
421 x: Math.floor(cached.x),
422 y: Math.floor(cached.y),
423 width: Math.floor(cached.width),
424 height: Math.floor(cached.height),
425 })
426 // Drop descendants' cache too — hideInstance's markDirty walks UP
427 // only, so descendants' .dirty stays false. Their nodeCache entries
428 // survive with pre-hide rects. On unhide, if position didn't shift,
429 // the blit check at line ~432 passes and copies EMPTY cells from
430 // prevScreen (cleared here) → content vanishes.
431 dropSubtreeCache(node)
432 layoutDamageRows = addLayoutDamageRect(layoutDamageRows, cached)
433 }
434 }
435 return
436 }
437
438 // Left and top positions in Yoga are relative to their parent node
439 const x = offsetX + yogaNode.getComputedLeft()
440 const yogaTop = yogaNode.getComputedTop()
441 let y = offsetY + yogaTop
442 const width = yogaNode.getComputedWidth()
443 const height = yogaNode.getComputedHeight()
444
445 // Absolute-positioned overlays (e.g. autocomplete menus with bottom='100%')
446 // can compute negative screen y when they extend above the viewport. Without
447 // clamping, setCellAt drops cells at y<0, clipping the TOP of the content

Callers 5

renderToScreenFunction · 0.85
createRendererFunction · 0.85
renderChildrenFunction · 0.85
renderScrolledChildrenFunction · 0.85
scanElementSubtreeMethod · 0.85

Calls 15

dropSubtreeCacheFunction · 0.85
addLayoutDamageRectFunction · 0.85
siblingSharesYFunction · 0.85
getMaxWidthFunction · 0.85
widestLineFunction · 0.85
wrapWithSoftWrapFunction · 0.85
applyTextStylesFunction · 0.85
buildCharToSegmentMapFunction · 0.85
applyStylesToWrappedTextFunction · 0.85

Tested by

no test coverage detected