@visulima/ansi 1.0.18 → 2.0.0
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 +86 -0
- package/LICENSE.md +76 -74
- package/README.md +335 -2
- package/dist/alternative-screen.cjs +11 -5
- package/dist/alternative-screen.d.cts +74 -4
- package/dist/alternative-screen.d.mts +74 -4
- package/dist/alternative-screen.d.ts +74 -4
- package/dist/alternative-screen.mjs +8 -4
- package/dist/clear.cjs +10 -18
- package/dist/clear.d.cts +77 -7
- package/dist/clear.d.mts +77 -7
- package/dist/clear.d.ts +77 -7
- package/dist/clear.mjs +8 -15
- package/dist/constants.d.cts +20 -0
- package/dist/constants.d.mts +20 -0
- package/dist/constants.d.ts +20 -0
- package/dist/cursor.cjs +19 -2
- package/dist/cursor.d.cts +436 -30
- package/dist/cursor.d.mts +436 -30
- package/dist/cursor.d.ts +436 -30
- package/dist/cursor.mjs +2 -2
- package/dist/erase.cjs +44 -13
- package/dist/erase.d.cts +206 -9
- package/dist/erase.d.mts +206 -9
- package/dist/erase.d.ts +206 -9
- package/dist/erase.mjs +40 -14
- package/dist/helpers.d.cts +14 -0
- package/dist/helpers.d.mts +14 -0
- package/dist/helpers.d.ts +14 -0
- package/dist/hyperlink.cjs +9 -0
- package/dist/hyperlink.d.cts +29 -0
- package/dist/hyperlink.d.mts +27 -0
- package/dist/hyperlink.d.ts +29 -0
- package/dist/hyperlink.mjs +7 -0
- package/dist/image.cjs +12 -5
- package/dist/image.d.cts +69 -58
- package/dist/image.d.mts +69 -58
- package/dist/image.d.ts +69 -58
- package/dist/image.mjs +10 -5
- package/dist/index.cjs +209 -11
- package/dist/index.d.cts +35 -12
- package/dist/index.d.mts +35 -12
- package/dist/index.d.ts +35 -12
- package/dist/index.mjs +20 -7
- package/dist/iterm2/iterm2-properties.d.cts +135 -0
- package/dist/iterm2/iterm2-properties.d.mts +135 -0
- package/dist/iterm2/iterm2-properties.d.ts +135 -0
- package/dist/iterm2/iterm2-sequences.d.cts +96 -0
- package/dist/iterm2/iterm2-sequences.d.mts +96 -0
- package/dist/iterm2/iterm2-sequences.d.ts +96 -0
- package/dist/iterm2.cjs +26 -0
- package/dist/iterm2.d.cts +58 -0
- package/dist/iterm2.d.mts +58 -0
- package/dist/iterm2.d.ts +58 -0
- package/dist/iterm2.mjs +14 -0
- package/dist/mode.cjs +388 -0
- package/dist/mode.d.cts +657 -0
- package/dist/mode.d.mts +657 -0
- package/dist/mode.d.ts +657 -0
- package/dist/mode.mjs +235 -0
- package/dist/mouse.cjs +127 -0
- package/dist/mouse.d.cts +230 -0
- package/dist/mouse.d.mts +230 -0
- package/dist/mouse.d.ts +230 -0
- package/dist/mouse.mjs +108 -0
- package/dist/packem_shared/IT2_AUTO-5vTJQMm6.cjs +15 -0
- package/dist/packem_shared/IT2_AUTO-DnfCUXso.mjs +8 -0
- package/dist/packem_shared/ITerm2File-BGPqNSjB.cjs +137 -0
- package/dist/packem_shared/ITerm2File-DKFkdqdA.mjs +130 -0
- package/dist/packem_shared/{constants-D8u2npjW.cjs → constants-BK26O-46.cjs} +4 -0
- package/dist/packem_shared/constants-CE7WkXh_.mjs +9 -0
- package/dist/packem_shared/cursor-CQKLCu7U.cjs +105 -0
- package/dist/packem_shared/cursor-DhFQcQ9g.mjs +73 -0
- package/dist/passthrough.cjs +38 -0
- package/dist/passthrough.d.cts +77 -0
- package/dist/passthrough.d.mts +77 -0
- package/dist/passthrough.d.ts +77 -0
- package/dist/passthrough.mjs +31 -0
- package/dist/reset.cjs +9 -0
- package/dist/reset.d.cts +26 -0
- package/dist/reset.d.mts +26 -0
- package/dist/reset.d.ts +26 -0
- package/dist/reset.mjs +4 -0
- package/dist/screen.cjs +41 -0
- package/dist/screen.d.cts +234 -0
- package/dist/screen.d.mts +234 -0
- package/dist/screen.d.ts +234 -0
- package/dist/screen.mjs +29 -0
- package/dist/scroll.cjs +17 -3
- package/dist/scroll.d.cts +67 -4
- package/dist/scroll.d.mts +67 -4
- package/dist/scroll.d.ts +67 -4
- package/dist/scroll.mjs +16 -4
- package/dist/status.cjs +147 -0
- package/dist/status.d.cts +501 -0
- package/dist/status.d.mts +501 -0
- package/dist/status.d.ts +501 -0
- package/dist/status.mjs +104 -0
- package/dist/strip.d.cts +23 -1
- package/dist/strip.d.mts +22 -2
- package/dist/strip.d.ts +23 -1
- package/dist/termcap.cjs +33 -0
- package/dist/termcap.d.cts +38 -0
- package/dist/termcap.d.mts +38 -0
- package/dist/termcap.d.ts +38 -0
- package/dist/termcap.mjs +27 -0
- package/dist/title.cjs +31 -0
- package/dist/title.d.cts +185 -0
- package/dist/title.d.mts +185 -0
- package/dist/title.d.ts +185 -0
- package/dist/title.mjs +20 -0
- package/dist/window-ops.cjs +85 -0
- package/dist/window-ops.d.cts +418 -0
- package/dist/window-ops.d.mts +418 -0
- package/dist/window-ops.d.ts +418 -0
- package/dist/window-ops.mjs +63 -0
- package/dist/xterm.cjs +48 -0
- package/dist/xterm.d.cts +94 -0
- package/dist/xterm.d.mts +94 -0
- package/dist/xterm.d.ts +94 -0
- package/dist/xterm.mjs +35 -0
- package/package.json +153 -9
- package/dist/link.cjs +0 -9
- package/dist/link.d.cts +0 -3
- package/dist/link.d.mts +0 -3
- package/dist/link.d.ts +0 -3
- package/dist/link.mjs +0 -7
- package/dist/packem_shared/constants-CqXMfQy0.mjs +0 -7
- package/dist/packem_shared/cursor-2tHgT9r6.cjs +0 -57
- package/dist/packem_shared/cursor-CDCWqbC9.mjs +0 -42
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default value for the `limit` parameter in {@link screenPassthrough}, indicating no chunking.
|
|
3
|
+
* When this value is used (or any value <= 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 <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 ; <escaped-data> ST`
|
|
54
|
+
* (where `DCS` is `ESC P`, and `ST` is `ESC \`).
|
|
55
|
+
*
|
|
56
|
+
* The `<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,31 @@
|
|
|
1
|
+
import { D as DCS, a as ST, E as ESC } from './packem_shared/constants-CE7WkXh_.mjs';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
const SCREEN_MAX_LEN_DEFAULT = 0;
|
|
6
|
+
const SCREEN_TYPICAL_LIMIT = 768;
|
|
7
|
+
const screenPassthrough = /* @__PURE__ */ __name((sequence, limit = SCREEN_MAX_LEN_DEFAULT) => {
|
|
8
|
+
let result = DCS;
|
|
9
|
+
if (limit > 0 && sequence.length > limit) {
|
|
10
|
+
for (let index = 0; index < sequence.length; index += limit) {
|
|
11
|
+
const end = Math.min(index + limit, sequence.length);
|
|
12
|
+
result += sequence.slice(index, end);
|
|
13
|
+
if (end < sequence.length) {
|
|
14
|
+
result += ST + DCS;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
result += sequence;
|
|
19
|
+
}
|
|
20
|
+
result += ST;
|
|
21
|
+
return result;
|
|
22
|
+
}, "screenPassthrough");
|
|
23
|
+
const tmuxPassthrough = /* @__PURE__ */ __name((sequence) => {
|
|
24
|
+
let escapedSequence = "";
|
|
25
|
+
for (const element of sequence) {
|
|
26
|
+
escapedSequence += element === ESC ? ESC + ESC : element;
|
|
27
|
+
}
|
|
28
|
+
return `${DCS}tmux;${escapedSequence}${ST}`;
|
|
29
|
+
}, "tmuxPassthrough");
|
|
30
|
+
|
|
31
|
+
export { SCREEN_MAX_LEN_DEFAULT, SCREEN_TYPICAL_LIMIT, screenPassthrough, tmuxPassthrough };
|
package/dist/reset.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const RESET_INITIAL_STATE = "\x1Bc";
|
|
6
|
+
const RIS = RESET_INITIAL_STATE;
|
|
7
|
+
|
|
8
|
+
exports.RESET_INITIAL_STATE = RESET_INITIAL_STATE;
|
|
9
|
+
exports.RIS = RIS;
|
package/dist/reset.d.cts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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/reset.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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/reset.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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/reset.mjs
ADDED
package/dist/screen.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const constants = require('./packem_shared/constants-BK26O-46.cjs');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
const insertLine = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}L`, "insertLine");
|
|
10
|
+
const deleteLine = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}M`, "deleteLine");
|
|
11
|
+
const setTopBottomMargins = /* @__PURE__ */ __name((top, bottom) => {
|
|
12
|
+
const topString = top && top > 0 ? top.toString() : "";
|
|
13
|
+
const bottomString = bottom && bottom > 0 ? bottom.toString() : "";
|
|
14
|
+
if (topString === "" && bottomString === "") {
|
|
15
|
+
return `${constants.CSI + constants.SEP}r`;
|
|
16
|
+
}
|
|
17
|
+
return `${constants.CSI + topString + constants.SEP + bottomString}r`;
|
|
18
|
+
}, "setTopBottomMargins");
|
|
19
|
+
const setLeftRightMargins = /* @__PURE__ */ __name((left, right) => {
|
|
20
|
+
const leftString = left && left > 0 ? left.toString() : "";
|
|
21
|
+
const rightString = right && right > 0 ? right.toString() : "";
|
|
22
|
+
if (leftString === "" && rightString === "") {
|
|
23
|
+
return `${constants.CSI + constants.SEP}s`;
|
|
24
|
+
}
|
|
25
|
+
return `${constants.CSI + leftString + constants.SEP + rightString}s`;
|
|
26
|
+
}, "setLeftRightMargins");
|
|
27
|
+
const insertCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}@`, "insertCharacter");
|
|
28
|
+
const deleteCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}P`, "deleteCharacter");
|
|
29
|
+
const clearTabStop = /* @__PURE__ */ __name((mode = 0) => `${constants.CSI + mode}g`, "clearTabStop");
|
|
30
|
+
const requestPresentationStateReport = /* @__PURE__ */ __name((mode) => `${constants.CSI + mode}$u`, "requestPresentationStateReport");
|
|
31
|
+
const repeatPreviousCharacter = /* @__PURE__ */ __name((count = 1) => `${constants.CSI + (count <= 1 ? "" : count)}b`, "repeatPreviousCharacter");
|
|
32
|
+
|
|
33
|
+
exports.clearTabStop = clearTabStop;
|
|
34
|
+
exports.deleteCharacter = deleteCharacter;
|
|
35
|
+
exports.deleteLine = deleteLine;
|
|
36
|
+
exports.insertCharacter = insertCharacter;
|
|
37
|
+
exports.insertLine = insertLine;
|
|
38
|
+
exports.repeatPreviousCharacter = repeatPreviousCharacter;
|
|
39
|
+
exports.requestPresentationStateReport = requestPresentationStateReport;
|
|
40
|
+
exports.setLeftRightMargins = setLeftRightMargins;
|
|
41
|
+
exports.setTopBottomMargins = setTopBottomMargins;
|
|
@@ -0,0 +1,234 @@
|
|
|
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;
|