MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / opsToText

Function opsToText

packages/core/src/testing/renderer.ts:338–379  ·  view source on GitHub ↗
(ops: readonly TestRecordedOp[], viewport: TestViewport)

Source from the content-addressed store, hash-verified

336}
337
338function opsToText(ops: readonly TestRecordedOp[], viewport: TestViewport): string {
339 const grid: string[][] = [];
340 for (let y = 0; y < viewport.rows; y++) {
341 grid.push(new Array(viewport.cols).fill(" "));
342 }
343 const clipStack: ClipRect[] = [];
344
345 for (const op of ops) {
346 if (op.kind === "clear") {
347 fillGridRect(grid, viewport, clipStack, { x: 0, y: 0, w: viewport.cols, h: viewport.rows });
348 continue;
349 }
350
351 if (op.kind === "clearTo") {
352 fillGridRect(grid, viewport, clipStack, { x: 0, y: 0, w: op.cols, h: op.rows });
353 continue;
354 }
355
356 if (op.kind === "fillRect") {
357 fillGridRect(grid, viewport, clipStack, op);
358 continue;
359 }
360
361 if (op.kind === "drawText") {
362 drawTextToGrid(grid, viewport, clipStack, op.x, op.y, op.text);
363 continue;
364 }
365
366 if (op.kind === "pushClip") {
367 clipStack.push({ x: op.x, y: op.y, w: op.w, h: op.h });
368 continue;
369 }
370
371 if (op.kind === "popClip") {
372 clipStack.pop();
373 }
374 }
375
376 const lines = grid.map((row) => row.join("").replace(/\s+$/u, ""));
377 while (lines.length > 1 && lines[lines.length - 1] === "") lines.pop();
378 return lines.join("\n");
379}
380
381function findById(nodes: readonly TestRenderNode[], id: string): TestRenderNode | null {
382 for (const node of nodes) {

Callers 1

getScreenTextFunction · 0.85

Calls 4

fillGridRectFunction · 0.85
drawTextToGridFunction · 0.85
replaceMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected