ANSI Reference
📟 Functional CLI ANSI formatting functions.
Usage
📦 Node
Install @lou.codes/ansi
as a dependency:
1pnpm add @lou.codes/ansi2# or3npm install @lou.codes/ansi4# or5yarn add @lou.codes/ansi
Import it and use it:
1import { foregroundRed } from "@lou.codes/ansi";2
3foregroundRed`Hello world!`; // "Hello world!" in red text.
🦕 Deno
Import @lou.codes/ansi
using the npm:
prefix, and use it directly:
1import { foregroundRed } from "npm:@lou.codes/ansi";2
3foregroundRed`Hello world!`; // "Hello world!" in red text.
🌎 Browser
Import @lou.codes/ansi
using esm.sh, and use it directly:
1<script type="module">2 import { foregroundRed } from "https://esm.sh/@lou.codes/ansi";3
4 foregroundRed`Hello world!`; // "Hello world!" in red text.5</script>
Useful links
- 📝 Documentation: TypeDoc generated documentation.
- ⏳ Changelog: List of changes between versions.
- ✅ Tests Coverage: Coveralls page with tests coverage.
Background
backgroundBlack()
1function backgroundBlack<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[40m${Input extends string ? Input<Input> : string}[49m`;
Black background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[40m${Input extends string ? Input<Input> : string}[49m`
input
string with black background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
black background around it.
Example
1backgroundBlack("Lou"); // "\u001B[40mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBlack`Lou`; // "\u001B[40mLou\u001B[49m"
See
backgroundBlue()
1function backgroundBlue<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[44m${Input extends string ? Input<Input> : string}[49m`;
Blue background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[44m${Input extends string ? Input<Input> : string}[49m`
input
string with blue background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
blue background around it.
Example
1backgroundBlue("Lou"); // "\u001B[44mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBlue`Lou`; // "\u001B[44mLou\u001B[49m"
See
backgroundBrightBlue()
1function backgroundBrightBlue<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[104m${Input extends string ? Input<Input> : string}[49m`;
Bright blue background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[104m${Input extends string ? Input<Input> : string}[49m`
input
string with bright blue background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright blue background around it.
Example
1backgroundBrightBlue("Lou"); // "\u001B[104mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightBlue`Lou`; // "\u001B[104mLou\u001B[49m"
See
backgroundBrightCyan()
1function backgroundBrightCyan<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[106m${Input extends string ? Input<Input> : string}[49m`;
Bright cyan background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[106m${Input extends string ? Input<Input> : string}[49m`
input
string with bright cyan background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright cyan background around it.
Example
1backgroundBrightCyan("Lou"); // "\u001B[106mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightCyan`Lou`; // "\u001B[106mLou\u001B[49m"
See
backgroundBrightGreen()
1function backgroundBrightGreen<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[102m${Input extends string ? Input<Input> : string}[49m`;
Bright green background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[102m${Input extends string ? Input<Input> : string}[49m`
input
string with bright green background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright green background around it.
Example
1backgroundBrightGreen("Lou"); // "\u001B[102mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightGreen`Lou`; // "\u001B[102mLou\u001B[49m"
See
backgroundBrightMagenta()
1function backgroundBrightMagenta<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[105m${Input extends string ? Input<Input> : string}[49m`;
Bright magenta background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[105m${Input extends string ? Input<Input> : string}[49m`
input
string with bright magenta background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright magenta background around it.
Example
1backgroundBrightMagenta("Lou"); // "\u001B[105mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightMagenta`Lou`; // "\u001B[105mLou\u001B[49m"
See
backgroundBrightRed()
1function backgroundBrightRed<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[101m${Input extends string ? Input<Input> : string}[49m`;
Bright red background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[101m${Input extends string ? Input<Input> : string}[49m`
input
string with bright red background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright red background around it.
Example
1backgroundBrightRed("Lou"); // "\u001B[101mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightRed`Lou`; // "\u001B[101mLou\u001B[49m"
See
backgroundBrightWhite()
1function backgroundBrightWhite<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[107m${Input extends string ? Input<Input> : string}[49m`;
Bright white background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[107m${Input extends string ? Input<Input> : string}[49m`
input
string with bright white background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright white background around it.
Example
1backgroundBrightWhite("Lou"); // "\u001B[107mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightWhite`Lou`; // "\u001B[107mLou\u001B[49m"
See
backgroundBrightYellow()
1function backgroundBrightYellow<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[103m${Input extends string ? Input<Input> : string}[49m`;
Bright yellow background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[103m${Input extends string ? Input<Input> : string}[49m`
input
string with bright yellow background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright yellow background around it.
Example
1backgroundBrightYellow("Lou"); // "\u001B[103mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundBrightYellow`Lou`; // "\u001B[103mLou\u001B[49m"
See
backgroundColor()
1function backgroundColor<Open>(2 open: Open,3): <Input>(4 input: Input,5 ...expressions: ReadOnlyArray6) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[49m`;
Background color code wrapper.
Type parameters
Type parameter |
---|
Open extends number |
Parameters
Parameter | Type |
---|---|
open | Open |
Returns
Function
Curried function with close
ANSI code for background in context.
format function with close
and open
set.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Input string or TemplateStringArray (when using tagged templates). |
…expressions | ReadOnlyArray | Input expressions (when using tagged templates) |
Returns
`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[49m`
Formatted input
string.
See
Remarks
Takes an open
ANSI code and an input
string and adds the open and close ANSI
codes to that string (for background color).
Example
1backgroundColor(13)("Lou"); // "\u001B[13mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundColor(13)`Lou`; // "\u001B[13mLou\u001B[49m"
See
backgroundCyan()
1function backgroundCyan<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[46m${Input extends string ? Input<Input> : string}[49m`;
Cyan background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[46m${Input extends string ? Input<Input> : string}[49m`
input
string with cyan background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
cyan background around it.
Example
1backgroundCyan("Lou"); // "\u001B[46mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundCyan`Lou`; // "\u001B[46mLou\u001B[49m"
See
backgroundGray()
1function backgroundGray<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[100m${Input extends string ? Input<Input> : string}[49m`;
Gray background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[100m${Input extends string ? Input<Input> : string}[49m`
input
string with gray background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
gray background around it.
Example
1backgroundGray("Lou"); // "\u001B[100mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundGray`Lou`; // "\u001B[100mLou\u001B[49m"
See
backgroundGreen()
1function backgroundGreen<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[42m${Input extends string ? Input<Input> : string}[49m`;
Green background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[42m${Input extends string ? Input<Input> : string}[49m`
input
string with green background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
green background around it.
Example
1backgroundGreen("Lou"); // "\u001B[42mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundGreen`Lou`; // "\u001B[42mLou\u001B[49m"
See
backgroundMagenta()
1function backgroundMagenta<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[45m${Input extends string ? Input<Input> : string}[49m`;
Magenta background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[45m${Input extends string ? Input<Input> : string}[49m`
input
string with magenta background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
magenta background around it.
Example
1backgroundMagenta("Lou"); // "\u001B[45mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundMagenta`Lou`; // "\u001B[45mLou\u001B[49m"
See
backgroundRed()
1function backgroundRed<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[41m${Input extends string ? Input<Input> : string}[49m`;
Red background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[41m${Input extends string ? Input<Input> : string}[49m`
input
string with red background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
red background around it.
Example
1backgroundRed("Lou"); // "\u001B[41mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundRed`Lou`; // "\u001B[41mLou\u001B[49m"
See
backgroundWhite()
1function backgroundWhite<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[47m${Input extends string ? Input<Input> : string}[49m`;
White background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[47m${Input extends string ? Input<Input> : string}[49m`
input
string with white background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
white background around it.
Example
1backgroundWhite("Lou"); // "\u001B[47mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundWhite`Lou`; // "\u001B[47mLou\u001B[49m"
See
backgroundYellow()
1function backgroundYellow<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[43m${Input extends string ? Input<Input> : string}[49m`;
Yellow background code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[43m${Input extends string ? Input<Input> : string}[49m`
input
string with yellow background.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
yellow background around it.
Example
1backgroundYellow("Lou"); // "\u001B[43mLou\u001B[49m"2// It can also be used as a tag function for tagged templates:3backgroundYellow`Lou`; // "\u001B[43mLou\u001B[49m"
See
Common
Formatter()
1type Formatter: (templateStrings: TemplateStringsArray | string, ...expressions: ReadOnlyArray) => string;
Formatter function that takes a string or a tagged template.
Remarks
Type to represent a function that works both directly on a string or as a tagged template function.
Example
1const formatter: Formatter = (input, ...expressions) =>2 typeof input === "string" ? input : (3 input4 .flatMap((string, index) => [string, expressions[index] ?? ""])5 .join("")6 );7
8formatter("Lou"); // "Lou"9formatter`Lou`; // "Lou"
See
Parameters
Parameter | Type |
---|---|
templateStrings | TemplateStringsArray | string |
…expressions | ReadOnlyArray |
Returns
string
resetToInitialState
1const resetToInitialState: "\u001bc";
RIS sequence.
Remarks
Resets the entire screen to initial state.
Example
1console.log(resetToInitialState); // "\u001B[c"2stdout.write(resetToInitialState); // Resets the entire screen to initial state.
See
controlSequenceIntroducer()
1function controlSequenceIntroducer<Code>(2 code: Code,3): <Input>(4 input: Input,5) => `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}${Code}`;
CSI sequence generator.
Type parameters
Type parameter | Description |
---|---|
Code extends string | CSI code generic. |
Parameters
Parameter | Type | Description |
---|---|---|
code | Code | CSI code. |
Returns
Function
Curried function with code
in context.
Takes an input
number and returns the CSI sequence.
Type parameters
Type parameter | Description |
---|---|
Input extends number | readonly [Maybe <number >, Maybe <number >] | CSI input generic. |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | CSI input. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}${Code}`
CSI sequence.
See
Remarks
Takes a code
and an input
number and returns the CSI sequence.
Example
1const selectGraphicRendition = controlSequenceIntroducer("m");2selectGraphicRendition(13); // "\u001B[13m"3selectGraphicRendition(42); // "\u001B[42m"
See
escapeSequence()
1function escapeSequence<Input>(input: Input): `${Input}`;
Takes an input
string and returns an escaped sequence based on it.
Type parameters
Type parameter | Description |
---|---|
Input extends string | String to escape generic. |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | String to escape. |
Returns
`${Input}`
String with ESC character prepended.
Remarks
Escape sequences are used to control the cursor, change colors, and more in the terminal. They are preceded by the ESC character (ASCII code 27, or 0x1b). This functions prepends any given string with the ESC character.
Example
1escapeSequence("Lou"); // "\x1bLou"
See
format()
1function format<Close>(2 close: Close,3): <Open>(4 open: Open,5) => <Input>(6 input: Input,7 ...expressions: ReadOnlyArray8) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${Close<Close>[0] extends number ? any[any] : ""};${Close<Close>[1] extends number ? any[any] : ""}` : `${Close}`}m`;
Format wrapper function.
Type parameters
Type parameter | Description |
---|---|
Close extends number | Close string generic. |
Parameters
Parameter | Type | Description |
---|---|---|
close | Close | Close string. |
Returns
Function
Curried function with close
in context.
format function with close
set.
Type parameters
Type parameter | Description |
---|---|
Open extends number | Open string generic. |
Parameters
Parameter | Type | Description |
---|---|---|
open | Open | Open string. |
Returns
Function
Curried function with close
and open
in context.
format function with close
and open
set.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Input string or TemplateStringArray (when using tagged templates). |
…expressions | ReadOnlyArray | Input expressions (when using tagged templates) |
Returns
`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${Close<Close>[0] extends number ? any[any] : ""};${Close<Close>[1] extends number ? any[any] : ""}` : `${Close}`}m`
Formatted input
string.
See
See
Remarks
Given an open
, a close
string and an input
string, return formatted
input
(surrounded by open
and close
).
Example
1format(13)(42)("Lou"); // "\u001B[42mLou\u001B[13m"2// It can also be used as a tag function for tagged templates:3format(13)(42)`Lou`; // "\u001B[42mLou\u001B[13m"
See
mix()
1function mix(...formatters: ReadOnlyArray<Formatter>): Formatter;
Composes formatters.
Parameters
Parameter | Type | Description |
---|---|---|
…formatters | ReadOnlyArray <Formatter > | Array of formatters to be composed. |
Returns
Formatter composed of the given formatters.
Remarks
Given an array of formatters, it will return a new formatter that will apply all of them to the input string.
Example
1const redTextWhiteBackground = mix(foregroundRed, backgroundWhite);2
3redTextWhiteBackground("Lou");4// It can also be used as a tag function for tagged templates:5redTextWhiteBackground`Lou`;
See
normalizeString()
1function normalizeString<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): Input extends string ? Input<Input> : string;
Takes a string or a template string and returns a plain string.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | String or template string. |
…expressions | ReadOnlyArray | Possible values passed to the template string. |
Returns
Input
extends string
? Input
<Input
> : string
Plain string.
Example
1normalizeString(`Hello ${13}!`); // "Hello 13!"2normalizeString`Hello ${13}!`; // "Hello 13!"
See
optionalFormat()
1function optionalFormat<Close>(2 close: Close,3): <Open>(4 open: Open,5) => <Input>(6 input: Input,7 ...expressions: ReadOnlyArray8) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${Close<Close>[0] extends number ? any[any] : ""};${Close<Close>[1] extends number ? any[any] : ""}` : `${Close}`}m`;
Process dependant format
function.
Type parameters
Type parameter |
---|
Close extends number |
Parameters
Parameter | Type |
---|---|
close | Close |
Returns
Function
Either the formatted string, or just the passed string.
format function with close
set.
Type parameters
Type parameter | Description |
---|---|
Open extends number | Open string generic. |
Parameters
Parameter | Type | Description |
---|---|---|
open | Open | Open string. |
Returns
Function
Curried function with close
and open
in context.
format function with close
and open
set.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Input string or TemplateStringArray (when using tagged templates). |
…expressions | ReadOnlyArray | Input expressions (when using tagged templates) |
Returns
`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${Close<Close>[0] extends number ? any[any] : ""};${Close<Close>[1] extends number ? any[any] : ""}` : `${Close}`}m`
Formatted input
string.
See
See
Remarks
Impure version of format which changes
depending on the current NodeJS globalThis.process
environment.
Example
1// In a environment with color:2optionalFormat(42)(13)("Lou"); // "\u001B[42mLou\u001B[13m"3// In an environment without color:4optionalFormat(42)(13)("Lou"); // "Lou"5// It also works with tagged templates:6optionalFormat(42)(13)`Lou`; // "\u001B[42mLou\u001B[13m"
See
selectGraphicRendition()
1function selectGraphicRendition<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}m`;
Takes an input
number and returns the a SGR sequence.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Input to escape. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}m`
SGR sequence.
Example
1controlSequenceIntroducer(13); // "\u001B[13m"2controlSequenceIntroducer(42); // "\u001B[42m"
See
Cursor
cursorBack()
1function cursorBack<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}D`;
Moves the cursor input
cells back.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of cells back. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}D`
CUB sequence.
Remarks
If the cursor is already at the edge of the screen, this has no effect.
Example
1cursorBack(13); // "\u001B[13C"
See
cursorDown()
1function cursorDown<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}B`;
Moves the cursor input
cells down.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of cells down. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}B`
CUD sequence.
Remarks
If the cursor is already at the edge of the screen, this has no effect.
Example
1cursorDown(13); // "\u001B[13B"
See
cursorForward()
1function cursorForward<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}C`;
Moves the cursor input
cells forward.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of cells forward. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}C`
CUF sequence.
Remarks
If the cursor is already at the edge of the screen, this has no effect.
Example
1cursorForward(13); // "\u001B[13C"
See
cursorHorizontalAbsolute()
1function cursorHorizontalAbsolute<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}G`;
Moves cursor to the column input
.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Column number. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}G`
CHA sequence.
Example
1cursorHorizontalAbsolute(13); // "\u001B[13G"
See
cursorNextLine()
1function cursorNextLine<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}E`;
Moves cursor to beginning of the line input
lines down.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of lines down. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}E`
CNL sequence.
Example
1cursorNextLine(13); // "\u001B[13E"
See
cursorPosition()
1function cursorPosition<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}H`;
Moves the cursor to position input
.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Position (row, column) |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}H`
CUP sequence.
Example
1cursorPosition([13, 42]); // "\u001B[13;42H"2cursorPosition([undefined, 42]); // "\u001B[;42H"3cursorPosition([13, undefined]); // "\u001B[13;H"
See
cursorPreviousLine()
1function cursorPreviousLine<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}F`;
Moves cursor to beginning of the line input
lines up.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of lines up. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}F`
CPL sequence.
Example
1cursorPreviousLine(13); // "\u001B[13F"
See
cursorUp()
1function cursorUp<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}A`;
Moves the cursor input
cells up.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of cells up. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}A`
CUU sequence.
Remarks
If the cursor is already at the edge of the screen, this has no effect.
Example
1cursorUp(13); // "\u001B[13A"
See
Erase
eraseInDisplay()
1function eraseInDisplay<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}J`;
Clear screen from cursor to beginning, to end of screen, or entire screen.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | 0 (to end of screen), 1 (to beginning of screen), or 2 (entire screen). |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}J`
ED sequence.
Example
1eraseInDisplay(0); // "\u001B[0J" Clear from cursor to end of screen.2eraseInDisplay(1); // "\u001B[1J" Clear from cursor to beginning of screen.3eraseInDisplay(2); // "\u001B[2J" Clear entire screen.
See
eraseInLine()
1function eraseInLine<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}K`;
Erases the line from cursor to beginning, to end of line, or entire line.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | 0 (to end of line), 1 (to beginning of line), or 2 (entire line). |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}K`
EL sequence.
Remarks
input | erases… |
---|---|
0 | …to end of line. |
1 | …to beginning of line. |
2 | …entire line. |
Example
1eraseInLine(0); // "\u001B[0K" Clear from cursor to end of line.2eraseInLine(1); // "\u001B[1K" Clear from cursor to beginning of line.3eraseInLine(2); // "\u001B[2K" Clear entire line.
See
CSI (Control Sequence Introducer) sequences
Foreground
foregroundBlack()
1function foregroundBlack<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[30m${Input extends string ? Input<Input> : string}[39m`;
Black foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[30m${Input extends string ? Input<Input> : string}[39m`
input
string with black foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
black foreground.
Example
1foregroundBlack("Lou"); // "\u001B[30mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBlack`Lou`; // "\u001B[30mLou\u001B[39m"
See
foregroundBlue()
1function foregroundBlue<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[34m${Input extends string ? Input<Input> : string}[39m`;
Blue foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[34m${Input extends string ? Input<Input> : string}[39m`
input
string with blue foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
blue foreground.
Example
1foregroundBlue("Lou"); // "\u001B[34mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBlue`Lou`; // "\u001B[34mLou\u001B[39m"
See
foregroundBrightBlue()
1function foregroundBrightBlue<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[94m${Input extends string ? Input<Input> : string}[39m`;
Bright blue foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[94m${Input extends string ? Input<Input> : string}[39m`
input
string with bright blue foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright blue foreground.
Example
1foregroundBrightBlue("Lou"); // "\u001B[94mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightBlue`Lou`; // "\u001B[94mLou\u001B[39m"
See
foregroundBrightCyan()
1function foregroundBrightCyan<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[96m${Input extends string ? Input<Input> : string}[39m`;
Bright Cyan foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[96m${Input extends string ? Input<Input> : string}[39m`
input
string with bright cyan foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright Cyan foreground.
Example
1foregroundBrightCyan("Lou"); // "\u001B[96mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightCyan`Lou`; // "\u001B[96mLou\u001B[39m"
See
foregroundBrightGreen()
1function foregroundBrightGreen<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[92m${Input extends string ? Input<Input> : string}[39m`;
Bright green foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[92m${Input extends string ? Input<Input> : string}[39m`
input
string with bright green foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright green foreground.
Example
1foregroundBrightGreen("Lou"); // "\u001B[92mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightGreen`Lou`; // "\u001B[92mLou\u001B[39m"
See
foregroundBrightMagenta()
1function foregroundBrightMagenta<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[95m${Input extends string ? Input<Input> : string}[39m`;
Bright magenta foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[95m${Input extends string ? Input<Input> : string}[39m`
input
string with bright magenta foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright magenta foreground.
Example
1foregroundBrightMagenta("Lou"); // "\u001B[95mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightMagenta`Lou`; // "\u001B[95mLou\u001B[39m"
See
foregroundBrightRed()
1function foregroundBrightRed<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[91m${Input extends string ? Input<Input> : string}[39m`;
Bright red foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[91m${Input extends string ? Input<Input> : string}[39m`
input
string with bright red foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright red foreground.
Example
1foregroundBrightRed("Lou"); // "\u001B[91mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightRed`Lou`; // "\u001B[91mLou\u001B[39m"
See
foregroundBrightWhite()
1function foregroundBrightWhite<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[97m${Input extends string ? Input<Input> : string}[39m`;
Bright white foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[97m${Input extends string ? Input<Input> : string}[39m`
input
string with bright white foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright white foreground.
Example
1foregroundBrightWhite("Lou"); // "\u001B[97mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightWhite`Lou`; // "\u001B[97mLou\u001B[39m"
See
foregroundBrightYellow()
1function foregroundBrightYellow<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[93m${Input extends string ? Input<Input> : string}[39m`;
Bright yellow foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[93m${Input extends string ? Input<Input> : string}[39m`
input
string with bright yellow foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bright yellow foreground.
Example
1foregroundBrightYellow("Lou"); // "\u001B[93mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundBrightYellow`Lou`; // "\u001B[93mLou\u001B[39m"
See
foregroundColor()
1function foregroundColor<Open>(2 open: Open,3): <Input>(4 input: Input,5 ...expressions: ReadOnlyArray6) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[39m`;
Foreground color code wrapper.
Type parameters
Type parameter |
---|
Open extends number |
Parameters
Parameter | Type |
---|---|
open | Open |
Returns
Function
Curried function with close
ANSI code for foreground in context.
format function with close
and open
set.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Input string or TemplateStringArray (when using tagged templates). |
…expressions | ReadOnlyArray | Input expressions (when using tagged templates) |
Returns
`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${Open<Open>[0] extends number ? any[any] : ""};${Open<Open>[1] extends number ? any[any] : ""}` : `${Open}`}m${Input extends string ? Input<Input> : string}[39m`
Formatted input
string.
See
Remarks
Takes an open
ANSI code and an input
string and adds the open and close ANSI
codes to that string (for foreground color).
Example
1foregroundColor(13)("Lou"); // "\u001B[13mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundColor(13)`Lou`; // "\u001B[13mLou\u001B[39m"
See
foregroundCyan()
1function foregroundCyan<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[36m${Input extends string ? Input<Input> : string}[39m`;
Cyan foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[36m${Input extends string ? Input<Input> : string}[39m`
input
string with cyan foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
cyan foreground.
Example
1foregroundCyan("Lou"); // "\u001B[36mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundCyan`Lou`; // "\u001B[36mLou\u001B[39m"
See
foregroundGray()
1function foregroundGray<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[90m${Input extends string ? Input<Input> : string}[39m`;
Gray foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[90m${Input extends string ? Input<Input> : string}[39m`
input
string with gray foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
gray foreground.
Example
1foregroundGray("Lou"); // "\u001B[90mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundGray`Lou`; // "\u001B[90mLou\u001B[39m"
See
foregroundGreen()
1function foregroundGreen<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[32m${Input extends string ? Input<Input> : string}[39m`;
Green foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[32m${Input extends string ? Input<Input> : string}[39m`
input
string with green foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
green foreground.
Example
1foregroundGreen("Lou"); // "\u001B[32mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundGreen`Lou`; // "\u001B[32mLou\u001B[39m"
See
foregroundMagenta()
1function foregroundMagenta<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[35m${Input extends string ? Input<Input> : string}[39m`;
Magenta foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[35m${Input extends string ? Input<Input> : string}[39m`
input
string with magenta foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
magenta foreground.
Example
1foregroundMagenta("Lou"); // "\u001B[35mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundMagenta`Lou`; // "\u001B[35mLou\u001B[39m"
See
foregroundRed()
1function foregroundRed<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[31m${Input extends string ? Input<Input> : string}[39m`;
Red foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[31m${Input extends string ? Input<Input> : string}[39m`
input
string with red foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
red foreground.
Example
1foregroundRed("Lou"); // "\u001B[31mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundRed`Lou`; // "\u001B[31mLou\u001B[39m"
See
foregroundWhite()
1function foregroundWhite<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[37m${Input extends string ? Input<Input> : string}[39m`;
White foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[37m${Input extends string ? Input<Input> : string}[39m`
input
string with white foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
white foreground.
Example
1foregroundWhite("Lou"); // "\u001B[37mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundWhite`Lou`; // "\u001B[37mLou\u001B[39m"
See
foregroundYellow()
1function foregroundYellow<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[33m${Input extends string ? Input<Input> : string}[39m`;
Yellow foreground code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[33m${Input extends string ? Input<Input> : string}[39m`
input
string with yellow foreground.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
yellow foreground.
Example
1foregroundYellow("Lou"); // "\u001B[33mLou\u001B[39m"2// It can also be used as a tag function for tagged templates:3foregroundYellow`Lou`; // "\u001B[33mLou\u001B[39m"
See
Scroll
scrollDown()
1function scrollDown<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}S`;
Scroll whole page down by input
lines. New lines are added at the top.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of lines down. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}S`
SD sequence.
Example
1scrollDown(13); // "\u001B[13S"
See
scrollUp()
1function scrollUp<Input>(2 input: Input,3): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}S`;
Scroll whole page up by input
lines. New lines are added at the bottom.
Type parameters
Type parameter |
---|
Input extends number | readonly [Maybe <number >, Maybe <number >] |
Parameters
Parameter | Type | Description |
---|---|---|
input | Input | Amount of lines up. |
Returns
`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${Input<Input>[0] extends number ? any[any] : ""};${Input<Input>[1] extends number ? any[any] : ""}` : `${Input & number}`}S`
SU sequence.
Example
1scrollUp(13); // "\u001B[13S"
See
Text
bold()
1function bold<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[1m${Input extends string ? Input<Input> : string}[22m`;
Bold code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[1m${Input extends string ? Input<Input> : string}[22m`
input
string with bold format.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
bold around it.
Example
1bold("Lou"); // "\u001B[1mLou\u001B[22m"2// It can also be used as a tag function for tagged templates:3bold`Lou`; // "\u001B[1mLou\u001B[22m"
See
dimmed()
1function dimmed<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[2m${Input extends string ? Input<Input> : string}[22m`;
Dimmed code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[2m${Input extends string ? Input<Input> : string}[22m`
input
string with dimmed format.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
dimmed around it.
Example
1dimmed("Lou"); // "\u001B[2mLou\u001B[22m"2// It can also be used as a tag function for tagged templates:3dimmed`Lou`; // "\u001B[2mLou\u001B[22m"
See
inverse()
1function inverse<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[7m${Input extends string ? Input<Input> : string}[27m`;
Inverse code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[7m${Input extends string ? Input<Input> : string}[27m`
input
string with inverse format.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
inverse around it.
Example
1inverse("Lou"); // "\u001B[7mLou\u001B[27m"2// It can also be used as a tag function for tagged templates:3inverse`Lou`; // "\u001B[7mLou\u001B[27m"
See
italic()
1function italic<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[3m${Input extends string ? Input<Input> : string}[23m`;
Italic code wrapper.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[3m${Input extends string ? Input<Input> : string}[23m`
input
string with italic format.
Remarks
Given an input
string, it will return a new string with the ANSI codes for
italic around it.
Example
1italic("Lou"); // "\u001B[3mLou\u001B[23m"2// It can also be used as a tag function for tagged templates:3italic`Lou`; // "\u001B[3mLou\u001B[23m"
See
strikethrough()
1function strikethrough<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[9m${Input extends string ? Input<Input> : string}[29m`;
Takes an input
string and adds the ANSI codes for strikethrough text.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[9m${Input extends string ? Input<Input> : string}[29m`
input
string with strikethrough format.
Example
1strikethrough("Lou"); // "\u001B[9mLou\u001B[29m"2// It can also be used as a tag function for tagged templates:3strikethrough`Lou`; // "\u001B[9mLou\u001B[29m"
See
underlined()
1function underlined<Input>(2 input: Input,3 ...expressions: ReadOnlyArray4): `[4m${Input extends string ? Input<Input> : string}[24m`;
Takes an input
string and adds the ANSI codes for underlined text.
Type parameters
Type parameter |
---|
Input extends string | TemplateStringsArray |
Parameters
Parameter | Type |
---|---|
input | Input |
…expressions | ReadOnlyArray |
Returns
`[4m${Input extends string ? Input<Input> : string}[24m`
input
string with underlined format.
Example
1underlined("Lou"); // "\u001B[4mLou\u001B[24m"2// It can also be used as a tag function for tagged templates:3underlined`Lou`; // "\u001B[4mLou\u001B[24m"