1 | /* eslint-disable @typescript-eslint/member-ordering */
|
2 | import {LiteralUnion} from 'type-fest';
|
3 |
|
4 | export interface ImageOptions {
|
5 | /**
|
6 | The width is given as a number followed by a unit, or the word `'auto'`.
|
7 |
|
8 | - `N`: N character cells.
|
9 | - `Npx`: N pixels.
|
10 | - `N%`: N percent of the session's width or height.
|
11 | - `auto`: The image's inherent size will be used to determine an appropriate dimension.
|
12 | */
|
13 | readonly width?: LiteralUnion<'auto', number | string>;
|
14 |
|
15 | /**
|
16 | The height is given as a number followed by a unit, or the word `'auto'`.
|
17 |
|
18 | - `N`: N character cells.
|
19 | - `Npx`: N pixels.
|
20 | - `N%`: N percent of the session's width or height.
|
21 | - `auto`: The image's inherent size will be used to determine an appropriate dimension.
|
22 | */
|
23 | readonly height?: LiteralUnion<'auto', number | string>;
|
24 |
|
25 | readonly preserveAspectRatio?: boolean;
|
26 | }
|
27 |
|
28 | export interface AnnotationOptions {
|
29 | /**
|
30 | Nonzero number of columns to annotate.
|
31 |
|
32 | Default: The remainder of the line.
|
33 | */
|
34 | readonly length?: number;
|
35 |
|
36 | /**
|
37 | Starting X coordinate.
|
38 |
|
39 | Must be used with `y` and `length`.
|
40 |
|
41 | Default: The cursor position
|
42 | */
|
43 | readonly x?: number;
|
44 |
|
45 | /**
|
46 | Starting Y coordinate.
|
47 |
|
48 | Must be used with `x` and `length`.
|
49 |
|
50 | Default: Cursor position.
|
51 | */
|
52 | readonly y?: number;
|
53 |
|
54 | /**
|
55 | Create a "hidden" annotation.
|
56 |
|
57 | Annotations created this way can be shown using the "Show Annotations" iTerm command.
|
58 | */
|
59 | readonly isHidden?: boolean;
|
60 | }
|
61 |
|
62 | declare const ansiEscapes: {
|
63 | /**
|
64 | Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
|
65 | */
|
66 | cursorTo(x: number, y?: number): string;
|
67 |
|
68 | /**
|
69 | Set the position of the cursor relative to its current position.
|
70 | */
|
71 | cursorMove(x: number, y?: number): string;
|
72 |
|
73 | /**
|
74 | Move cursor up a specific amount of rows.
|
75 |
|
76 | @param count - Count of rows to move up. Default is `1`.
|
77 | */
|
78 | cursorUp(count?: number): string;
|
79 |
|
80 | /**
|
81 | Move cursor down a specific amount of rows.
|
82 |
|
83 | @param count - Count of rows to move down. Default is `1`.
|
84 | */
|
85 | cursorDown(count?: number): string;
|
86 |
|
87 | /**
|
88 | Move cursor forward a specific amount of rows.
|
89 |
|
90 | @param count - Count of rows to move forward. Default is `1`.
|
91 | */
|
92 | cursorForward(count?: number): string;
|
93 |
|
94 | /**
|
95 | Move cursor backward a specific amount of rows.
|
96 |
|
97 | @param count - Count of rows to move backward. Default is `1`.
|
98 | */
|
99 | cursorBackward(count?: number): string;
|
100 |
|
101 | /**
|
102 | Move cursor to the left side.
|
103 | */
|
104 | cursorLeft: string;
|
105 |
|
106 | /**
|
107 | Save cursor position.
|
108 | */
|
109 | cursorSavePosition: string;
|
110 |
|
111 | /**
|
112 | Restore saved cursor position.
|
113 | */
|
114 | cursorRestorePosition: string;
|
115 |
|
116 | /**
|
117 | Get cursor position.
|
118 | */
|
119 | cursorGetPosition: string;
|
120 |
|
121 | /**
|
122 | Move cursor to the next line.
|
123 | */
|
124 | cursorNextLine: string;
|
125 |
|
126 | /**
|
127 | Move cursor to the previous line.
|
128 | */
|
129 | cursorPrevLine: string;
|
130 |
|
131 | /**
|
132 | Hide cursor.
|
133 | */
|
134 | cursorHide: string;
|
135 |
|
136 | /**
|
137 | Show cursor.
|
138 | */
|
139 | cursorShow: string;
|
140 |
|
141 | /**
|
142 | Erase from the current cursor position up the specified amount of rows.
|
143 |
|
144 | @param count - Count of rows to erase.
|
145 | */
|
146 | eraseLines(count: number): string;
|
147 |
|
148 | /**
|
149 | Erase from the current cursor position to the end of the current line.
|
150 | */
|
151 | eraseEndLine: string;
|
152 |
|
153 | /**
|
154 | Erase from the current cursor position to the start of the current line.
|
155 | */
|
156 | eraseStartLine: string;
|
157 |
|
158 | /**
|
159 | Erase the entire current line.
|
160 | */
|
161 | eraseLine: string;
|
162 |
|
163 | /**
|
164 | Erase the screen from the current line down to the bottom of the screen.
|
165 | */
|
166 | eraseDown: string;
|
167 |
|
168 | /**
|
169 | Erase the screen from the current line up to the top of the screen.
|
170 | */
|
171 | eraseUp: string;
|
172 |
|
173 | /**
|
174 | Erase the screen and move the cursor the top left position.
|
175 | */
|
176 | eraseScreen: string;
|
177 |
|
178 | /**
|
179 | Scroll display up one line.
|
180 | */
|
181 | scrollUp: string;
|
182 |
|
183 | /**
|
184 | Scroll display down one line.
|
185 | */
|
186 | scrollDown: string;
|
187 |
|
188 | /**
|
189 | Clear the terminal screen. (Viewport)
|
190 | */
|
191 | clearScreen: string;
|
192 |
|
193 | /**
|
194 | Clear the whole terminal, including scrollback buffer. (Not just the visible part of it)
|
195 | */
|
196 | clearTerminal: string;
|
197 |
|
198 | /**
|
199 | Output a beeping sound.
|
200 | */
|
201 | beep: string;
|
202 |
|
203 | /**
|
204 | Create a clickable link.
|
205 |
|
206 | [Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) Use [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks) to detect link support.
|
207 | */
|
208 | link(text: string, url: string): string;
|
209 |
|
210 | /**
|
211 | Display an image.
|
212 |
|
213 | _Currently only supported on iTerm2 >=3_
|
214 |
|
215 | See [term-img](https://github.com/sindresorhus/term-img) for a higher-level module.
|
216 |
|
217 | @param buffer - Buffer of an image. Usually read in with `fs.readFile()`.
|
218 | */
|
219 | image(buffer: Buffer, options?: ImageOptions): string;
|
220 |
|
221 | iTerm: {
|
222 | /**
|
223 | [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).
|
224 |
|
225 | @param cwd - Current directory. Default: `process.cwd()`.
|
226 | */
|
227 | setCwd(cwd?: string): string;
|
228 |
|
229 | /**
|
230 | An annotation looks like this when shown:
|
231 |
|
232 | ![screenshot of iTerm annotation](https://user-images.githubusercontent.com/924465/64382136-b60ac700-cfe9-11e9-8a35-9682e8dc4b72.png)
|
233 |
|
234 | See the [iTerm Proprietary Escape Codes documentation](https://iterm2.com/documentation-escape-codes.html) for more information.
|
235 |
|
236 | @param message - The message to display within the annotation. The `|` character is disallowed and will be stripped.
|
237 | @returns An escape code which will create an annotation when printed in iTerm2.
|
238 | */
|
239 | annotation(message: string, options?: AnnotationOptions): string;
|
240 | };
|
241 | };
|
242 |
|
243 | export default ansiEscapes;
|