ANSI Reference
📟 Functional CLI ANSI formatting functions.
Usage
📦 Node
Install @lou.codes/ansi
as a dependency:
Import it and use it:
🦕 Deno
Import @lou.codes/ansi
using the npm:
prefix, and use it directly:
🌎 Browser
Import @lou.codes/ansi
using esm.sh, and use it directly:
Useful links
- 📝 Documentation: TypeDoc generated documentation.
- ⏳ Changelog: List of changes between versions.
- ✅ Tests Coverage: Coveralls page with tests coverage.
Background
backgroundBlack()
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
See
backgroundBlue()
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
See
backgroundBrightBlue()
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
See
backgroundBrightCyan()
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
See
backgroundBrightGreen()
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
See
backgroundBrightMagenta()
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
See
backgroundBrightRed()
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
See
backgroundBrightWhite()
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
See
backgroundBrightYellow()
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
See
backgroundColor()
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
See
backgroundCyan()
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
See
backgroundGray()
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
See
backgroundGreen()
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
See
backgroundMagenta()
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
See
backgroundRed()
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
See
backgroundWhite()
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
See
backgroundYellow()
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
See
Common
Formatter()
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
See
Parameters
Parameter | Type |
---|---|
templateStrings | TemplateStringsArray | string |
…expressions | ReadOnlyArray |
Returns
string
resetToInitialState
RIS sequence.
Remarks
Resets the entire screen to initial state.
Example
See
controlSequenceIntroducer()
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
See
escapeSequence()
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
See
format()
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
See
mix()
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
See
normalizeString()
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
See
optionalFormat()
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
See
selectGraphicRendition()
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
See
Cursor
cursorBack()
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
See
cursorDown()
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
See
cursorForward()
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
See
cursorHorizontalAbsolute()
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
See
cursorNextLine()
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
See
cursorPosition()
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
See
cursorPreviousLine()
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
See
cursorUp()
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
See
Erase
eraseInDisplay()
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
See
eraseInLine()
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
See
CSI (Control Sequence Introducer) sequences
Foreground
foregroundBlack()
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
See
foregroundBlue()
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
See
foregroundBrightBlue()
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
See
foregroundBrightCyan()
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
See
foregroundBrightGreen()
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
See
foregroundBrightMagenta()
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
See
foregroundBrightRed()
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
See
foregroundBrightWhite()
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
See
foregroundBrightYellow()
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
See
foregroundColor()
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
See
foregroundCyan()
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
See
foregroundGray()
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
See
foregroundGreen()
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
See
foregroundMagenta()
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
See
foregroundRed()
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
See
foregroundWhite()
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
See
foregroundYellow()
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
See
Scroll
scrollDown()
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
See
scrollUp()
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
See
Text
bold()
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
See
dimmed()
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
See
inverse()
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
See
italic()
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
See
strikethrough()
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
See
underlined()
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.