MCPcopy
hub / github.com/codeaashu/claude-code / applyPaddingToText

Function applyPaddingToText

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

Source from the content-addressed store, hash-verified

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

Callers 1

renderNodeToOutputFunction · 0.85

Calls 3

fillMethod · 0.80
getComputedLeftMethod · 0.45
getComputedTopMethod · 0.45

Tested by

no test coverage detected