| import type { TerminalInfo } from '../../ink-picture/InkPictureProvider.js' |
|
|
| |
| |
| |
| |
| |
| |
| |
| export function detectTerminalCaps(): Partial<TerminalInfo> { |
| const term = process.env.TERM ?? '' |
| const termProgram = process.env.TERM_PROGRAM ?? '' |
|
|
| const supportsUnicode = true |
| const colorterm = process.env.COLORTERM ?? '' |
| const supportsColor = |
| colorterm === 'truecolor' || |
| !!colorterm || |
| term.includes('truecolor') || |
| term.includes('256color') |
|
|
| |
| const supportsKittyGraphics = |
| termProgram === 'ghostty' || |
| termProgram === 'kitty' || |
| term.includes('kitty') || |
| term.includes('ghostty') || |
| !!process.env.KITTY_WINDOW_ID |
|
|
| |
| const supportsSixelGraphics = |
| term.includes('sixel') || |
| termProgram === 'ghostty' || |
| termProgram === 'vscode' || |
| (supportsKittyGraphics && termProgram === 'foot') |
|
|
| |
| let supportsITerm2Graphics = false |
| if (termProgram === 'iTerm.app') { |
| supportsITerm2Graphics = true |
| } else if (termProgram === 'WezTerm') { |
| |
| const ver = process.env.TERM_PROGRAM_VERSION ?? '' |
| const date = parseInt(ver.split('-')[0], 10) |
| if (!Number.isNaN(date) && date >= 20220319) { |
| supportsITerm2Graphics = true |
| } |
| } else if (termProgram === 'WarpTerminal') { |
| |
| const ver = process.env.TERM_PROGRAM_VERSION ?? '' |
| const match = ver.match(/v?(\d+)\.(\d+)\.(\d+)/) |
| if (match) { |
| const [, year, month, day] = match.map(Number) |
| if ( |
| year > 2025 || |
| (year === 2025 && month > 3) || |
| (year === 2025 && month === 3 && day >= 5) |
| ) { |
| supportsITerm2Graphics = true |
| } |
| } |
| } else if (termProgram === 'vscode' && supportsSixelGraphics) { |
| |
| supportsITerm2Graphics = true |
| } else if (!!process.env.KONSOLE_VERSION && supportsKittyGraphics) { |
| |
| const konsoleVer = parseInt(process.env.KONSOLE_VERSION, 10) |
| if (!Number.isNaN(konsoleVer) && konsoleVer >= 220400) { |
| supportsITerm2Graphics = true |
| } |
| } |
|
|
| return { |
| supportsUnicode, |
| supportsColor, |
| supportsKittyGraphics, |
| supportsSixelGraphics, |
| supportsITerm2Graphics, |
| } |
| } |
|
|