MCPcopy
hub / github.com/chenglou/pretext / layoutWithLines

Function layoutWithLines

src/layout.ts:880–902  ·  view source on GitHub ↗
(prepared: PreparedTextWithSegments, maxWidth: number, lineHeight: number)

Source from the content-addressed store, hash-verified

878// decisions, but keeps extra per-line bookkeeping so it should stay off the
879// resize hot path.
880export function layoutWithLines(prepared: PreparedTextWithSegments, maxWidth: number, lineHeight: number): LayoutLinesResult {
881 const lines: LayoutLine[] = []
882 if (prepared.widths.length === 0) return { lineCount: 0, height: 0, lines }
883
884 const graphemeCache = getLineTextCache(prepared)
885 const lineCount = walkPreparedLinesRaw(
886 getInternalPrepared(prepared),
887 maxWidth,
888 (width, startSegmentIndex, startGraphemeIndex, endSegmentIndex, endGraphemeIndex) => {
889 lines.push(createLayoutLine(
890 prepared,
891 graphemeCache,
892 width,
893 startSegmentIndex,
894 startGraphemeIndex,
895 endSegmentIndex,
896 endGraphemeIndex,
897 ))
898 },
899 )
900
901 return { lineCount, height: lineCount * lineHeight, lines }
902}
903
904export function clearCache(): void {
905 clearAnalysisCaches()

Callers 9

runSweepFunction · 0.90
getOurLinesFunction · 0.90
measureWidthFunction · 0.90
buildRichBenchmarksFunction · 0.90
getPublicLinesFunction · 0.90
fitHeadlineFunction · 0.90
renderFunction · 0.90
materializeBlockLayoutFunction · 0.90
layout.test.tsFile · 0.85

Calls 4

getLineTextCacheFunction · 0.85
walkPreparedLinesRawFunction · 0.85
getInternalPreparedFunction · 0.85
createLayoutLineFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…