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

Function makeFrame

src/ink/terminalReplayOracle.test.ts:21–59  ·  view source on GitHub ↗
({
  lines,
  viewportWidth = 40,
  viewportHeight = 10,
  cursorY = lines.length,
  styleId = stylePool.none,
}: {
  lines: string[]
  viewportWidth?: number
  viewportHeight?: number
  cursorY?: number
  styleId?: number
})

Source from the content-addressed store, hash-verified

19const hyperlinkPool = new HyperlinkPool()
20
21function makeFrame({
22 lines,
23 viewportWidth = 40,
24 viewportHeight = 10,
25 cursorY = lines.length,
26 styleId = stylePool.none,
27}: {
28 lines: string[]
29 viewportWidth?: number
30 viewportHeight?: number
31 cursorY?: number
32 styleId?: number
33}): Frame {
34 const screen = createScreen(
35 viewportWidth,
36 lines.length,
37 stylePool,
38 charPool,
39 hyperlinkPool,
40 )
41
42 for (let y = 0; y < lines.length; y += 1) {
43 const line = lines[y] ?? ''
44 for (let x = 0; x < line.length; x += 1) {
45 setCellAt(screen, x, y, {
46 char: line[x]!,
47 styleId,
48 width: CellWidth.Narrow,
49 hyperlink: undefined,
50 })
51 }
52 }
53
54 return {
55 screen,
56 viewport: { width: viewportWidth, height: viewportHeight },
57 cursor: { x: 0, y: cursorY, visible: true },
58 }
59}
60
61function serializeDiff(diff: Diff | { diff: Diff }): string {
62 const patches = Array.isArray(diff) ? diff : diff.diff

Callers 1

Calls 2

createScreenFunction · 0.85
setCellAtFunction · 0.85

Tested by

no test coverage detected