ansi-escapes
- Version 7.2.0
- Published
- 20.8 kB
- 1 dependency
- MIT license
Install
npm i ansi-escapesyarn add ansi-escapespnpm add ansi-escapesOverview
ANSI escape codes for manipulating the terminal
Index
Variables
Functions
Type Aliases
Namespaces
default
- AnnotationOptions
- beep
- clearScreen
- clearTerminal
- clearViewport
- ConEmu
- cursorBackward()
- cursorDown()
- cursorForward()
- cursorGetPosition
- cursorHide
- cursorLeft
- cursorMove()
- cursorNextLine
- cursorPrevLine
- cursorRestorePosition
- cursorSavePosition
- cursorShow
- cursorTo()
- cursorUp()
- enterAlternativeScreen
- eraseDown
- eraseEndLine
- eraseLine
- eraseLines()
- eraseScreen
- eraseStartLine
- eraseUp
- exitAlternativeScreen
- image()
- ImageOptions
- iTerm
- link()
- LiteralUnion
- Primitive
- scrollDown
- scrollUp
- setCwd()
Variables
variable beep
const beep: string;Output a beeping sound.
variable clearScreen
const clearScreen: string;Clear the terminal screen.
⚠️ **Warning:** Uses RIS (Reset to Initial State) which may also: - Clear scrollback buffer in some terminals (xterm.js, VTE) - Reset terminal modes and state - Not behave consistently across different terminals
Consider using
clearViewportfor safer viewport-only clearing.
variable clearTerminal
const clearTerminal: string;Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
variable clearViewport
const clearViewport: string;Clear only the visible terminal screen (viewport) without affecting scrollback buffer or terminal state.
This is a safer alternative to
clearScreenthat works consistently across terminals.
variable ConEmu
const ConEmu: { setCwd(cwd?: string): string };variable cursorGetPosition
const cursorGetPosition: string;Get cursor position.
variable cursorHide
const cursorHide: string;Hide cursor.
variable cursorLeft
const cursorLeft: string;Move cursor to the left side.
variable cursorNextLine
const cursorNextLine: string;Move cursor to the next line.
variable cursorPrevLine
const cursorPrevLine: string;Move cursor to the previous line.
variable cursorRestorePosition
const cursorRestorePosition: string;Restore saved cursor position.
variable cursorSavePosition
const cursorSavePosition: string;Save cursor position.
variable cursorShow
const cursorShow: string;Show cursor.
variable enterAlternativeScreen
const enterAlternativeScreen: string;Enter the [alternative screen](https://terminalguide.namepad.de/mode/p47/).
variable eraseDown
const eraseDown: string;Erase the screen from the current line down to the bottom of the screen.
variable eraseEndLine
const eraseEndLine: string;Erase from the current cursor position to the end of the current line.
variable eraseLine
const eraseLine: string;Erase the entire current line.
variable eraseScreen
const eraseScreen: string;Erase the screen and move the cursor the top left position.
variable eraseStartLine
const eraseStartLine: string;Erase from the current cursor position to the start of the current line.
variable eraseUp
const eraseUp: string;Erase the screen from the current line up to the top of the screen.
variable exitAlternativeScreen
const exitAlternativeScreen: string;Exit the [alternative screen](https://terminalguide.namepad.de/mode/p47/), assuming
enterAlternativeScreenwas called before.
variable iTerm
const iTerm: { setCwd(cwd?: string): string; annotation(message: string, options?: AnnotationOptions): string;};variable scrollDown
const scrollDown: string;Scroll display down one line.
variable scrollUp
const scrollUp: string;Scroll display up one line.
Functions
function cursorBackward
cursorBackward: (count?: number) => string;Move cursor backward a specific amount of rows.
Parameter count
Count of rows to move backward. Default is
1.
function cursorDown
cursorDown: (count?: number) => string;Move cursor down a specific amount of rows.
Parameter count
Count of rows to move down. Default is
1.
function cursorForward
cursorForward: (count?: number) => string;Move cursor forward a specific amount of rows.
Parameter count
Count of rows to move forward. Default is
1.
function cursorMove
cursorMove: (x: number, y?: number) => string;Set the position of the cursor relative to its current position.
function cursorTo
cursorTo: (x: number, y?: number) => string;Set the absolute position of the cursor.
x0y0is the top left of the screen.
function cursorUp
cursorUp: (count?: number) => string;Move cursor up a specific amount of rows.
Parameter count
Count of rows to move up. Default is
1.
function eraseLines
eraseLines: (count: number) => string;Erase from the current cursor position up the specified amount of rows.
Parameter count
Count of rows to erase.
function image
image: (data: Uint8Array, options?: ImageOptions) => string;Display an image.
See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
Parameter data
Image data. Usually read in with
fs.readFile().
function link
link: (text: string, url: string) => string;Create a clickable link.
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [
supports-hyperlinks](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.
function setCwd
setCwd: (cwd?: string) => string;Set the current working directory for both iTerm2 and ConEmu.
Parameter cwd
Current directory. Default:
process.cwd().
Type Aliases
type AnnotationOptions
type AnnotationOptions = { /** Nonzero number of columns to annotate.
Default: The remainder of the line. */ readonly length?: number;
/** Starting X coordinate.
Must be used with `y` and `length`.
Default: The cursor position */ readonly x?: number;
/** Starting Y coordinate.
Must be used with `x` and `length`.
Default: Cursor position. */ readonly y?: number;
/** Create a "hidden" annotation.
Annotations created this way can be shown using the "Show Annotations" iTerm command. */ readonly isHidden?: boolean;};type ImageOptions
type ImageOptions = { /** The width is given as a number followed by a unit, or the word `'auto'`.
- `N`: N character cells. - `Npx`: N pixels. - `N%`: N percent of the session's width or height. - `auto`: The image's inherent size will be used to determine an appropriate dimension. */ readonly width?: LiteralUnion<'auto', number | string>;
/** The height is given as a number followed by a unit, or the word `'auto'`.
- `N`: N character cells. - `Npx`: N pixels. - `N%`: N percent of the session's width or height. - `auto`: The image's inherent size will be used to determine an appropriate dimension. */ readonly height?: LiteralUnion<'auto', number | string>;
/** @default true */ readonly preserveAspectRatio?: boolean;};type LiteralUnion
type LiteralUnion<LiteralType, BaseType extends Primitive> = | LiteralType | (BaseType & Record<never, never>);type Primitive
type Primitive = | null // eslint-disable-line @typescript-eslint/ban-types | undefined | string | number | boolean | symbol | bigint;Namespaces
namespace default
module 'base.d.ts' {}The width is given as a number followed by a unit, or the word
'auto'.-
N: N character cells. -Npx: N pixels. -N%: N percent of the session's width or height. -auto: The image's inherent size will be used to determine an appropriate dimension.
variable beep
const beep: string;Output a beeping sound.
variable clearScreen
const clearScreen: string;Clear the terminal screen.
⚠️ **Warning:** Uses RIS (Reset to Initial State) which may also: - Clear scrollback buffer in some terminals (xterm.js, VTE) - Reset terminal modes and state - Not behave consistently across different terminals
Consider using
clearViewportfor safer viewport-only clearing.
variable clearTerminal
const clearTerminal: string;Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
variable clearViewport
const clearViewport: string;Clear only the visible terminal screen (viewport) without affecting scrollback buffer or terminal state.
This is a safer alternative to
clearScreenthat works consistently across terminals.
variable ConEmu
const ConEmu: { setCwd(cwd?: string): string };variable cursorGetPosition
const cursorGetPosition: string;Get cursor position.
variable cursorHide
const cursorHide: string;Hide cursor.
variable cursorLeft
const cursorLeft: string;Move cursor to the left side.
variable cursorNextLine
const cursorNextLine: string;Move cursor to the next line.
variable cursorPrevLine
const cursorPrevLine: string;Move cursor to the previous line.
variable cursorRestorePosition
const cursorRestorePosition: string;Restore saved cursor position.
variable cursorSavePosition
const cursorSavePosition: string;Save cursor position.
variable cursorShow
const cursorShow: string;Show cursor.
variable enterAlternativeScreen
const enterAlternativeScreen: string;Enter the [alternative screen](https://terminalguide.namepad.de/mode/p47/).
variable eraseDown
const eraseDown: string;Erase the screen from the current line down to the bottom of the screen.
variable eraseEndLine
const eraseEndLine: string;Erase from the current cursor position to the end of the current line.
variable eraseLine
const eraseLine: string;Erase the entire current line.
variable eraseScreen
const eraseScreen: string;Erase the screen and move the cursor the top left position.
variable eraseStartLine
const eraseStartLine: string;Erase from the current cursor position to the start of the current line.
variable eraseUp
const eraseUp: string;Erase the screen from the current line up to the top of the screen.
variable exitAlternativeScreen
const exitAlternativeScreen: string;Exit the [alternative screen](https://terminalguide.namepad.de/mode/p47/), assuming
enterAlternativeScreenwas called before.
variable iTerm
const iTerm: { setCwd(cwd?: string): string; annotation(message: string, options?: AnnotationOptions): string;};variable scrollDown
const scrollDown: string;Scroll display down one line.
variable scrollUp
const scrollUp: string;Scroll display up one line.
function cursorBackward
cursorBackward: (count?: number) => string;Move cursor backward a specific amount of rows.
Parameter count
Count of rows to move backward. Default is
1.
function cursorDown
cursorDown: (count?: number) => string;Move cursor down a specific amount of rows.
Parameter count
Count of rows to move down. Default is
1.
function cursorForward
cursorForward: (count?: number) => string;Move cursor forward a specific amount of rows.
Parameter count
Count of rows to move forward. Default is
1.
function cursorMove
cursorMove: (x: number, y?: number) => string;Set the position of the cursor relative to its current position.
function cursorTo
cursorTo: (x: number, y?: number) => string;Set the absolute position of the cursor.
x0y0is the top left of the screen.
function cursorUp
cursorUp: (count?: number) => string;Move cursor up a specific amount of rows.
Parameter count
Count of rows to move up. Default is
1.
function eraseLines
eraseLines: (count: number) => string;Erase from the current cursor position up the specified amount of rows.
Parameter count
Count of rows to erase.
function image
image: (data: Uint8Array, options?: ImageOptions) => string;Display an image.
See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
Parameter data
Image data. Usually read in with
fs.readFile().
function link
link: (text: string, url: string) => string;Create a clickable link.
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [
supports-hyperlinks](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.
function setCwd
setCwd: (cwd?: string) => string;Set the current working directory for both iTerm2 and ConEmu.
Parameter cwd
Current directory. Default:
process.cwd().
type AnnotationOptions
type AnnotationOptions = { /** Nonzero number of columns to annotate.
Default: The remainder of the line. */ readonly length?: number;
/** Starting X coordinate.
Must be used with `y` and `length`.
Default: The cursor position */ readonly x?: number;
/** Starting Y coordinate.
Must be used with `x` and `length`.
Default: Cursor position. */ readonly y?: number;
/** Create a "hidden" annotation.
Annotations created this way can be shown using the "Show Annotations" iTerm command. */ readonly isHidden?: boolean;};type ImageOptions
type ImageOptions = { /** The width is given as a number followed by a unit, or the word `'auto'`.
- `N`: N character cells. - `Npx`: N pixels. - `N%`: N percent of the session's width or height. - `auto`: The image's inherent size will be used to determine an appropriate dimension. */ readonly width?: LiteralUnion<'auto', number | string>;
/** The height is given as a number followed by a unit, or the word `'auto'`.
- `N`: N character cells. - `Npx`: N pixels. - `N%`: N percent of the session's width or height. - `auto`: The image's inherent size will be used to determine an appropriate dimension. */ readonly height?: LiteralUnion<'auto', number | string>;
/** @default true */ readonly preserveAspectRatio?: boolean;};type LiteralUnion
type LiteralUnion<LiteralType, BaseType extends Primitive> = | LiteralType | (BaseType & Record<never, never>);type Primitive
type Primitive = | null // eslint-disable-line @typescript-eslint/ban-types | undefined | string | number | boolean | symbol | bigint;Package Files (2)
Dependencies (1)
Dev Dependencies (4)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ansi-escapes.
- Markdown[](https://www.jsdocs.io/package/ansi-escapes)
- HTML<a href="https://www.jsdocs.io/package/ansi-escapes"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3658 ms. - Missing or incorrect documentation? Open an issue for this package.
