1 /// <reference types="node"/>
2 import {LiteralUnion} from 'type-fest';
4 declare namespace ansiEscapes {
5 interface ImageOptions {
7 The width is given as a number followed by a unit, or the word `'auto'`.
9 - `N`: N character cells.
11 - `N%`: N percent of the session's width or height.
12 - `auto`: The image's inherent size will be used to determine an appropriate dimension.
14 readonly width?: LiteralUnion<'auto', number | string>;
17 The height is given as a number followed by a unit, or the word `'auto'`.
19 - `N`: N character cells.
21 - `N%`: N percent of the session's width or height.
22 - `auto`: The image's inherent size will be used to determine an appropriate dimension.
24 readonly height?: LiteralUnion<'auto', number | string>;
26 readonly preserveAspectRatio?: boolean;
29 interface AnnotationOptions {
31 Nonzero number of columns to annotate.
33 Default: The remainder of the line.
35 readonly length?: number;
38 Starting X coordinate.
40 Must be used with `y` and `length`.
42 Default: The cursor position
47 Starting Y coordinate.
49 Must be used with `x` and `length`.
51 Default: Cursor position.
56 Create a "hidden" annotation.
58 Annotations created this way can be shown using the "Show Annotations" iTerm command.
60 readonly isHidden?: boolean;
64 declare const ansiEscapes: {
66 Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
68 cursorTo(x: number, y?: number): string;
71 Set the position of the cursor relative to its current position.
73 cursorMove(x: number, y?: number): string;
76 Move cursor up a specific amount of rows.
78 @param count - Count of rows to move up. Default is `1`.
80 cursorUp(count?: number): string;
83 Move cursor down a specific amount of rows.
85 @param count - Count of rows to move down. Default is `1`.
87 cursorDown(count?: number): string;
90 Move cursor forward a specific amount of rows.
92 @param count - Count of rows to move forward. Default is `1`.
94 cursorForward(count?: number): string;
97 Move cursor backward a specific amount of rows.
99 @param count - Count of rows to move backward. Default is `1`.
101 cursorBackward(count?: number): string;
104 Move cursor to the left side.
109 Save cursor position.
111 cursorSavePosition: string;
114 Restore saved cursor position.
116 cursorRestorePosition: string;
121 cursorGetPosition: string;
124 Move cursor to the next line.
126 cursorNextLine: string;
129 Move cursor to the previous line.
131 cursorPrevLine: string;
144 Erase from the current cursor position up the specified amount of rows.
146 @param count - Count of rows to erase.
148 eraseLines(count: number): string;
151 Erase from the current cursor position to the end of the current line.
153 eraseEndLine: string;
156 Erase from the current cursor position to the start of the current line.
158 eraseStartLine: string;
161 Erase the entire current line.
166 Erase the screen from the current line down to the bottom of the screen.
171 Erase the screen from the current line up to the top of the screen.
176 Erase the screen and move the cursor the top left position.
181 Scroll display up one line.
186 Scroll display down one line.
191 Clear the terminal screen. (Viewport)
196 Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
198 clearTerminal: string;
201 Output a beeping sound.
206 Create a clickable link.
208 [Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.
210 link(text: string, url: string): string;
215 _Currently only supported on iTerm2 >=3_
217 See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
219 @param buffer - Buffer of an image. Usually read in with `fs.readFile()`.
221 image(buffer: Buffer, options?: ansiEscapes.ImageOptions): string;
225 [Inform iTerm2](https://www.iterm2.com/documentation-escape-codes.html) of the current directory to help semantic history and enable [Cmd-clicking relative paths](https://coderwall.com/p/b7e82q/quickly-open-files-in-iterm-with-cmd-click).
227 @param cwd - Current directory. Default: `process.cwd()`.
229 setCwd(cwd?: string): string;
232 An annotation looks like this when shown:
234 ![screenshot of iTerm annotation](https://user-images.githubusercontent.com/924465/64382136-b60ac700-cfe9-11e9-8a35-9682e8dc4b72.png)
236 See the [iTerm Proprietary Escape Codes documentation](https://iterm2.com/documentation-escape-codes.html) for more information.
238 @param message - The message to display within the annotation. The `|` character is disallowed and will be stripped.
239 @returns An escape code which will create an annotation when printed in iTerm2.
241 annotation(message: string, options?: ansiEscapes.AnnotationOptions): string;
244 // TODO: remove this in the next major version
245 default: typeof ansiEscapes;
248 export = ansiEscapes;