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

Function getPublicLines

pages/probe.ts:495–523  ·  view source on GitHub ↗
(
  prepared: PreparedTextWithSegments,
  normalizedText: string,
  contentWidth: number,
  lineHeight: number,
  measuredFont: string,
)

Source from the content-addressed store, hash-verified

493}
494
495function getPublicLines(
496 prepared: PreparedTextWithSegments,
497 normalizedText: string,
498 contentWidth: number,
499 lineHeight: number,
500 measuredFont: string,
501): ProbeLine[] {
502 return layoutWithLines(prepared, contentWidth, lineHeight).lines.map(line => {
503 const start = line.start.segmentIndex === 0 && line.start.graphemeIndex === 0
504 ? 0
505 : computeOffsetFromCursor(prepared, line.start)
506 const end = computeOffsetFromCursor(prepared, line.end)
507 const content = getLineContent(line.text, end)
508 const contentEnd = start + content.text.length
509 const logicalText = normalizedText.slice(start, contentEnd)
510
511 return {
512 text: logicalText,
513 renderedText: line.text,
514 contentText: content.text,
515 start,
516 end,
517 contentEnd,
518 fullWidth: measureCanvasTextWidth(diagnosticCtx, content.text, measuredFont),
519 domWidth: measureDomTextWidth(document, content.text, measuredFont, direction),
520 sumWidth: measurePreparedSlice(prepared, start, contentEnd, measuredFont),
521 }
522 })
523}
524
525function summarizeLines(lines: ProbeLine[]): ProbeLineSummary[] {
526 return lines.map((line, index) => ({

Callers 1

buildProbeReportFunction · 0.85

Calls 6

layoutWithLinesFunction · 0.90
getLineContentFunction · 0.90
measureCanvasTextWidthFunction · 0.90
measureDomTextWidthFunction · 0.90
computeOffsetFromCursorFunction · 0.85
measurePreparedSliceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…