@visulima/ansi 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE.md +3 -0
- package/dist/alternative-screen.d.ts +74 -6
- package/dist/clear.d.ts +77 -6
- package/dist/constants.d.ts +20 -0
- package/dist/cursor.d.ts +429 -48
- package/dist/erase.d.ts +197 -14
- package/dist/helpers.d.ts +14 -0
- package/dist/hyperlink.d.ts +26 -2
- package/dist/image.d.ts +69 -7
- package/dist/index.d.ts +36 -30
- package/dist/iterm2/iterm2-properties.d.ts +135 -0
- package/dist/iterm2/iterm2-sequences.d.ts +96 -0
- package/dist/iterm2.d.ts +58 -43
- package/dist/mode.d.ts +717 -174
- package/dist/mouse.d.ts +203 -21
- package/dist/passthrough.d.ts +77 -6
- package/dist/progress.d.ts +41 -0
- package/dist/reset.d.ts +26 -4
- package/dist/screen.d.ts +234 -11
- package/dist/scroll.d.ts +67 -6
- package/dist/status.d.ts +521 -48
- package/dist/strip.d.ts +22 -2
- package/dist/termcap.d.ts +38 -5
- package/dist/title.d.ts +185 -10
- package/dist/window-ops.d.ts +396 -24
- package/dist/xterm.d.ts +94 -12
- package/package.json +1 -4
package/dist/cursor.d.ts
CHANGED
|
@@ -1,56 +1,437 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
declare const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
declare const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
declare const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
* Saves the cursor position, character attributes (like color, intensity), and character set (G0-G3).
|
|
3
|
+
* This is the DECSC (Save Cursor) sequence: `ESC 7`.
|
|
4
|
+
* Used in conjunction with {@link RESTORE_CURSOR_DEC} (`ESC 8`) to restore the saved state.
|
|
5
|
+
* @remarks This is a DEC private sequence, widely supported.
|
|
6
|
+
* For SCO-compatible terminals (like Linux console before full ANSI/VT support, or some older Unix systems),
|
|
7
|
+
* `ESC s` ({@link cursorSave}) might be used for a similar purpose, though DECSC/DECRC are more comprehensive.
|
|
8
|
+
* @see {@link RESTORE_CURSOR_DEC}
|
|
9
|
+
* @see {@link cursorSave} (provides a version that adapts to Terminal.app)
|
|
10
|
+
*/
|
|
11
|
+
export declare const SAVE_CURSOR_DEC: string;
|
|
12
|
+
/**
|
|
13
|
+
* Restores the previously saved cursor position, character attributes, and character set.
|
|
14
|
+
* This is the DECRC (Restore Cursor) sequence: `ESC 8`.
|
|
15
|
+
* Used after {@link SAVE_CURSOR_DEC} (`ESC 7`) has saved the state.
|
|
16
|
+
* @remarks This is a DEC private sequence, widely supported.
|
|
17
|
+
* For SCO-compatible terminals, `ESC u` ({@link cursorRestore}) might be used.
|
|
18
|
+
* @see {@link SAVE_CURSOR_DEC}
|
|
19
|
+
* @see {@link cursorRestore} (provides a version that adapts to Terminal.app)
|
|
20
|
+
*/
|
|
21
|
+
export declare const RESTORE_CURSOR_DEC: string;
|
|
22
|
+
/**
|
|
23
|
+
* Moves the cursor up one line in the same column. If the cursor is at the top line, behavior is undefined (may ignore or scroll).
|
|
24
|
+
* This is the CUU (Cursor Up) sequence: `CSI A` (equivalent to `CSI 1A`).
|
|
25
|
+
* @see {@link cursorUp} for moving multiple lines or with a count.
|
|
26
|
+
* @see {@link CURSOR_DOWN_1}
|
|
27
|
+
* @see {@link CURSOR_FORWARD_1}
|
|
28
|
+
* @see {@link CURSOR_BACKWARD_1}
|
|
29
|
+
*/
|
|
30
|
+
export declare const CURSOR_UP_1: string;
|
|
31
|
+
/**
|
|
32
|
+
* Moves the cursor down one line in the same column. If the cursor is at the bottom line, behavior is undefined (may ignore or scroll).
|
|
33
|
+
* This is the CUD (Cursor Down) sequence: `CSI B` (equivalent to `CSI 1B`).
|
|
34
|
+
* @see {@link cursorDown} for moving multiple lines or with a count.
|
|
35
|
+
* @see {@link CURSOR_UP_1}
|
|
36
|
+
* @see {@link CURSOR_FORWARD_1}
|
|
37
|
+
* @see {@link CURSOR_BACKWARD_1}
|
|
38
|
+
*/
|
|
39
|
+
export declare const CURSOR_DOWN_1: string;
|
|
40
|
+
/**
|
|
41
|
+
* Moves the cursor forward (right) one column in the same line. If the cursor is at the rightmost column, behavior is terminal-dependent (may wrap if DECAWM is set, or ignore).
|
|
42
|
+
* This is the CUF (Cursor Forward) sequence: `CSI C` (equivalent to `CSI 1C`).
|
|
43
|
+
* @see {@link cursorForward} for moving multiple columns or with a count.
|
|
44
|
+
* @see {@link CURSOR_UP_1}
|
|
45
|
+
* @see {@link CURSOR_DOWN_1}
|
|
46
|
+
* @see {@link CURSOR_BACKWARD_1}
|
|
47
|
+
*/
|
|
48
|
+
export declare const CURSOR_FORWARD_1: string;
|
|
49
|
+
/**
|
|
50
|
+
* Moves the cursor backward (left) one column in the same line. If the cursor is at the leftmost column, behavior is undefined (may ignore).
|
|
51
|
+
* This is the CUB (Cursor Backward) sequence: `CSI D` (equivalent to `CSI 1D`).
|
|
52
|
+
* @see {@link cursorBackward} for moving multiple columns or with a count.
|
|
53
|
+
* @see {@link CURSOR_UP_1}
|
|
54
|
+
* @see {@link CURSOR_DOWN_1}
|
|
55
|
+
* @see {@link CURSOR_FORWARD_1}
|
|
56
|
+
*/
|
|
57
|
+
export declare const CURSOR_BACKWARD_1: string;
|
|
58
|
+
/**
|
|
59
|
+
* Asks the terminal to report its current cursor position using the DSR (Device Status Report) sequence.
|
|
60
|
+
* The sequence sent is `CSI 6n`.
|
|
61
|
+
* The terminal is expected to respond with a CPR (Cursor Position Report) sequence in the format `CSI <row>;<col>R`,
|
|
62
|
+
* where `<row>` and `<col>` are 1-indexed coordinates.
|
|
63
|
+
* @remarks
|
|
64
|
+
* This is an active report, meaning the application sends a request and waits for a response from the terminal
|
|
65
|
+
* via standard input.
|
|
66
|
+
* Parsing the response requires reading from `stdin` and interpreting the escape sequence.
|
|
67
|
+
* @see {@link REQUEST_EXTENDED_CURSOR_POSITION} for a version that might include page number.
|
|
68
|
+
* @see {@link https://vt100.net/docs/vt510-rm/DSR-CPR.html} DSR/CPR documentation.
|
|
69
|
+
* @returns The ANSI escape sequence `CSI 6n`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const REQUEST_CURSOR_POSITION: string;
|
|
72
|
+
/**
|
|
73
|
+
* Asks the terminal to report its extended cursor position, potentially including the page number.
|
|
74
|
+
* The sequence sent is `CSI ?6n` (a DEC private DSR variant).
|
|
75
|
+
* The response format from the terminal is typically `CSI ? <row>;<col>;<page>R` (1-indexed).
|
|
76
|
+
* If the terminal does not support this extended version, it might fall back to the standard DSR response
|
|
77
|
+
* or not respond in a recognizable way.
|
|
78
|
+
* @remarks
|
|
79
|
+
* Support for this DEC private DSR is less universal than the standard `CSI 6n`.
|
|
80
|
+
* It's generally used in contexts where page numbers (e.g., in a multi-page document or buffer)
|
|
81
|
+
* are relevant.
|
|
82
|
+
* @see {@link REQUEST_CURSOR_POSITION} for the standard cursor position report.
|
|
83
|
+
* @returns The ANSI escape sequence `CSI ?6n`.
|
|
84
|
+
*/
|
|
85
|
+
export declare const REQUEST_EXTENDED_CURSOR_POSITION: string;
|
|
86
|
+
/**
|
|
87
|
+
* Moves the cursor backward (left) a specific number of columns from its current position.
|
|
88
|
+
* This uses the CUB (Cursor Backward) sequence: `CSI <count>D`.
|
|
89
|
+
* @param count The number of columns to move backward. Must be a positive integer. Defaults to `1`.
|
|
90
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
91
|
+
* @returns The ANSI escape sequence for moving the cursor backward.
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* cursorBackward(5); // Moves cursor 5 columns to the left.
|
|
95
|
+
* cursorBackward(); // Moves cursor 1 column to the left.
|
|
96
|
+
* ```
|
|
97
|
+
* @see {@link CURSOR_BACKWARD_1}
|
|
98
|
+
* @see {@link cursorForward}
|
|
99
|
+
* @see {@link cursorLeft} (alias for this function)
|
|
100
|
+
*/
|
|
101
|
+
export declare const cursorBackward: (count?: number) => string;
|
|
102
|
+
/**
|
|
103
|
+
* Moves the cursor down a specific number of rows from its current position, staying in the same column.
|
|
104
|
+
* This uses the CUD (Cursor Down) sequence: `CSI <count>B`.
|
|
105
|
+
* @param count The number of rows to move down. Must be a positive integer. Defaults to `1`.
|
|
106
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
107
|
+
* @returns The ANSI escape sequence for moving the cursor down.
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* cursorDown(3); // Moves cursor 3 rows down.
|
|
111
|
+
* cursorDown(); // Moves cursor 1 row down.
|
|
112
|
+
* ```
|
|
113
|
+
* @see {@link CURSOR_DOWN_1}
|
|
114
|
+
* @see {@link cursorUp}
|
|
115
|
+
*/
|
|
116
|
+
export declare const cursorDown: (count?: number) => string;
|
|
117
|
+
/**
|
|
118
|
+
* Moves the cursor forward (right) a specific number of columns from its current position.
|
|
119
|
+
* This uses the CUF (Cursor Forward) sequence: `CSI <count>C`.
|
|
120
|
+
* @param count The number of columns to move forward. Must be a positive integer. Defaults to `1`.
|
|
121
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
122
|
+
* @returns The ANSI escape sequence for moving the cursor forward.
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* cursorForward(4); // Moves cursor 4 columns to the right.
|
|
126
|
+
* cursorForward(); // Moves cursor 1 column to the right.
|
|
127
|
+
* ```
|
|
128
|
+
* @see {@link CURSOR_FORWARD_1}
|
|
129
|
+
* @see {@link cursorBackward}
|
|
130
|
+
*/
|
|
131
|
+
export declare const cursorForward: (count?: number) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Hides the cursor. This uses the DECTCEM (Text Cursor Enable Mode) sequence `CSI ?25l` to set the mode to "invisible".
|
|
134
|
+
* @remarks
|
|
135
|
+
* This is a DEC private mode. Visibility can be restored using {@link cursorShow} (`CSI ?25h`).
|
|
136
|
+
* The appearance of the cursor (when visible) can often be controlled by {@link setCursorStyle}.
|
|
137
|
+
* @see {@link cursorShow}
|
|
138
|
+
* @see {@link TextCursorEnableMode} in `mode.ts` (represents DEC Mode 25).
|
|
139
|
+
* @returns The ANSI escape sequence `CSI ?25l`.
|
|
140
|
+
*/
|
|
141
|
+
export declare const cursorHide: string;
|
|
142
|
+
/**
|
|
143
|
+
* Moves the cursor to column 1 (the beginning) of the current line.
|
|
144
|
+
* This uses the CHA (Cursor Horizontal Absolute) sequence `CSI G` (equivalent to `CSI 1G`).
|
|
145
|
+
* @remarks
|
|
146
|
+
* This is different from a carriage return (`\r` or `CR`), which also moves to the beginning
|
|
147
|
+
* of the line but can have other side effects (like overprinting) in some contexts.
|
|
148
|
+
* `CSI G` specifically sets the horizontal position.
|
|
149
|
+
* @see {@link cursorHorizontalAbsolute} for moving to any absolute column.
|
|
150
|
+
* @returns The ANSI escape sequence `CSI G`.
|
|
151
|
+
*/
|
|
152
|
+
export declare const cursorToColumn1: string;
|
|
153
|
+
/**
|
|
154
|
+
* Moves the cursor left by `count` columns. This is an alias for {@link cursorBackward}.
|
|
155
|
+
* Sequence: `CSI <count>D`.
|
|
156
|
+
* @param count The number of columns to move left. Defaults to `1`.
|
|
157
|
+
* @returns The ANSI escape sequence.
|
|
158
|
+
* @see {@link cursorBackward}
|
|
159
|
+
*/
|
|
160
|
+
export declare const cursorLeft: (count?: number) => string;
|
|
161
|
+
/**
|
|
162
|
+
* Moves the cursor to the specified absolute horizontal column `column` (1-indexed) on the current line.
|
|
163
|
+
* This uses the CHA (Cursor Horizontal Absolute) sequence: `CSI <column>G`.
|
|
164
|
+
* @param column The 1-indexed column number to move to. E.g., `1` for the first column.
|
|
165
|
+
* If `column` is less than 1, behavior is terminal-dependent (often treated as 1).
|
|
166
|
+
* Defaults to `1` if not provided.
|
|
167
|
+
* @returns The ANSI escape sequence.
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* cursorHorizontalAbsolute(10); // Moves to column 10 of the current line.
|
|
171
|
+
* cursorHorizontalAbsolute(); // Moves to column 1 of the current line.
|
|
172
|
+
* ```
|
|
173
|
+
* @see {@link cursorToColumn1} (moves to column 1 specifically).
|
|
174
|
+
* @see {@link cursorTo} for moving to an (x,y) coordinate, which can also use CHA for x-only movement.
|
|
175
|
+
*/
|
|
176
|
+
export declare const cursorHorizontalAbsolute: (column?: number) => string;
|
|
177
|
+
/**
|
|
178
|
+
* Moves the cursor relative to its current position by `x` columns and `y` rows.
|
|
179
|
+
*
|
|
180
|
+
* This function combines CUU (Up), CUD (Down), CUF (Forward), and CUB (Backward) sequences
|
|
181
|
+
* as needed based on the signs and magnitudes of `x` and `y`.
|
|
182
|
+
*
|
|
183
|
+
* - Positive `x` moves right (CUF: `CSI <x>C`).
|
|
184
|
+
* - Negative `x` moves left (CUB: `CSI <-x>D`).
|
|
185
|
+
* - Positive `y` moves down (CUD: `CSI <y>B`).
|
|
186
|
+
* - Negative `y` moves up (CUU: `CSI <-y>A`).
|
|
187
|
+
*
|
|
188
|
+
* If both `x` and `y` are 0, an empty string is returned as no movement is needed.
|
|
189
|
+
* @param x The number of columns to move. Positive values move right, negative values move left.
|
|
190
|
+
* @param y The number of rows to move. Positive values move down, negative values move up.
|
|
191
|
+
* @returns A string containing the necessary ANSI escape sequence(s) to perform the relative move,
|
|
192
|
+
* or an empty string if no movement (`x=0`, `y=0`).
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* console.log(cursorMove(5, -2)); // Moves 5 columns right and 2 rows up.
|
|
196
|
+
* // Output: CSI 5C CSI 2A (or similar)
|
|
197
|
+
* console.log(cursorMove(-3, 0)); // Moves 3 columns left.
|
|
198
|
+
* // Output: CSI 3D
|
|
199
|
+
* console.log(cursorMove(0, 4)); // Moves 4 rows down.
|
|
200
|
+
* // Output: CSI 4B
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare const cursorMove: (x: number, y: number) => string;
|
|
204
|
+
/**
|
|
205
|
+
* Moves the cursor to the beginning (column 1) of the next line, `count` times.
|
|
206
|
+
* This uses the CNL (Cursor Next Line) sequence: `CSI <count>E`.
|
|
207
|
+
* @param count The number of lines to move down. Defaults to `1`.
|
|
208
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
209
|
+
* @returns The ANSI escape sequence.
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* cursorNextLine(2); // Moves to the beginning of the line 2 lines down.
|
|
213
|
+
* cursorNextLine(); // Moves to the beginning of the next line.
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare const cursorNextLine: (count?: number) => string;
|
|
217
|
+
/**
|
|
218
|
+
* Moves the cursor to the beginning (column 1) of the previous line, `count` times.
|
|
219
|
+
* This uses the CPL (Cursor Previous Line) sequence: `CSI <count>F`.
|
|
220
|
+
* @param count The number of lines to move up. Defaults to `1`.
|
|
221
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
222
|
+
* @returns The ANSI escape sequence.
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* cursorPreviousLine(3); // Moves to the beginning of the line 3 lines up.
|
|
226
|
+
* cursorPreviousLine(); // Moves to the beginning of the previous line.
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
export declare const cursorPreviousLine: (count?: number) => string;
|
|
230
|
+
/**
|
|
231
|
+
* Restores the last saved cursor position, character attributes (like color and style),
|
|
232
|
+
* and character set state (G0-G3 mapping).
|
|
233
|
+
*
|
|
234
|
+
* This function adapts to the environment:
|
|
235
|
+
* - For Apple's Terminal.app (and environments where `isTerminalApp` is true),
|
|
236
|
+
* it uses DECRC (`ESC 8`, see {@link RESTORE_CURSOR_DEC}).
|
|
237
|
+
* - For other terminals (typically SCO-compatible or more standard ANSI environments),
|
|
238
|
+
* it uses SCOSRC (`ESC u`).
|
|
239
|
+
* @remarks
|
|
240
|
+
* `DECSC`/`DECRC` (`ESC 7`/`ESC 8`) are generally more comprehensive and widely supported for full state saving/restoring
|
|
241
|
+
* in VT100+ compatible terminals.
|
|
242
|
+
* `SCOSC`/`SCOSRC` (`ESC s`/`ESC u`) are from the SCO console world and might save/restore fewer attributes.
|
|
243
|
+
* @returns The ANSI escape sequence for restoring the cursor state, adapted to the terminal environment.
|
|
244
|
+
* @see {@link cursorSave} for the corresponding save operation.
|
|
245
|
+
* @see {@link SAVE_CURSOR_DEC}
|
|
246
|
+
* @see {@link RESTORE_CURSOR_DEC}
|
|
247
|
+
* @see {@link isTerminalApp}
|
|
248
|
+
*/
|
|
249
|
+
export declare const cursorRestore: string;
|
|
250
|
+
/**
|
|
251
|
+
* Saves the current cursor position, character attributes, and character set state.
|
|
252
|
+
*
|
|
253
|
+
* This function adapts to the environment:
|
|
254
|
+
* - For Apple's Terminal.app (and environments where `isTerminalApp` is true),
|
|
255
|
+
* it uses DECSC (`ESC 7`, see {@link SAVE_CURSOR_DEC}).
|
|
256
|
+
* - For other terminals, it uses SCOSC (`ESC s`).
|
|
257
|
+
* @returns The ANSI escape sequence for saving the cursor state, adapted to the terminal environment.
|
|
258
|
+
* @see {@link cursorRestore} for the corresponding restore operation.
|
|
259
|
+
* @see {@link SAVE_CURSOR_DEC}
|
|
260
|
+
* @see {@link RESTORE_CURSOR_DEC}
|
|
261
|
+
* @see {@link isTerminalApp}
|
|
262
|
+
*/
|
|
263
|
+
export declare const cursorSave: string;
|
|
264
|
+
/**
|
|
265
|
+
* Shows the cursor. This uses the DECTCEM (Text Cursor Enable Mode) sequence `CSI ?25h` to set the mode to "visible".
|
|
266
|
+
* @remarks
|
|
267
|
+
* This is a DEC private mode. Visibility can be hidden using {@link cursorHide} (`CSI ?25l`).
|
|
268
|
+
* The appearance of the cursor (when visible) can often be controlled by {@link setCursorStyle}.
|
|
269
|
+
* @see {@link cursorHide}
|
|
270
|
+
* @see {@link TextCursorEnableMode} in `mode.ts` (represents DEC Mode 25).
|
|
271
|
+
* @returns The ANSI escape sequence `CSI ?25h`.
|
|
272
|
+
*/
|
|
273
|
+
export declare const cursorShow: string;
|
|
274
|
+
/**
|
|
275
|
+
* Moves the cursor to a specific coordinate (0-indexed) on the screen.
|
|
276
|
+
* The top-left corner of the screen is `(x: 0, y: 0)`.
|
|
277
|
+
*
|
|
278
|
+
* - If both `x` (column) and `y` (row) are provided, it uses the CUP (Cursor Position)
|
|
279
|
+
* sequence: `CSI <y+1>;<x+1>H`. Note that CUP is 1-indexed.
|
|
280
|
+
* - If only `x` (column) is provided (or `y` is `undefined`), it moves the cursor horizontally
|
|
281
|
+
* to the absolute column `x` on the current line. This uses the CHA (Cursor Horizontal Absolute)
|
|
282
|
+
* sequence: `CSI <x+1>G`. Note that CHA is 1-indexed.
|
|
283
|
+
* @param x The 0-indexed column number. `0` is the leftmost column.
|
|
284
|
+
* @param y (Optional) The 0-indexed row number. `0` is the topmost row.
|
|
285
|
+
* If undefined, only horizontal movement to column `x` occurs.
|
|
286
|
+
* @returns The ANSI escape sequence for moving the cursor.
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* cursorTo(0, 0); // Moves to top-left (row 0, col 0) -> CSI 1;1H
|
|
290
|
+
* cursorTo(10, 5); // Moves to row 5, col 10 -> CSI 6;11H
|
|
291
|
+
* cursorTo(7); // Moves to column 7 of the current line -> CSI 8G
|
|
292
|
+
* ```
|
|
293
|
+
* @see {@link cursorPosition} for a 1-indexed version of CUP.
|
|
294
|
+
* @see {@link cursorHorizontalAbsolute} for 1-indexed horizontal positioning.
|
|
295
|
+
*/
|
|
296
|
+
export declare const cursorTo: (x: number, y?: number) => string;
|
|
297
|
+
/**
|
|
298
|
+
* Moves the cursor to a specific position (1-indexed) on the screen using the CUP (Cursor Position) sequence.
|
|
299
|
+
* The top-left corner of the screen is `(row: 1, column: 1)`.
|
|
300
|
+
*
|
|
301
|
+
* - If `column` is provided: `CSI <row>;<column>H`.
|
|
302
|
+
* - If `column` is undefined: `CSI <row>H` (moves to column 1 of the specified `row`).
|
|
303
|
+
* @param row The 1-indexed row number. `1` is the topmost row.
|
|
304
|
+
* @param column (Optional) The 1-indexed column number. `1` is the leftmost column.
|
|
305
|
+
* If undefined, the cursor moves to column 1 of the specified `row`.
|
|
306
|
+
* @returns The ANSI escape sequence.
|
|
307
|
+
* @example
|
|
308
|
+
* ```typescript
|
|
309
|
+
* cursorPosition(1, 1); // Moves to top-left (row 1, col 1) -> CSI 1;1H
|
|
310
|
+
* cursorPosition(5, 10); // Moves to row 5, col 10 -> CSI 5;10H
|
|
311
|
+
* cursorPosition(3); // Moves to row 3, col 1 -> CSI 3H
|
|
312
|
+
* ```
|
|
313
|
+
* @see {@link cursorTo} for a 0-indexed version.
|
|
314
|
+
*/
|
|
315
|
+
export declare const cursorPosition: (row: number, column?: number) => string;
|
|
316
|
+
/**
|
|
317
|
+
* Moves the cursor forward (right) to the next tab stop, `count` times.
|
|
318
|
+
* This uses the CHT (Cursor Horizontal Forward Tabulation) sequence: `CSI <count>I`.
|
|
319
|
+
* Tab stops are typically every 8 columns by default, but can be configured by terminal settings or HTS/TBC sequences.
|
|
320
|
+
* @param count The number of tab stops to advance. Defaults to `1`.
|
|
321
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
322
|
+
* @returns The ANSI escape sequence.
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* cursorHorizontalForwardTab(2); // Advances two tab stops.
|
|
326
|
+
* cursorHorizontalForwardTab(); // Advances one tab stop.
|
|
327
|
+
* ```
|
|
328
|
+
* @see {@link cursorBackwardTab}
|
|
329
|
+
*/
|
|
330
|
+
export declare const cursorHorizontalForwardTab: (count?: number) => string;
|
|
331
|
+
/**
|
|
332
|
+
* Moves the cursor backward (left) to the previous tab stop, `count` times.
|
|
333
|
+
* This uses the CBT (Cursor Backward Tabulation) sequence: `CSI <count>Z`.
|
|
334
|
+
* Tab stops are typically every 8 columns by default.
|
|
335
|
+
* @param count The number of tab stops to move backward. Defaults to `1`.
|
|
336
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
337
|
+
* @returns The ANSI escape sequence.
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* cursorBackwardTab(2); // Moves back two tab stops.
|
|
341
|
+
* cursorBackwardTab(); // Moves back one tab stop.
|
|
342
|
+
* ```
|
|
343
|
+
* @see {@link cursorHorizontalForwardTab}
|
|
344
|
+
*/
|
|
345
|
+
export declare const cursorBackwardTab: (count?: number) => string;
|
|
346
|
+
/**
|
|
347
|
+
* Erases `count` characters from the current cursor position forward (inclusive of the character at the cursor position).
|
|
348
|
+
* Characters are replaced with spaces. The cursor position does not change.
|
|
349
|
+
* This uses the ECH (Erase Character) sequence: `CSI <count>X`.
|
|
350
|
+
* @param count The number of characters to erase. Defaults to `1`.
|
|
351
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
352
|
+
* @returns The ANSI escape sequence.
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* // Assuming text "Hello World" and cursor at 'H':
|
|
356
|
+
* process.stdout.write(eraseCharacter(5)); // Erases "Hello", leaves " World"
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
export declare const eraseCharacter: (count?: number) => string;
|
|
360
|
+
/**
|
|
361
|
+
* Moves the cursor to the absolute vertical line (row) `row` (1-indexed), maintaining the current column.
|
|
362
|
+
* This uses the VPA (Vertical Line Position Absolute) sequence: `CSI <row>d`.
|
|
363
|
+
* @param row The 1-indexed row number to move to. Defaults to `1` (the first row).
|
|
364
|
+
* If `row` is less than 1, behavior is terminal-dependent (often treated as 1).
|
|
365
|
+
* @returns The ANSI escape sequence.
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* cursorVerticalAbsolute(10); // Moves to row 10, same column.
|
|
369
|
+
* cursorVerticalAbsolute(); // Moves to row 1, same column.
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
export declare const cursorVerticalAbsolute: (row?: number) => string;
|
|
373
|
+
/**
|
|
374
|
+
* Moves the cursor up a specific number of rows from its current position, staying in the same column.
|
|
375
|
+
* This uses the CUU (Cursor Up) sequence: `CSI <count>A`.
|
|
376
|
+
* @param count The number of rows to move up. Must be a positive integer. Defaults to `1`.
|
|
377
|
+
* If `count` is 0 or negative, it might be treated as 1 by some terminals or ignored.
|
|
378
|
+
* @returns The ANSI escape sequence for moving the cursor up.
|
|
379
|
+
* @example
|
|
380
|
+
* ```typescript
|
|
381
|
+
* cursorUp(2); // Moves cursor 2 rows up.
|
|
382
|
+
* cursorUp(); // Moves cursor 1 row up.
|
|
383
|
+
* ```
|
|
384
|
+
* @see {@link CURSOR_UP_1}
|
|
385
|
+
* @see {@link cursorDown}
|
|
386
|
+
*/
|
|
387
|
+
export declare const cursorUp: (count?: number) => string;
|
|
388
|
+
/**
|
|
389
|
+
* Represents the available cursor styles that can be set using the DECSCUSR (Set Cursor Style) sequence.
|
|
390
|
+
* The sequence is typically `CSI <Ps> SP q` (note the space before `q`).
|
|
391
|
+
* @remarks
|
|
392
|
+
* - `0` or `1` (Blinking Block) are often treated as the default by many terminals if DECSCUSR is not supported or reset.
|
|
393
|
+
* - Actual appearance can vary between terminal emulators.
|
|
394
|
+
* - Some terminals might not support all styles or DECSCUSR itself.
|
|
395
|
+
*/
|
|
396
|
+
export declare enum CursorStyle {
|
|
397
|
+
/** Blinking Bar (often an I-beam shape) cursor. (Corresponds to `Ps=5`) */
|
|
46
398
|
BlinkingBar = 5,
|
|
47
|
-
|
|
399
|
+
/** Blinking Block cursor. (Corresponds to `Ps=0` or `Ps=1` in `CSI Ps SP q`) */
|
|
400
|
+
BlinkingBlock = 1,// Or 0, often interchangeable for default blinking block
|
|
401
|
+
/** Blinking Underline cursor. (Corresponds to `Ps=3`) */
|
|
48
402
|
BlinkingUnderline = 3,
|
|
403
|
+
/**
|
|
404
|
+
* Default cursor style (Ps=0). The appearance is terminal-dependent, typically a blinking block.
|
|
405
|
+
* Using `0` explicitly can sometimes reset to the terminal's configured default if it differs from `1`.
|
|
406
|
+
*/
|
|
49
407
|
Default = 0,
|
|
408
|
+
/** Steady (non-blinking) Bar (I-beam) cursor. (Corresponds to `Ps=6`) */
|
|
50
409
|
SteadyBar = 6,
|
|
410
|
+
/** Steady (non-blinking) Block cursor. (Corresponds to `Ps=2`) */
|
|
51
411
|
SteadyBlock = 2,
|
|
412
|
+
/** Steady (non-blinking) Underline cursor. (Corresponds to `Ps=4`) */
|
|
52
413
|
SteadyUnderline = 4
|
|
53
414
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
415
|
+
/**
|
|
416
|
+
* Sets the terminal cursor style using the DECSCUSR (Set Cursor Style) sequence.
|
|
417
|
+
* The generated sequence is `CSI <styleValue> SP q` (note the space before `q`).
|
|
418
|
+
* @param style The desired cursor style. This can be a value from the {@link CursorStyle} enum
|
|
419
|
+
* or a raw number corresponding to the `Ps` parameter of DECSCUSR.
|
|
420
|
+
* @returns The ANSI escape sequence to set the cursor style.
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* import { setCursorStyle, CursorStyle } from '@visulima/ansi/cursor';
|
|
424
|
+
*
|
|
425
|
+
* process.stdout.write(setCursorStyle(CursorStyle.BlinkingUnderline)); // Sets blinking underline: CSI 3 q
|
|
426
|
+
* process.stdout.write(setCursorStyle(CursorStyle.SteadyBar)); // Sets steady bar: CSI 6 q
|
|
427
|
+
* process.stdout.write(setCursorStyle(0)); // Sets default (usually blinking block): CSI 0 q
|
|
428
|
+
* ```
|
|
429
|
+
* @remarks
|
|
430
|
+
* - Support for DECSCUSR and specific styles can vary between terminal emulators.
|
|
431
|
+
* - `0` and `1` often both result in a blinking block, with `0` sometimes being a more explicit "reset to default."
|
|
432
|
+
* @see {@link CursorStyle} for predefined style values.
|
|
433
|
+
* @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Set-cursor-style-DECSCUSR} XTerm DECSCUSR documentation.
|
|
434
|
+
* @see {@link https://vt100.net/docs/vt510-rm/DECSCUSR.html} VT510 DECSCUSR documentation.
|
|
435
|
+
*/
|
|
436
|
+
export declare const setCursorStyle: (style: CursorStyle | number) => string;
|
|
437
|
+
export { default as restoreCursor } from "restore-cursor";
|