@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/dist/mouse.d.ts CHANGED
@@ -1,4 +1,31 @@
1
- declare const MouseButton: {
1
+ /**
2
+ * Defines codes for various mouse buttons and actions.
3
+ * These are based on X11 button codes and common terminal mouse reporting extensions.
4
+ * @property {number} LEFT - Left mouse button (typically button 1).
5
+ * @property {number} MIDDLE - Middle mouse button (typically button 2).
6
+ * @property {number} RIGHT - Right mouse button (typically button 3).
7
+ * @property {number} NONE - Represents no specific button, often used for release events in some protocols.
8
+ * @property {number} RELEASE - Alias for `NONE`, used to signify a button release event.
9
+ * @property {number} BUTTON_1 - Alias for `LEFT`.
10
+ * @property {number} BUTTON_2 - Alias for `MIDDLE`.
11
+ * @property {number} BUTTON_3 - Alias for `RIGHT`.
12
+ * @property {number} WHEEL_UP - Mouse wheel scrolled upwards (typically button 4).
13
+ * @property {number} WHEEL_DOWN - Mouse wheel scrolled downwards (typically button 5).
14
+ * @property {number} WHEEL_LEFT - Mouse wheel scrolled leftwards (typically button 6, less common).
15
+ * @property {number} WHEEL_RIGHT - Mouse wheel scrolled rightwards (typically button 7, less common).
16
+ * @property {number} BACKWARD - Auxiliary button, often browser "Back" (typically button 8).
17
+ * @property {number} FORWARD - Auxiliary button, often browser "Forward" (typically button 9).
18
+ * @property {number} BUTTON_4 - Alias for `WHEEL_UP`.
19
+ * @property {number} BUTTON_5 - Alias for `WHEEL_DOWN`.
20
+ * @property {number} BUTTON_6 - Alias for `WHEEL_LEFT`.
21
+ * @property {number} BUTTON_7 - Alias for `WHEEL_RIGHT`.
22
+ * @property {number} BUTTON_8 - Alias for `BACKWARD`.
23
+ * @property {number} BUTTON_9 - Alias for `FORWARD`.
24
+ * @property {number} BUTTON_10 - Auxiliary button 10.
25
+ * @property {number} BUTTON_11 - Auxiliary button 11.
26
+ * @enum {number}
27
+ */
28
+ export declare const MouseButton: {
2
29
  readonly BACKWARD: 8;
3
30
  readonly BUTTON_1: 1;
4
31
  readonly BUTTON_2: 2;
@@ -22,27 +49,182 @@ declare const MouseButton: {
22
49
  readonly WHEEL_RIGHT: 7;
23
50
  readonly WHEEL_UP: 4;
24
51
  };
25
- type MouseButtonType = (typeof MouseButton)[keyof typeof MouseButton];
26
- interface MouseModifiers {
52
+ export type MouseButtonType = (typeof MouseButton)[keyof typeof MouseButton];
53
+ /**
54
+ * Interface representing modifier keys (Shift, Alt, Ctrl) that might be active during a mouse event.
55
+ * @property {boolean} [alt] - `true` if the Alt (or Meta) key was pressed, `false` or `undefined` otherwise.
56
+ * @property {boolean} [ctrl] - `true` if the Control key was pressed, `false` or `undefined` otherwise.
57
+ * @property {boolean} [shift] - `true` if the Shift key was pressed, `false` or `undefined` otherwise.
58
+ */
59
+ export interface MouseModifiers {
27
60
  alt?: boolean;
28
61
  ctrl?: boolean;
29
62
  shift?: boolean;
30
63
  }
31
- declare const encodeMouseButtonByte: (button: MouseButtonType, motion: boolean, modifiers?: MouseModifiers) => number;
32
- declare const mouseX10Sequence: (callback: number, x: number, y: number) => string;
33
- declare const mouseSgrSequence: (callback: number, x: number, y: number, isRelease: boolean) => string;
34
- declare const enableX10Mouse: string;
35
- declare const disableX10Mouse: string;
36
- declare const enableNormalMouse: string;
37
- declare const disableNormalMouse: string;
38
- declare const enableButtonEventMouse: string;
39
- declare const disableButtonEventMouse: string;
40
- declare const enableAnyEventMouse: string;
41
- declare const disableAnyEventMouse: string;
42
- declare const enableSgrMouse: string;
43
- declare const disableSgrMouse: string;
44
- declare const enableFocusTracking: string;
45
- declare const disableFocusTracking: string;
46
-
47
- export { MouseButton, disableAnyEventMouse, disableButtonEventMouse, disableFocusTracking, disableNormalMouse, disableSgrMouse, disableX10Mouse, enableAnyEventMouse, enableButtonEventMouse, enableFocusTracking, enableNormalMouse, enableSgrMouse, enableX10Mouse, encodeMouseButtonByte, mouseSgrSequence, mouseX10Sequence };
48
- export type { MouseButtonType, MouseModifiers };
64
+ /**
65
+ * Encodes a mouse button, motion status, and modifiers into a single byte (Cb)
66
+ * for use in X10 and SGR mouse tracking protocols.
67
+ *
68
+ * The encoded byte combines button information, whether it's a motion event,
69
+ * and the state of Shift, Alt, and Ctrl keys.
70
+ * @param button The {@link MouseButtonType} representing the button pressed or wheel action.
71
+ * @param motion `true` if this is a motion event, `false` otherwise.
72
+ * @param modifiers An optional {@link MouseModifiers} object indicating active modifier keys.
73
+ * @returns The encoded byte (Cb). Returns `0xFF` (255) if the provided `button` is invalid or not recognized.
74
+ * @example
75
+ * ```typescript
76
+ * import { encodeMouseButtonByte, MouseButton, MouseModifiers } from \'@visulima/ansi/mouse\';
77
+ *
78
+ * // Left button press, no motion, no modifiers
79
+ * const cb1 = encodeMouseButtonByte(MouseButton.LEFT, false);
80
+ * console.log(cb1); // Output: 0
81
+ *
82
+ * // Middle button press, with motion, Shift key held
83
+ * const cb2 = encodeMouseButtonByte(MouseButton.MIDDLE, true, { shift: true });
84
+ * console.log(cb2); // Output: 37 (Middle=1 + Shift=4 + Motion=32)
85
+ *
86
+ * // Wheel up, no motion, Alt and Ctrl held
87
+ * const cb3 = encodeMouseButtonByte(MouseButton.WHEEL_UP, false, { alt: true, ctrl: true });
88
+ * console.log(cb3); // Output: 88 (WheelUp=0 + WheelFlag=64 + Alt=8 + Ctrl=16)
89
+ *
90
+ * // Release event
91
+ * const cb4 = encodeMouseButtonByte(MouseButton.RELEASE, false);
92
+ * console.log(cb4); // Output: 3
93
+ * ```
94
+ */
95
+ export declare const encodeMouseButtonByte: (button: MouseButtonType, motion: boolean, modifiers?: MouseModifiers) => number;
96
+ /**
97
+ * Generates an X10 mouse tracking escape sequence.
98
+ * Format: `CSI M Cb Cx Cy`
99
+ * Where `Cb`, `Cx`, `Cy` are characters derived by adding {@link X10_MOUSE_OFFSET} (32) to the
100
+ * encoded button byte, 1-based X coordinate, and 1-based Y coordinate, respectively.
101
+ *
102
+ * This is an older mouse reporting protocol, primarily reporting button presses.
103
+ * @param callback The encoded button byte, typically from {@link encodeMouseButtonByte}.
104
+ * @param x The 0-indexed X coordinate of the mouse event.
105
+ * @param y The 0-indexed Y coordinate of the mouse event.
106
+ * @returns The X10 mouse sequence string. Returns an empty string if `cb` is `0xFF` (invalid).
107
+ * @example
108
+ * ```typescript
109
+ * import { mouseX10Sequence, encodeMouseButtonByte, MouseButton } from \'@visulima/ansi/mouse\';
110
+ *
111
+ * const cb = encodeMouseButtonByte(MouseButton.LEFT, false);
112
+ * const seq = mouseX10Sequence(cb, 10, 20); // Coordinates are 0-indexed
113
+ * // Result: "\u001b[M!+5" (Cb=0 -> char 32, Cx=11 -> char 43, Cy=21 -> char 53)
114
+ * console.log(seq);
115
+ * ```
116
+ */
117
+ export declare const mouseX10Sequence: (callback: number, x: number, y: number) => string;
118
+ /**
119
+ * Generates an SGR (Select Graphic Rendition) style mouse tracking escape sequence.
120
+ * This is a more modern and robust mouse reporting format.
121
+ *
122
+ * Format for press/motion: `CSI < Cb ; Px ; Py M`
123
+ * Format for release: `CSI < Cb ; Px ; Py m`
124
+ *
125
+ * `Cb` is the encoded button byte (see {@link encodeMouseButtonByte}).
126
+ * `Px` and `Py` are 1-based X and Y coordinates.
127
+ * @param callback The encoded button byte from {@link encodeMouseButtonByte}.
128
+ * @param x The 0-indexed X coordinate of the mouse event.
129
+ * @param y The 0-indexed Y coordinate of the mouse event.
130
+ * @param isRelease `true` if this is a button release event (sequence ends with `m`),
131
+ * `false` for press or motion events (sequence ends with `M`).
132
+ * @returns The SGR mouse sequence string. Returns an empty string if `cb` is `0xFF` (invalid).
133
+ * @example
134
+ * ```typescript
135
+ * import { mouseSgrSequence, encodeMouseButtonByte, MouseButton } from \'@visulima/ansi/mouse\';
136
+ *
137
+ * // Left button press at (10, 20)
138
+ * const cbPress = encodeMouseButtonByte(MouseButton.LEFT, false);
139
+ * const seqPress = mouseSgrSequence(cbPress, 10, 20, false);
140
+ * console.log(seqPress); // Output: "\u001b[<0;11;21M"
141
+ *
142
+ * // Left button release at (10, 20)
143
+ * const cbRelease = encodeMouseButtonByte(MouseButton.RELEASE, false); // Or use original button with isRelease=true
144
+ * const seqRelease = mouseSgrSequence(cbPress, 10, 20, true); // cbPress (0) is fine for release with SGR if button info isn't needed for release
145
+ * console.log(seqRelease); // Output: "\u001b[<0;11;21m"
146
+ * // If using explicit release button code from encodeMouseButtonByte:
147
+ * const cbExplicitRelease = encodeMouseButtonByte(MouseButton.RELEASE, false);
148
+ * const seqExplicitRelease = mouseSgrSequence(cbExplicitRelease, 10, 20, true);
149
+ * console.log(seqExplicitRelease); // Output: "\u001b[<3;11;21m"
150
+ *
151
+ * // Motion with middle button and Shift key at (5,5)
152
+ * const cbMotion = encodeMouseButtonByte(MouseButton.MIDDLE, true, { shift: true });
153
+ * const seqMotion = mouseSgrSequence(cbMotion, 5, 5, false);
154
+ * console.log(seqMotion); // Output: "\u001b[<37;6;6M"
155
+ * ```
156
+ */
157
+ export declare const mouseSgrSequence: (callback: number, x: number, y: number, isRelease: boolean) => string;
158
+ /**
159
+ * Enables X10 compatibility mouse reporting (DECSET 9).
160
+ * This is an older protocol that typically reports only button press events.
161
+ * The format is `CSI M Cb Cx Cy`.
162
+ * @see {@link disableX10Mouse}
163
+ * @see {@link mouseX10Sequence}
164
+ */
165
+ export declare const enableX10Mouse: string;
166
+ /**
167
+ * Disables X10 compatibility mouse reporting (DECRST 9).
168
+ * @see {@link enableX10Mouse}
169
+ */
170
+ export declare const disableX10Mouse: string;
171
+ /**
172
+ * Enables Normal Tracking mode, also known as VT200 mouse reporting (DECSET 1000).
173
+ * Reports button press and release events.
174
+ * Uses X10-style coordinate encoding if SGR mode is not also active.
175
+ * @see {@link disableNormalMouse}
176
+ */
177
+ export declare const enableNormalMouse: string;
178
+ /**
179
+ * Disables Normal Tracking mode / VT200 mouse reporting (DECRST 1000).
180
+ * @see {@link enableNormalMouse}
181
+ */
182
+ export declare const disableNormalMouse: string;
183
+ /**
184
+ * Enables Button-Event tracking mouse reporting (DECSET 1002).
185
+ * Reports press, release, and mouse motion when a button is held down.
186
+ * @see {@link disableButtonEventMouse}
187
+ */
188
+ export declare const enableButtonEventMouse: string;
189
+ /**
190
+ * Disables Button-Event tracking mouse reporting (DECRST 1002).
191
+ * @see {@link enableButtonEventMouse}
192
+ */
193
+ export declare const disableButtonEventMouse: string;
194
+ /**
195
+ * Enables Any-Event mouse reporting (DECSET 1003).
196
+ * Reports press, release, and all mouse motion (including hover when no buttons are pressed).
197
+ * This is the most comprehensive mouse motion tracking mode (excluding pixel-level reporting).
198
+ * @see {@link disableAnyEventMouse}
199
+ */
200
+ export declare const enableAnyEventMouse: string;
201
+ /**
202
+ * Disables Any-Event mouse reporting (DECRST 1003).
203
+ * @see {@link enableAnyEventMouse}
204
+ */
205
+ export declare const disableAnyEventMouse: string;
206
+ /**
207
+ * Enables SGR (Select Graphic Rendition) Extended mouse reporting (DECSET 1006).
208
+ * Event data is sent in a more robust format: `CSI < Cb ; Px ; Py M` (press) or `m` (release).
209
+ * This mode is generally preferred for new applications due to its clarity and ability
210
+ * to handle coordinates larger than 95 without ambiguity with UTF-8 characters.
211
+ * @see {@link disableSgrMouse}
212
+ * @see {@link mouseSgrSequence}
213
+ */
214
+ export declare const enableSgrMouse: string;
215
+ /**
216
+ * Disables SGR Extended mouse reporting (DECRST 1006).
217
+ * @see {@link enableSgrMouse}
218
+ */
219
+ export declare const disableSgrMouse: string;
220
+ /**
221
+ * Enables FocusIn/FocusOut event reporting (DECSET 1004).
222
+ * The terminal will send `CSI I` when it gains focus and `CSI O` when it loses focus.
223
+ * @see {@link disableFocusTracking}
224
+ */
225
+ export declare const enableFocusTracking: string;
226
+ /**
227
+ * Disables FocusIn/FocusOut event reporting (DECRST 1004).
228
+ * @see {@link enableFocusTracking}
229
+ */
230
+ export declare const disableFocusTracking: string;
@@ -1,6 +1,77 @@
1
- declare const SCREEN_MAX_LEN_DEFAULT: number;
2
- declare const SCREEN_TYPICAL_LIMIT: number;
3
- declare const screenPassthrough: (sequence: string, limit?: number) => string;
4
- declare const tmuxPassthrough: (sequence: string) => string;
5
-
6
- export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough };
1
+ /**
2
+ * Default value for the `limit` parameter in {@link screenPassthrough}, indicating no chunking.
3
+ * When this value is used (or any value &lt;= 0), the passthrough sequence is not split into smaller chunks.
4
+ */
5
+ export declare const SCREEN_MAX_LEN_DEFAULT: number;
6
+ /**
7
+ * A typical limit for string sequences in GNU Screen (e.g., 768 bytes).
8
+ * This constant can be used as a practical value for the `limit` parameter in {@link screenPassthrough}
9
+ * to avoid issues with Screen's internal buffers, though the function itself defaults to no limit.
10
+ * It's provided for informational purposes and as a suggested practical chunking limit.
11
+ */
12
+ export declare const SCREEN_TYPICAL_LIMIT: number;
13
+ /**
14
+ * Wraps a given ANSI escape sequence in a DCS (Device Control String) passthrough sequence
15
+ * specifically for GNU Screen. This allows raw escape sequences to be sent to the
16
+ * terminal emulator that is hosting Screen, bypassing Screen's own interpretation.
17
+ *
18
+ * The basic format is: `DCS &lt;data> ST` (where `DCS` is `ESC P` and `ST` is `ESC \`).
19
+ *
20
+ * GNU Screen has limitations on the length of string sequences it can handle (often around 768 bytes).
21
+ * This function can optionally chunk the input `sequence` into smaller parts, each wrapped
22
+ * in its own `DCS...ST` sequence, to work around this limitation.
23
+ * @param sequence The ANSI escape sequence string to be wrapped.
24
+ * @param limit The maximum length for each chunk of the `sequence` before it's wrapped.
25
+ * If `0` or a negative number, the sequence is not chunked. Defaults to {@link SCREEN_MAX_LEN_DEFAULT} (0).
26
+ * Consider using {@link SCREEN_TYPICAL_LIMIT} (768) for practical chunking with Screen.
27
+ * @returns The wrapped string, possibly chunked into multiple `DCS...ST` sequences if `limit` is positive and the `sequence` exceeds it.
28
+ * @see {@link https://www.gnu.org/software/screen/manual/screen.html#String-Escapes} GNU Screen Manual - String Escapes.
29
+ * @example
30
+ * ```typescript
31
+ * import { screenPassthrough, SCREEN_TYPICAL_LIMIT } from \'@visulima/ansi/passthrough\';
32
+ * import { cursorShow, cursorHide } from \'@visulima/ansi/cursor\';
33
+ *
34
+ * const longSequence = cursorHide + "Some very long output..." + cursorShow;
35
+ *
36
+ * // No chunking (default behavior if sequence is short enough or limit is 0)
37
+ * const passthrough1 = screenPassthrough(cursorHide);
38
+ * console.log(JSON.stringify(passthrough1)); // "\u001bP?25l\u001b\\"
39
+ *
40
+ * // With chunking, assuming SCREEN_TYPICAL_LIMIT is small for demonstration
41
+ * const limitedPassthrough = screenPassthrough(longSequence, 10); // Hypothetical small limit
42
+ * // Example output if longSequence was "0123456789abcde" and limit 10:
43
+ * // "\u001bP0123456789\u001b\\\u001bPabcde\u001b\\"
44
+ * console.log(JSON.stringify(limitedPassthrough));
45
+ * ```
46
+ */
47
+ export declare const screenPassthrough: (sequence: string, limit?: number) => string;
48
+ /**
49
+ * Wraps a given ANSI escape sequence in a special DCS (Device Control String) passthrough sequence
50
+ * designed for tmux (Terminal Multiplexer). This allows raw escape sequences to be sent to the
51
+ * terminal emulator hosting tmux, bypassing tmux's own interpretation.
52
+ *
53
+ * The format is: `DCS tmux ; &lt;escaped-data> ST`
54
+ * (where `DCS` is `ESC P`, and `ST` is `ESC \`).
55
+ *
56
+ * The `&lt;escaped-data>` is the original `sequence` with all occurrences of the ESC character (`\u001B`)
57
+ * doubled (i.e., `ESC` becomes `ESC ESC`).
58
+ *
59
+ * **Note:** For this to work, the tmux option `allow-passthrough` must be enabled (`on`) in the tmux configuration.
60
+ * By default, it might be off.
61
+ * @param sequence The ANSI escape sequence string to be wrapped and properly escaped for tmux.
62
+ * @returns The wrapped and escaped string suitable for tmux passthrough.
63
+ * @see {@link https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it} Tmux FAQ on Passthrough.
64
+ * @example
65
+ * ```typescript
66
+ * import { tmuxPassthrough } from \'@visulima/ansi/passthrough\';
67
+ * import { cursorShow } from \'@visulima/ansi/cursor\';
68
+ *
69
+ * const originalSequence = cursorShow; // e.g., "\u001b[?25h"
70
+ * const passthrough = tmuxPassthrough(originalSequence);
71
+ *
72
+ * // Expected: "\u001bPtmux;\u001b\u001b[?25h\u001b\\"
73
+ * // (ESC P tmux ; ESC ESC [ ? 2 5 h ESC \)
74
+ * console.log(JSON.stringify(passthrough));
75
+ * ```
76
+ */
77
+ export declare const tmuxPassthrough: (sequence: string) => string;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Resets the progress bar to its default state (hidden).
3
+ *
4
+ * Sequence: `OSC 9 ; 4 ; 0 BEL`
5
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
6
+ */
7
+ export declare const resetProgressBar: string;
8
+ /**
9
+ * Returns a sequence for setting the progress bar to a specific percentage (0-100) in the "default" state.
10
+ *
11
+ * Sequence: `OSC 9 ; 4 ; 1 ; Percentage BEL`
12
+ * @param percentage The progress percentage (0-100, clamped automatically)
13
+ * @returns The progress bar sequence
14
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
15
+ */
16
+ export declare const setProgressBar: (percentage: number) => string;
17
+ /**
18
+ * Returns a sequence for setting the progress bar to a specific percentage (0-100) in the "Error" state.
19
+ *
20
+ * Sequence: `OSC 9 ; 4 ; 2 ; Percentage BEL`
21
+ * @param percentage The progress percentage (0-100, clamped automatically)
22
+ * @returns The error progress bar sequence
23
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
24
+ */
25
+ export declare const setErrorProgressBar: (percentage: number) => string;
26
+ /**
27
+ * Sets the progress bar to the indeterminate state.
28
+ *
29
+ * Sequence: `OSC 9 ; 4 ; 3 BEL`
30
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
31
+ */
32
+ export declare const setIndeterminateProgressBar: string;
33
+ /**
34
+ * Returns a sequence for setting the progress bar to a specific percentage (0-100) in the "Warning" state.
35
+ *
36
+ * Sequence: `OSC 9 ; 4 ; 4 ; Percentage BEL`
37
+ * @param percentage The progress percentage (0-100, clamped automatically)
38
+ * @returns The warning progress bar sequence
39
+ * @see {@link https://learn.microsoft.com/en-us/windows/terminal/tutorials/progress-bar-sequences}
40
+ */
41
+ export declare const setWarningProgressBar: (percentage: number) => string;
package/dist/reset.d.ts CHANGED
@@ -1,4 +1,26 @@
1
- declare const RESET_INITIAL_STATE: string;
2
- declare const RIS: string;
3
-
4
- export { RESET_INITIAL_STATE, RIS };
1
+ /**
2
+ * The ANSI escape sequence for Reset Initial State (RIS).
3
+ * This command attempts to reset the terminal to its power-up state or initial configuration.
4
+ * The exact behavior can vary between terminal emulators, but it typically includes:
5
+ * - Resetting graphic rendition (SGR parameters) to default.
6
+ * - Clearing the screen.
7
+ * - Moving the cursor to the top-left (home position).
8
+ * - Resetting character sets.
9
+ * - Resetting tab stops.
10
+ * - Resetting modes (like DECAWM, DECOM) to their defaults.
11
+ *
12
+ * Sequence: `ESC c`
13
+ *
14
+ * This is a more comprehensive reset than `CSI 0 m` (which only resets SGR) or `CSI 2 J` (which only clears the screen).
15
+ * It is often referred to as a "hard reset".
16
+ * @see {@link https://vt100.net/docs/vt510-rm/RIS.html VT510 RIS Documentation}
17
+ * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Reset} Xterm Control Sequences - Reset
18
+ */
19
+ export declare const RESET_INITIAL_STATE: string;
20
+ /**
21
+ * Alias for {@link RESET_INITIAL_STATE} (Reset Initial State).
22
+ *
23
+ * Provides a shorter name for the RIS sequence `ESC c`.
24
+ * @see {@link RESET_INITIAL_STATE}
25
+ */
26
+ export declare const RIS: string;
package/dist/screen.d.ts CHANGED
@@ -1,11 +1,234 @@
1
- declare const insertLine: (count?: number) => string;
2
- declare const deleteLine: (count?: number) => string;
3
- declare const setTopBottomMargins: (top?: number | null, bottom?: number | null) => string;
4
- declare const setLeftRightMargins: (left?: number | null, right?: number | null) => string;
5
- declare const insertCharacter: (count?: number) => string;
6
- declare const deleteCharacter: (count?: number) => string;
7
- declare const clearTabStop: (mode?: 0 | 3) => string;
8
- declare const requestPresentationStateReport: (mode: 0 | 1 | 2) => string;
9
- declare const repeatPreviousCharacter: (count?: number) => string;
10
-
11
- export { clearTabStop, deleteCharacter, deleteLine, insertCharacter, insertLine, repeatPreviousCharacter, requestPresentationStateReport, setLeftRightMargins, setTopBottomMargins };
1
+ /**
2
+ * Inserts a specified number of blank lines at the current cursor position.
3
+ * (IL - Insert Line)
4
+ *
5
+ * Existing lines from the cursor position to the bottom margin are moved downwards.
6
+ * Lines moved past the bottom margin are lost. The cursor position is unchanged.
7
+ * If the parameter `count` is 0 or 1, it defaults to inserting one line.
8
+ *
9
+ * Sequence: `CSI Pn L`
10
+ * - `Pn`: Number of lines to insert (default: 1).
11
+ * @param count The number of blank lines to insert. Defaults to 1.
12
+ * @returns The ANSI escape sequence for inserting lines.
13
+ * @see {@link https://vt100.net/docs/vt510-rm/IL.html VT510 IL Documentation}
14
+ * @example
15
+ * ```typescript
16
+ * import { insertLine } from \'@visulima/ansi/screen\';
17
+ *
18
+ * // Insert 1 line (default)
19
+ * process.stdout.write(insertLine()); // CSI L
20
+ *
21
+ * // Insert 5 lines
22
+ * process.stdout.write(insertLine(5)); // CSI 5L
23
+ * ```
24
+ */
25
+ export declare const insertLine: (count?: number) => string;
26
+ /**
27
+ * Deletes a specified number of lines starting from the line with the cursor.
28
+ * (DL - Delete Line)
29
+ *
30
+ * Lines below the deleted ones are moved upwards. Blank lines are added at the bottom
31
+ * of the scrolling region to fill the gap. The cursor position is unchanged.
32
+ * If the parameter `count` is 0 or 1, it defaults to deleting one line.
33
+ *
34
+ * Sequence: `CSI Pn M`
35
+ * - `Pn`: Number of lines to delete (default: 1).
36
+ * @param count The number of lines to delete. Defaults to 1.
37
+ * @returns The ANSI escape sequence for deleting lines.
38
+ * @see {@link https://vt100.net/docs/vt510-rm/DL.html VT510 DL Documentation}
39
+ * @example
40
+ * ```typescript
41
+ * import { deleteLine } from \'@visulima/ansi/screen\';
42
+ *
43
+ * // Delete 1 line (default)
44
+ * process.stdout.write(deleteLine()); // CSI M
45
+ *
46
+ * // Delete 3 lines
47
+ * process.stdout.write(deleteLine(3)); // CSI 3M
48
+ * ```
49
+ */
50
+ export declare const deleteLine: (count?: number) => string;
51
+ /**
52
+ * Sets the top and bottom margins, defining the scrolling region.
53
+ * (DECSTBM - Set Top and Bottom Margins)
54
+ *
55
+ * Cursor movement is typically confined to this region, especially when Origin Mode (DECOM) is active.
56
+ * If parameters are omitted or invalid (e.g., `0`, `null`, `undefined`), they usually default to the
57
+ * screen's current extents (e.g., line 1 for top, last line for bottom).
58
+ *
59
+ * Sequence: `CSI Pt ; Pb r`
60
+ * - `Pt`: Line number for the top margin (1-indexed). Default: 1.
61
+ * - `Pb`: Line number for the bottom margin (1-indexed). Default: screen height.
62
+ * @param top The line number for the top margin (1-indexed). If `null`, `undefined`, or `< 1`, it's omitted, implying default.
63
+ * @param bottom The line number for the bottom margin (1-indexed). If `null`, `undefined`, or `< 1`, it's omitted, implying default.
64
+ * @returns The ANSI escape sequence for DECSTBM.
65
+ * @see {@link https://vt100.net/docs/vt510-rm/DECSTBM.html VT510 DECSTBM Documentation}
66
+ * @example
67
+ * ```typescript
68
+ * import { setTopBottomMargins } from \'@visulima/ansi/screen\';
69
+ *
70
+ * // Set scrolling region from line 5 to 20
71
+ * process.stdout.write(setTopBottomMargins(5, 20)); // CSI 5;20r
72
+ *
73
+ * // Reset to default margins (full screen)
74
+ * process.stdout.write(setTopBottomMargins()); // CSI ;r
75
+ * ```
76
+ */
77
+ export declare const setTopBottomMargins: (top?: number | null, bottom?: number | null) => string;
78
+ /**
79
+ * Sets the left and right margins for the page or screen, defining horizontal boundaries.
80
+ * (DECSLRM - Set Left and Right Margins)
81
+ *
82
+ * This command is common on VT420+ terminals and xterm.
83
+ * If parameters are omitted or invalid, they usually default to the screen's current extents
84
+ * (e.g., column 1 for left, last column for right).
85
+ *
86
+ * Sequence: `CSI Pl ; Pr s`
87
+ * - `Pl`: Column number for the left margin (1-indexed). Default: 1.
88
+ * - `Pr`: Column number for the right margin (1-indexed). Default: screen width.
89
+ *
90
+ * Note: The final character 's' should not be confused with save cursor sequences.
91
+ * @param left The column number for the left margin (1-indexed). If `null`, `undefined`, or `< 1`, it's omitted.
92
+ * @param right The column number for the right margin (1-indexed). If `null`, `undefined`, or `< 1`, it's omitted.
93
+ * @returns The ANSI escape sequence for DECSLRM.
94
+ * @see {@link https://vt100.net/docs/vt510-rm/DECSLRM.html VT510 DECSLRM Documentation}
95
+ * @example
96
+ * ```typescript
97
+ * import { setLeftRightMargins } from \'@visulima/ansi/screen\';
98
+ *
99
+ * // Set left margin to 10, right margin to 70
100
+ * process.stdout.write(setLeftRightMargins(10, 70)); // CSI 10;70s
101
+ *
102
+ * // Reset to default margins (full width)
103
+ * process.stdout.write(setLeftRightMargins()); // CSI ;s
104
+ * ```
105
+ */
106
+ export declare const setLeftRightMargins: (left?: number | null, right?: number | null) => string;
107
+ /**
108
+ * Inserts a specified number of blank characters at the current cursor position.
109
+ * (ICH - Insert CHaracter)
110
+ *
111
+ * Existing characters from the cursor position to the right margin are shifted to the right.
112
+ * Characters shifted past the right margin are lost. The cursor position is unchanged.
113
+ * If the parameter `count` is 0 or 1, it defaults to inserting one character.
114
+ *
115
+ * Sequence: `CSI Pn @`
116
+ * - `Pn`: Number of blank characters to insert (default: 1).
117
+ * @param count The number of blank characters to insert. Defaults to 1.
118
+ * @returns The ANSI escape sequence for inserting characters.
119
+ * @see {@link https://vt100.net/docs/vt510-rm/ICH.html VT510 ICH Documentation}
120
+ * @example
121
+ * ```typescript
122
+ * import { insertCharacter } from \'@visulima/ansi/screen\';
123
+ *
124
+ * // Insert 1 character (default)
125
+ * process.stdout.write(insertCharacter()); // CSI @
126
+ *
127
+ * // Insert 10 characters
128
+ * process.stdout.write(insertCharacter(10)); // CSI 10@
129
+ * ```
130
+ */
131
+ export declare const insertCharacter: (count?: number) => string;
132
+ /**
133
+ * Deletes a specified number of characters starting from the current cursor position.
134
+ * (DCH - Delete CHaracter)
135
+ *
136
+ * Remaining characters on the line (to the right of the cursor) are shifted to the left.
137
+ * Character attributes move with the characters. Blank characters with default attributes
138
+ * are inserted at the right margin. The cursor position is unchanged.
139
+ * If the parameter `count` is 0 or 1, it defaults to deleting one character.
140
+ *
141
+ * Sequence: `CSI Pn P`
142
+ * - `Pn`: Number of characters to delete (default: 1).
143
+ * @param count The number of characters to delete. Defaults to 1.
144
+ * @returns The ANSI escape sequence for deleting characters.
145
+ * @see {@link https://vt100.net/docs/vt510-rm/DCH.html VT510 DCH Documentation}
146
+ * @example
147
+ * ```typescript
148
+ * import { deleteCharacter } from \'@visulima/ansi/screen\';
149
+ *
150
+ * // Delete 1 character (default)
151
+ * process.stdout.write(deleteCharacter()); // CSI P
152
+ *
153
+ * // Delete 5 characters
154
+ * process.stdout.write(deleteCharacter(5)); // CSI 5P
155
+ * ```
156
+ */
157
+ export declare const deleteCharacter: (count?: number) => string;
158
+ /**
159
+ * Clears horizontal tab stops.
160
+ * (TBC - Tabulation Clear)
161
+ *
162
+ * Sequence: `CSI Ps g`
163
+ * - `Ps = 0` (or omitted): Clear horizontal tab stop at the current column (default).
164
+ * - `Ps = 3`: Clear all horizontal tab stops in the current line (or all lines, terminal-dependent).
165
+ * @param mode Specifies which tab stops to clear:
166
+ * - `0`: Clear tab stop at the current cursor column (default).
167
+ * - `3`: Clear all horizontal tab stops.
168
+ * @returns The ANSI escape sequence for clearing tab stops.
169
+ * @see {@link https://vt100.net/docs/vt510-rm/TBC.html VT510 TBC Documentation}
170
+ * @example
171
+ * ```typescript
172
+ * import { clearTabStop } from \'@visulima/ansi/screen\';
173
+ *
174
+ * // Clear tab stop at current column
175
+ * process.stdout.write(clearTabStop(0)); // CSI 0g
176
+ * process.stdout.write(clearTabStop()); // CSI 0g (default)
177
+ *
178
+ * // Clear all tab stops
179
+ * process.stdout.write(clearTabStop(3)); // CSI 3g
180
+ * ```
181
+ */
182
+ export declare const clearTabStop: (mode?: 0 | 3) => string;
183
+ /**
184
+ * Requests a report of the terminal's presentation state.
185
+ * (DECRQPSR - Request Presentation State Report)
186
+ *
187
+ * The terminal responds with a corresponding report sequence (e.g., DECTPSSR, DECSGRSR, DECCPSR).
188
+ * This is useful for querying current SGR settings, color palette, etc.
189
+ *
190
+ * Sequence: `CSI Ps $ u`
191
+ * - `Ps = 0`: Report Text Presentation State (DECTPSSR) - font, decoration, etc.
192
+ * - `Ps = 1`: Report SGR State (DECSGRSR) - current graphic rendition attributes.
193
+ * - `Ps = 2`: Report Color Palette State (DECCPSR) - color table contents.
194
+ * @param mode Specifies the type of presentation state report requested:
195
+ * - `0`: Text Presentation State (DECTPSSR).
196
+ * - `1`: SGR State (DECSGRSR).
197
+ * - `2`: Color Palette State (DECCPSR).
198
+ * @returns The ANSI escape sequence to request the presentation state report.
199
+ * @see {@link https://vt100.net/docs/vt510-rm/DECRQPSR.html VT510 DECRQPSR Documentation}
200
+ * @example
201
+ * ```typescript
202
+ * import { requestPresentationStateReport } from \'@visulima/ansi/screen\';
203
+ *
204
+ * // Request SGR state
205
+ * process.stdout.write(requestPresentationStateReport(1)); // CSI 1$u
206
+ * ```
207
+ */
208
+ export declare const requestPresentationStateReport: (mode: 0 | 1 | 2) => string;
209
+ /**
210
+ * Repeats the preceding graphic character a specified number of times.
211
+ * (REP - Repeat Previous Character)
212
+ *
213
+ * The character repeated is the last non-control character that was processed by the terminal.
214
+ * If the parameter `count` is 0 or 1, it defaults to repeating one time (i.e., printing it again).
215
+ *
216
+ * Sequence: `CSI Pn b`
217
+ * - `Pn`: Number of times to repeat the character (default: 1).
218
+ * @param count The number of times to repeat the preceding graphic character. Defaults to 1.
219
+ * @returns The ANSI escape sequence for repeating the previous character.
220
+ * @see {@link https://vt100.net/docs/vt510-rm/REP.html VT510 REP Documentation (though REP is less common or behavior varies)}
221
+ * @example
222
+ * ```typescript
223
+ * import { repeatPreviousCharacter } from \'@visulima/ansi/screen\';
224
+ *
225
+ * process.stdout.write("A");
226
+ * // Repeat 'A' 5 times
227
+ * process.stdout.write(repeatPreviousCharacter(5)); // Output: AAAAA (total 6 'A's)
228
+ *
229
+ * process.stdout.write("B");
230
+ * // Repeat 'B' 1 time (default)
231
+ * process.stdout.write(repeatPreviousCharacter()); // Output: BB (total 2 'B's)
232
+ * ```
233
+ */
234
+ export declare const repeatPreviousCharacter: (count?: number) => string;