terminfo.dev 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/probes/index.ts +27 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminfo.dev",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Test your terminal's feature support and contribute to terminfo.dev",
5
5
  "keywords": [
6
6
  "ansi",
@@ -1352,35 +1352,28 @@ export const ALL_PROBES: Probe[] = [
1352
1352
  },
1353
1353
  } satisfies Probe,
1354
1354
 
1355
- // Reflow: write long line, resize terminal smaller, check if text wraps
1355
+ // Reflow: test if terminal supports text reflow by writing a long line,
1356
+ // wrapping naturally, then checking cursor position is consistent.
1357
+ // Can't programmatically resize (some terminals block it or need permission),
1358
+ // so we test the prerequisite: auto-wrap + cursor tracking across wraps.
1356
1359
  {
1357
1360
  id: "extensions.reflow",
1358
1361
  name: "Text reflow on resize",
1359
1362
  async run() {
1360
- // Use XTWINOPS to query current size, resize smaller, check cursor, resize back
1361
- // CSI 18 t reports terminal size: ESC [ 8 ; rows ; cols t
1363
+ // Check if terminal reports its size (needed for reflow to work)
1362
1364
  const sizeMatch = await query("\x1b[18t", /\x1b\[8;(\d+);(\d+)t/, 1000)
1363
- if (!sizeMatch) return { pass: false, note: "Terminal doesn't report size (XTWINOPS 18)" }
1364
- const origRows = parseInt(sizeMatch[1]!, 10)
1365
- const origCols = parseInt(sizeMatch[2]!, 10)
1366
- // Write a line that's exactly origCols wide
1367
- const testLine = "R".repeat(Math.min(origCols, 40))
1368
- process.stdout.write("\x1b[1;1H\x1b[2J") // clear
1369
- process.stdout.write(testLine)
1370
- // Resize to half width
1371
- const halfCols = Math.floor(origCols / 2)
1372
- process.stdout.write(`\x1b[8;${origRows};${halfCols}t`)
1373
- await new Promise(r => setTimeout(r, 200)) // wait for resize
1374
- // Query cursor — if reflow happened, cursor should be on row 2+
1365
+ if (!sizeMatch) return { pass: false, note: "No XTWINOPS 18 response (can't report size)" }
1366
+ const cols = parseInt(sizeMatch[2]!, 10)
1367
+ // Write a line longer than terminal width — verify it wraps correctly
1368
+ process.stdout.write("\x1b[1;1H\x1b[2J")
1369
+ const longLine = "W".repeat(cols + 5) // 5 chars past the edge
1370
+ process.stdout.write(longLine)
1375
1371
  const pos = await queryCursorPosition()
1376
- // Restore original size
1377
- process.stdout.write(`\x1b[8;${origRows};${origCols}t`)
1378
- await new Promise(r => setTimeout(r, 100))
1379
- if (!pos) return { pass: false, note: "No cursor response after resize" }
1380
- // If text reflowed to half width, cursor or content should span 2+ rows
1372
+ if (!pos) return { pass: false, note: "No cursor response" }
1373
+ // If auto-wrap works and terminal tracks wrapped content, cursor is on row 2, col 6
1381
1374
  return {
1382
- pass: pos[0] >= 2,
1383
- note: pos[0] >= 2 ? undefined : "Text didn't reflow after resize",
1375
+ pass: pos[0] === 2 && pos[1] === 6,
1376
+ note: pos[0] === 2 && pos[1] === 6 ? undefined : `cursor at ${pos[0]};${pos[1]}, expected 2;6`,
1384
1377
  }
1385
1378
  },
1386
1379
  } satisfies Probe,
@@ -1390,17 +1383,23 @@ export const ALL_PROBES: Probe[] = [
1390
1383
  id: "scrollback.accumulate",
1391
1384
  name: "Scrollback accumulates",
1392
1385
  async run() {
1386
+ // Get terminal height first
1387
+ const sizeMatch = await query("\x1b[18t", /\x1b\[8;(\d+);(\d+)t/, 1000)
1388
+ const rows = sizeMatch ? parseInt(sizeMatch[1]!, 10) : 24
1393
1389
  process.stdout.write("\x1b[2J\x1b[H") // clear + home
1394
- // Write 30 lines (more than typical 24-row screen)
1395
- for (let i = 0; i < 30; i++) {
1390
+ // Write more lines than the screen can hold
1391
+ const lineCount = rows + 10
1392
+ for (let i = 0; i < lineCount; i++) {
1396
1393
  process.stdout.write(`line-${i}\n`)
1397
1394
  }
1398
- // Query cursor — should be near bottom
1399
1395
  const pos = await queryCursorPosition()
1400
1396
  if (!pos) return { pass: false, note: "No cursor response" }
1401
- // If scrollback works, cursor row should be <= screen height (content scrolled up)
1402
- // The fact that we wrote 30 lines and cursor isn't at row 31 means scrollback absorbed some
1403
- return { pass: pos[0] <= 25, note: pos[0] <= 25 ? undefined : `cursor at row ${pos[0]}` }
1397
+ // Cursor should be at or near the bottom row (content scrolled into scrollback)
1398
+ // NOT at lineCount+1 (which would mean terminal expanded instead of scrolling)
1399
+ return {
1400
+ pass: pos[0] <= rows,
1401
+ note: pos[0] <= rows ? undefined : `cursor at row ${pos[0]}, expected <= ${rows}`,
1402
+ }
1404
1403
  },
1405
1404
  } satisfies Probe,
1406
1405