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

Function visibleCellAtIndexInto

src/ink/screen.ts:665–702  ·  view source on GitHub ↗
(
  cells: Int32Array,
  charPool: CharPool,
  hyperlinkPool: HyperlinkPool,
  index: number,
  lastRenderedStyleId: number,
  out: Cell,
)

Source from the content-addressed store, hash-verified

663 * line, or -1 if none yet.
664 */
665export function visibleCellAtIndexInto(
666 cells: Int32Array,
667 charPool: CharPool,
668 hyperlinkPool: HyperlinkPool,
669 index: number,
670 lastRenderedStyleId: number,
671 out: Cell,
672): boolean {
673 const ci = index << 1
674 const charId = cells[ci]!
675 if (charId === 1) {
676 recordVisibleCellAtIndexResult('spacer')
677 return false // spacer
678 }
679 const word1 = cells[ci + 1]!
680 // For spaces: 0x3fffc masks bits 2-17 (hyperlinkId + styleId visibility
681 // bit). If zero, the space has no hyperlink and at most a fg-only style.
682 // Then word1 >>> STYLE_SHIFT is the foreground style — skip if it's zero
683 // (truly invisible) or matches the last rendered style on this line.
684 if (charId === 0 && (word1 & 0x3fffc) === 0) {
685 const fgStyle = word1 >>> STYLE_SHIFT
686 if (fgStyle === 0) {
687 recordVisibleCellAtIndexResult('empty')
688 return false
689 }
690 if (fgStyle === lastRenderedStyleId) {
691 recordVisibleCellAtIndexResult('fg-only-space-same-style')
692 return false
693 }
694 }
695 const hid = (word1 >>> HYPERLINK_SHIFT) & HYPERLINK_MASK
696 recordVisibleCellAtIndexResult('visible')
697 out.char = charPool.get(charId)
698 out.styleId = word1 >>> STYLE_SHIFT
699 out.width = word1 & WIDTH_MASK
700 out.hyperlink = hid === 0 ? undefined : hyperlinkPool.get(hid)
701 return true
702}
703
704/**
705 * Returns the style for a content-space cell that visibleCellAtIndexInto()

Callers 5

rowFitsWithinWidthFunction · 0.85
rowLeavesRightMarginFunction · 0.85
renderFrameSliceFunction · 0.85
visibleCellAtIndexFunction · 0.85

Calls 2

getMethod · 0.45

Tested by

no test coverage detected