terminfo.dev 0.3.0 → 0.4.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminfo.dev",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Test your terminal's feature support and contribute to terminfo.dev",
5
5
  "keywords": [
6
6
  "ansi",
package/src/index.ts CHANGED
@@ -46,11 +46,6 @@ async function main() {
46
46
  console.log(`Running ${ALL_PROBES.length} probes...\n`)
47
47
  }
48
48
 
49
- // Save/restore screen state
50
- process.stdout.write("\x1b7") // save cursor
51
- process.stdout.write("\x1b[?1049h") // alt screen
52
- process.stdout.write("\x1b[2J\x1b[H") // clear + home
53
-
54
49
  const results: Record<string, boolean> = {}
55
50
  const notes: Record<string, string> = {}
56
51
  const responses: Record<string, string> = {}
@@ -58,7 +53,13 @@ async function main() {
58
53
  let failed = 0
59
54
 
60
55
  await withRawMode(async () => {
56
+ // Enter alt screen inside raw mode so all probe output stays contained
57
+ process.stdout.write("\x1b[?1049h") // alt screen
58
+ process.stdout.write("\x1b[2J\x1b[H") // clear + home
59
+
61
60
  for (const probe of ALL_PROBES) {
61
+ // Clear screen before each probe to prevent leaking output
62
+ process.stdout.write("\x1b[2J\x1b[H")
62
63
  try {
63
64
  const result = await probe.run()
64
65
  results[probe.id] = result.pass
@@ -72,11 +73,10 @@ async function main() {
72
73
  failed++
73
74
  }
74
75
  }
75
- })
76
76
 
77
- // Restore screen
78
- process.stdout.write("\x1b[?1049l") // exit alt screen
79
- process.stdout.write("\x1b8") // restore cursor
77
+ // Exit alt screen while still in raw mode
78
+ process.stdout.write("\x1b[?1049l")
79
+ })
80
80
 
81
81
  const total = ALL_PROBES.length
82
82
  const pct = Math.round((passed / total) * 100)
@@ -318,16 +318,26 @@ const kittyKeyboard: Probe = {
318
318
 
319
319
  const sixelSupport: Probe = {
320
320
  id: "extensions.sixel",
321
- name: "Sixel graphics (DA1 bit 4)",
321
+ name: "Sixel graphics",
322
322
  async run() {
323
+ // Check DA1 for sixel bit (;4) — some terminals advertise it
323
324
  const match = await query("\x1b[c", /\x1b\[\?([0-9;]+)c/, 1000)
324
- if (!match) return { pass: false, note: "No DA1 response" }
325
- const attrs = match[1]!.split(";")
326
- const hasSixel = attrs.includes("4")
325
+ if (match) {
326
+ const attrs = match[1]!.split(";")
327
+ if (attrs.includes("4")) return { pass: true, response: `DA1: ${match[1]}` }
328
+ }
329
+ // Fallback: send a minimal sixel image and check if cursor moved
330
+ // DCS q = sixel start, #0;2;0;0;0 = color, ! = repeat, ~ = sixel data, ST = end
331
+ process.stdout.write("\x1b[1;1H") // move to 1;1
332
+ process.stdout.write("\x1bPq#0;2;0;0;0~-~\x1b\\") // tiny 1x2 sixel
333
+ const pos = await queryCursorPosition()
334
+ if (!pos) return { pass: false, note: "No cursor response after sixel" }
335
+ // If terminal parsed sixel, cursor may have moved down
336
+ const moved = pos[0] > 1 || pos[1] > 1
327
337
  return {
328
- pass: hasSixel,
329
- note: hasSixel ? undefined : "DA1 response missing ;4 (sixel)",
330
- response: match[1],
338
+ pass: moved,
339
+ note: moved ? undefined : "DA1 missing ;4 and sixel didn't move cursor",
340
+ response: match?.[1] ? `DA1: ${match[1]}` : undefined,
331
341
  }
332
342
  },
333
343
  }