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

Function analyzeFillableSpaceGap

src/ink/screen.ts:770–831  ·  view source on GitHub ↗
(
  screen: Screen,
  y: number,
  startX: number,
  endX: number,
  currentStyleId: number,
  currentHyperlink: Hyperlink,
  defaultStyleId: number,
)

Source from the content-addressed store, hash-verified

768 * stats or materializing Cells.
769 */
770export function analyzeFillableSpaceGap(
771 screen: Screen,
772 y: number,
773 startX: number,
774 endX: number,
775 currentStyleId: number,
776 currentHyperlink: Hyperlink,
777 defaultStyleId: number,
778): FillableSpaceGapAnalysis {
779 if (currentHyperlink !== undefined) {
780 return { fillableCells: 0, blocker: 'active-hyperlink' }
781 }
782
783 if (endX <= startX || y < 0 || y >= screen.height) {
784 return { fillableCells: 0, blocker: 'invalid-range' }
785 }
786
787 const rowContentEnd = screen.contentEnd[y] ?? 0
788 if (rowContentEnd <= startX) {
789 return { fillableCells: 0, blocker: 'content-end' }
790 }
791
792 const gapEnd = Math.min(endX, rowContentEnd)
793 if (gapEnd <= startX) {
794 return { fillableCells: 0, blocker: 'content-end' }
795 }
796
797 let fillableCells = 0
798 for (let x = startX; x < gapEnd; x += 1) {
799 const ci = (y * screen.width + x) << 1
800 const charId = screen.cells[ci]!
801 if (charId !== 0) {
802 return { fillableCells, blocker: 'non-space-char' }
803 }
804
805 const word1 = screen.cells[ci + 1]!
806 if ((word1 & 0x3fffc) !== 0) {
807 return { fillableCells, blocker: 'space-metadata' }
808 }
809
810 const fgStyle = word1 >>> STYLE_SHIFT
811 if (fgStyle === 0) {
812 if (currentStyleId !== defaultStyleId) {
813 return { fillableCells, blocker: 'default-style-mismatch' }
814 }
815 fillableCells += 1
816 continue
817 }
818
819 if (fgStyle !== currentStyleId) {
820 return { fillableCells, blocker: 'fg-style-mismatch' }
821 }
822
823 fillableCells += 1
824 }
825
826 if (gapEnd < endX) {
827 return { fillableCells, blocker: 'content-end' }

Callers 3

renderMethod · 0.85
countFillableSpaceGapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected