ktx/packages/cli/src/io/symbols.ts
2026-05-10 23:12:26 +02:00

37 lines
898 B
TypeScript

import { styleText } from 'node:util';
function detectUnicodeSupport(env: NodeJS.ProcessEnv = process.env): boolean {
if (process.platform !== 'win32') {
return env.TERM !== 'linux';
}
return (
Boolean(env.WT_SESSION) ||
env.TERM_PROGRAM === 'vscode' ||
env.TERM === 'xterm-256color' ||
env.TERM === 'alacritty'
);
}
const unicode = detectUnicodeSupport();
export const SYMBOLS = {
bar: unicode ? '│' : '|',
barStart: unicode ? '◇' : 'o',
barEnd: unicode ? '└' : '—',
group: unicode ? '●' : '*',
item: unicode ? '◆' : '*',
middot: unicode ? '·' : '-',
emDash: unicode ? '—' : '--',
} as const;
export function dim(text: string): string {
return styleText('dim', text);
}
export function bold(text: string): string {
return styleText('bold', text);
}
export function gray(text: string): string {
return styleText('gray', text);
}