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

Function makeFrame

src/ink/logUpdateFlickerRegression.test.ts:71–132  ·  view source on GitHub ↗
({
  lines,
  viewportWidth = 10,
  viewportHeight,
  screenHeight = lines.length,
  cursorY = screenHeight,
  cells = [],
}: {
  lines: string[]
  viewportWidth?: number
  viewportHeight: number
  screenHeight?: number
  cursorY?: number
  cells?: Array<{
    x: number
    y: number
    char: string
    styleId?: number
    width?: CellWidth
  }>
})

Source from the content-addressed store, hash-verified

69}
70
71function makeFrame({
72 lines,
73 viewportWidth = 10,
74 viewportHeight,
75 screenHeight = lines.length,
76 cursorY = screenHeight,
77 cells = [],
78}: {
79 lines: string[]
80 viewportWidth?: number
81 viewportHeight: number
82 screenHeight?: number
83 cursorY?: number
84 cells?: Array<{
85 x: number
86 y: number
87 char: string
88 styleId?: number
89 width?: CellWidth
90 }>
91}): Frame {
92 const screen = createScreen(
93 viewportWidth,
94 screenHeight,
95 stylePool,
96 charPool,
97 hyperlinkPool,
98 )
99
100 for (let y = 0; y < lines.length; y += 1) {
101 const line = lines[y] ?? ''
102 for (let x = 0; x < line.length; x += 1) {
103 setCellAt(screen, x, y, {
104 char: line[x]!,
105 styleId: stylePool.none,
106 width: CellWidth.Narrow,
107 hyperlink: undefined,
108 })
109 }
110 }
111 for (const cell of cells) {
112 setCellAt(screen, cell.x, cell.y, {
113 char: cell.char,
114 styleId: cell.styleId ?? stylePool.none,
115 width: cell.width ?? CellWidth.Narrow,
116 hyperlink: undefined,
117 })
118 }
119
120 return {
121 screen,
122 viewport: {
123 width: viewportWidth,
124 height: viewportHeight,
125 },
126 cursor: {
127 x: 0,
128 y: cursorY,

Calls 2

createScreenFunction · 0.85
setCellAtFunction · 0.85

Tested by

no test coverage detected