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

Function setCellStyleId

src/ink/screen.ts:1137–1159  ·  view source on GitHub ↗
(
  screen: Screen,
  x: number,
  y: number,
  styleId: number,
)

Source from the content-addressed store, hash-verified

1135 * for the cell so diffEach picks up the change.
1136 */
1137export function setCellStyleId(
1138 screen: Screen,
1139 x: number,
1140 y: number,
1141 styleId: number,
1142): void {
1143 if (x < 0 || y < 0 || x >= screen.width || y >= screen.height) return
1144 const ci = (y * screen.width + x) << 1
1145 const cells = screen.cells
1146 const word1 = cells[ci + 1]!
1147 const width = word1 & WIDTH_MASK
1148 // Skip spacer cells — inverse on the head cell visually covers both columns
1149 if (width === CellWidth.SpacerTail || width === CellWidth.SpacerHead) return
1150 const hid = (word1 >>> HYPERLINK_SHIFT) & HYPERLINK_MASK
1151 cells[ci + 1] = packWord1(styleId, hid, width)
1152 // Expand damage so diffEach scans this cell
1153 const d = screen.damage
1154 if (d) {
1155 screen.damage = unionRect(d, { x, y, width: 1, height: 1 })
1156 } else {
1157 screen.damage = { x, y, width: 1, height: 1 }
1158 }
1159}
1160
1161/**
1162 * Intern a character string via the screen's shared CharPool.

Callers 3

applyPositionedHighlightFunction · 0.85
applySelectionOverlayFunction · 0.85
applySearchHighlightFunction · 0.85

Calls 2

packWord1Function · 0.85
unionRectFunction · 0.85

Tested by

no test coverage detected