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

Function diffRowBoth

src/ink/screen.ts:1598–1624  ·  view source on GitHub ↗

* Diff one row where both screens are in bounds. * Scans for differences with findNextDiff, unpacks and calls cb for each.

(
  prevCells: Int32Array,
  nextCells: Int32Array,
  prev: Screen,
  next: Screen,
  ci: number,
  y: number,
  startX: number,
  endX: number,
  prevCell: Cell,
  nextCell: Cell,
  cb: DiffCallback,
)

Source from the content-addressed store, hash-verified

1596 * Scans for differences with findNextDiff, unpacks and calls cb for each.
1597 */
1598function diffRowBoth(
1599 prevCells: Int32Array,
1600 nextCells: Int32Array,
1601 prev: Screen,
1602 next: Screen,
1603 ci: number,
1604 y: number,
1605 startX: number,
1606 endX: number,
1607 prevCell: Cell,
1608 nextCell: Cell,
1609 cb: DiffCallback,
1610): boolean {
1611 let x = startX
1612 while (x < endX) {
1613 const skip = findNextDiff(prevCells, nextCells, ci, endX - x)
1614 x += skip
1615 ci += skip << 1
1616 if (x >= endX) break
1617 cellAtCI(prev, ci, prevCell)
1618 cellAtCI(next, ci, nextCell)
1619 if (cb(x, y, prevCell, nextCell)) return true
1620 x++
1621 ci += 2
1622 }
1623 return false
1624}
1625
1626/**
1627 * Emit removals for a row that only exists in prev (height shrank).

Callers 1

diffSameWidthFunction · 0.85

Calls 2

findNextDiffFunction · 0.85
cellAtCIFunction · 0.85

Tested by

no test coverage detected