MCPcopy Index your code
hub / github.com/codeaashu/claude-code / createScreen

Function createScreen

src/ink/screen.ts:451–492  ·  view source on GitHub ↗
(
  width: number,
  height: number,
  styles: StylePool,
  charPool: CharPool,
  hyperlinkPool: HyperlinkPool,
)

Source from the content-addressed store, hash-verified

449// ---
450
451export function createScreen(
452 width: number,
453 height: number,
454 styles: StylePool,
455 charPool: CharPool,
456 hyperlinkPool: HyperlinkPool,
457): Screen {
458 // Warn if dimensions are not valid integers (likely bad yoga layout output)
459 warn.ifNotInteger(width, 'createScreen width')
460 warn.ifNotInteger(height, 'createScreen height')
461
462 // Ensure width and height are valid integers to prevent crashes
463 if (!Number.isInteger(width) || width < 0) {
464 width = Math.max(0, Math.floor(width) || 0)
465 }
466 if (!Number.isInteger(height) || height < 0) {
467 height = Math.max(0, Math.floor(height) || 0)
468 }
469
470 const size = width * height
471
472 // Allocate one buffer, two views: Int32Array for per-word access,
473 // BigInt64Array for bulk fill in resetScreen/clearRegion.
474 // ArrayBuffer is zero-filled, which is exactly the empty cell value:
475 // [EMPTY_CHAR_INDEX=0, packWord1(emptyStyleId=0,0,0)=0].
476 const buf = new ArrayBuffer(size << 3) // 8 bytes per cell
477 const cells = new Int32Array(buf)
478 const cells64 = new BigInt64Array(buf)
479
480 return {
481 width,
482 height,
483 cells,
484 cells64,
485 charPool,
486 hyperlinkPool,
487 emptyStyleId: styles.none,
488 damage: undefined,
489 noSelect: new Uint8Array(size),
490 softWrap: new Int32Array(height),
491 }
492}
493
494/**
495 * Reset an existing screen for reuse, avoiding allocation of new typed arrays.

Callers 5

emptyFrameFunction · 0.85
renderToScreenFunction · 0.85
createRendererFunction · 0.85
blankMethod · 0.85
scanElementSubtreeMethod · 0.85

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected