MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / applyPaddingToText

Function applyPaddingToText

source code/ink/render-node-to-output.ts:367–386  ·  view source on GitHub ↗
(
  node: DOMElement,
  text: string,
  softWrap?: boolean[],
)

Source from the content-addressed store, hash-verified

365// Only first node is taken into account, because other text nodes can't have margin or padding,
366// so their coordinates will be relative to the first node anyway
367function applyPaddingToText(
368 node: DOMElement,
369 text: string,
370 softWrap?: boolean[],
371): string {
372 const yogaNode = node.childNodes[0]?.yogaNode
373
374 if (yogaNode) {
375 const offsetX = yogaNode.getComputedLeft()
376 const offsetY = yogaNode.getComputedTop()
377 text = '\n'.repeat(offsetY) + indentString(text, offsetX)
378 if (softWrap && offsetY > 0) {
379 // Prepend `false` for each padding line so indices stay aligned
380 // with text.split('\n'). Mutate in place — caller owns the array.
381 softWrap.unshift(...Array<boolean>(offsetY).fill(false))
382 }
383 }
384
385 return text
386}
387
388// After nodes are laid out, render each to output object, which later gets rendered to terminal
389function renderNodeToOutput(

Callers 1

renderNodeToOutputFunction · 0.85

Calls 2

getComputedLeftMethod · 0.45
getComputedTopMethod · 0.45

Tested by

no test coverage detected