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

Function buildCharToSegmentMap

src/ink/render-node-to-output.ts:195–204  ·  view source on GitHub ↗

* Build a mapping from each character position in the plain text to its segment index. * Returns an array where charToSegment[i] is the segment index for character i.

(segments: StyledSegment[])

Source from the content-addressed store, hash-verified

193 * Returns an array where charToSegment[i] is the segment index for character i.
194 */
195function buildCharToSegmentMap(segments: StyledSegment[]): number[] {
196 const map: number[] = []
197 for (let i = 0; i < segments.length; i++) {
198 const len = segments[i]!.text.length
199 for (let j = 0; j < len; j++) {
200 map.push(i)
201 }
202 }
203 return map
204}
205
206/**
207 * Apply styles to wrapped text by mapping each character back to its original segment.

Callers 1

renderNodeToOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected