@bearz/ansi
Version:
The ansi module provides color detection, writing ansi, codes, and an ansi writer.
82 lines (81 loc) • 1.78 kB
JavaScript
/**
* The `settings` includes the ANSI settings for the terminal.
*
* @module
*/
import { Lazy } from "./_lazy.js";
import { detectMode } from "./detector.js";
import { AnsiModes } from "./enums.js";
import { stderr, stdout } from "@bearz/process";
let settings = new Lazy(() => new AnsiSettings(detectMode()));
/**
* The ANSI settings.
*/
export class AnsiSettings {
/**
* Creates a new ANSI settings.
* @param mode The ANSI mode.
*/
constructor(mode) {
this.
this.
}
/**
* The current ANSI settings.
*/
static get current() {
return settings.value;
}
/**
* Sets the current ANSI settings.
*/
static set current(value) {
settings = new Lazy(() => value);
}
/**
* Determines if the standard output is a terminal which
* the equivalent of calling isatty on `stdout`.
*/
get stdout() {
if (this.
return stdout.isTerm();
}
return false;
}
/**
* Determines if the standard error is a terminal whic
* the equivalent of calling isatty on `stderr`.
*/
get stderr() {
if (this.
return stderr.isTerm();
}
return false;
}
/**
* The ANSI mode.
*/
get mode() {
return this.
}
/**
* Sets the ANSI mode.
*/
set mode(value) {
this.
}
/**
* Determines if the terminal supports links.
*/
get links() {
return this.
}
/**
* Sets if the terminal supports links.
*/
set links(value) {
this.
}
}