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.
- package/package.json +1 -1
- package/src/probes/index.ts +27 -28
package/package.json
CHANGED
package/src/probes/index.ts
CHANGED
|
@@ -1352,35 +1352,28 @@ export const ALL_PROBES: Probe[] = [
|
|
|
1352
1352
|
},
|
|
1353
1353
|
} satisfies Probe,
|
|
1354
1354
|
|
|
1355
|
-
// Reflow:
|
|
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
|
-
//
|
|
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: "
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
const
|
|
1368
|
-
process.stdout.write(
|
|
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
|
-
|
|
1377
|
-
|
|
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]
|
|
1383
|
-
note: pos[0]
|
|
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
|
|
1395
|
-
|
|
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
|
-
//
|
|
1402
|
-
//
|
|
1403
|
-
return {
|
|
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
|
|