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

Function extractRowText

source code/ink/selection.ts:718–746  ·  view source on GitHub ↗

Extract text from one screen row. When the next row is a soft-wrap * continuation (screen.softWrap[row+1]>0), clamp to that content-end * column and skip the trailing trim so the word-separator space survives * the join. See Screen.softWrap for why the clamp is necessary.

(
  screen: Screen,
  row: number,
  colStart: number,
  colEnd: number,
)

Source from the content-addressed store, hash-verified

716 * column and skip the trailing trim so the word-separator space survives
717 * the join. See Screen.softWrap for why the clamp is necessary. */
718function extractRowText(
719 screen: Screen,
720 row: number,
721 colStart: number,
722 colEnd: number,
723): string {
724 const noSelect = screen.noSelect
725 const rowOff = row * screen.width
726 const contentEnd = row + 1 < screen.height ? screen.softWrap[row + 1]! : 0
727 const lastCol = contentEnd > 0 ? Math.min(colEnd, contentEnd - 1) : colEnd
728 let line = ''
729 for (let col = colStart; col <= lastCol; col++) {
730 // Skip cells marked noSelect (gutters, line numbers, diff sigils).
731 // Check before cellAt to avoid the decode cost for excluded cells.
732 if (noSelect[rowOff + col] === 1) continue
733 const cell = cellAt(screen, col, row)
734 if (!cell) continue
735 // Skip spacer tails (second half of wide chars) — the head already
736 // contains the full grapheme. SpacerHead is a blank at line-end.
737 if (
738 cell.width === CellWidth.SpacerTail ||
739 cell.width === CellWidth.SpacerHead
740 ) {
741 continue
742 }
743 line += cell.char
744 }
745 return contentEnd > 0 ? line : line.replace(/\s+$/, '')
746}
747
748/** Accumulator for selected text that merges soft-wrapped rows back
749 * into logical lines. push(text, sw) appends a newline before text

Callers 2

getSelectedTextFunction · 0.85
captureScrolledRowsFunction · 0.85

Calls 1

cellAtFunction · 0.85

Tested by

no test coverage detected