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

Function drawTextToGrid

packages/core/src/testing/renderer.ts:291–319  ·  view source on GitHub ↗
(
  grid: string[][],
  viewport: TestViewport,
  clipStack: readonly ClipRect[],
  x0: number,
  y: number,
  text: string,
)

Source from the content-addressed store, hash-verified

289}
290
291function drawTextToGrid(
292 grid: string[][],
293 viewport: TestViewport,
294 clipStack: readonly ClipRect[],
295 x0: number,
296 y: number,
297 text: string,
298): void {
299 if (y < 0 || y >= viewport.rows) return;
300 let x = x0;
301 for (const glyph of text) {
302 const width = measureTextCells(glyph);
303 if (width <= 0) continue;
304
305 if (x >= 0 && x < viewport.cols && inClipStack(x, y, clipStack)) {
306 const row = grid[y];
307 if (row) row[x] = glyph;
308 }
309
310 for (let i = 1; i < width; i++) {
311 const xx = x + i;
312 if (xx < 0 || xx >= viewport.cols || !inClipStack(xx, y, clipStack)) continue;
313 const row = grid[y];
314 if (row) row[xx] = " ";
315 }
316
317 x += width;
318 }
319}
320
321function fillGridRect(
322 grid: string[][],

Callers 1

opsToTextFunction · 0.85

Calls 2

measureTextCellsFunction · 0.85
inClipStackFunction · 0.85

Tested by

no test coverage detected