mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-25 08:48:08 +02:00
37 lines
898 B
TypeScript
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);
|
|
}
|