@visulima/ansi 2.0.1 → 3.0.1

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.
Files changed (152) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE.md +2 -133
  3. package/README.md +226 -226
  4. package/dist/alternative-screen.d.ts +6 -74
  5. package/dist/alternative-screen.js +1 -0
  6. package/dist/clear.d.ts +6 -77
  7. package/dist/clear.js +1 -0
  8. package/dist/cursor.d.ts +48 -429
  9. package/dist/cursor.js +1 -0
  10. package/dist/erase.d.ts +14 -197
  11. package/dist/erase.js +1 -0
  12. package/dist/hyperlink.d.ts +2 -26
  13. package/dist/hyperlink.js +1 -0
  14. package/dist/image.d.ts +7 -69
  15. package/dist/image.js +1 -0
  16. package/dist/index.d.ts +30 -35
  17. package/dist/index.js +1 -0
  18. package/dist/iterm2.d.ts +43 -58
  19. package/dist/iterm2.js +1 -0
  20. package/dist/mode.d.ts +174 -648
  21. package/dist/mode.js +1 -0
  22. package/dist/mouse.d.ts +21 -203
  23. package/dist/mouse.js +1 -0
  24. package/dist/packem_shared/IT2_AUTO-BYrffRAq.js +1 -0
  25. package/dist/packem_shared/ITerm2File-C88DBJC-.js +1 -0
  26. package/dist/packem_shared/constants-D12jy2Zh.js +1 -0
  27. package/dist/packem_shared/cursor-D2UOfUc_.js +1 -0
  28. package/dist/packem_shared/resetProgressBar-BtBbpWCM.js +1 -0
  29. package/dist/packem_shared/restoreCursor-D3XBmqcY.js +2 -0
  30. package/dist/passthrough.d.ts +6 -77
  31. package/dist/passthrough.js +1 -0
  32. package/dist/reset.d.ts +4 -26
  33. package/dist/reset.js +1 -0
  34. package/dist/screen.d.ts +11 -234
  35. package/dist/screen.js +1 -0
  36. package/dist/scroll.d.ts +6 -67
  37. package/dist/scroll.js +1 -0
  38. package/dist/status.d.ts +48 -498
  39. package/dist/status.js +1 -0
  40. package/dist/strip.d.ts +2 -22
  41. package/dist/strip.js +1 -0
  42. package/dist/termcap.d.ts +5 -38
  43. package/dist/termcap.js +1 -0
  44. package/dist/title.d.ts +10 -185
  45. package/dist/title.js +1 -0
  46. package/dist/window-ops.d.ts +24 -396
  47. package/dist/window-ops.js +1 -0
  48. package/dist/xterm.d.ts +12 -94
  49. package/dist/xterm.js +1 -0
  50. package/package.json +45 -230
  51. package/dist/alternative-screen.cjs +0 -17
  52. package/dist/alternative-screen.d.cts +0 -74
  53. package/dist/alternative-screen.d.mts +0 -74
  54. package/dist/alternative-screen.mjs +0 -10
  55. package/dist/clear.cjs +0 -17
  56. package/dist/clear.d.cts +0 -77
  57. package/dist/clear.d.mts +0 -77
  58. package/dist/clear.mjs +0 -10
  59. package/dist/constants.d.cts +0 -20
  60. package/dist/constants.d.mts +0 -20
  61. package/dist/constants.d.ts +0 -20
  62. package/dist/cursor.cjs +0 -41
  63. package/dist/cursor.d.cts +0 -437
  64. package/dist/cursor.d.mts +0 -437
  65. package/dist/cursor.mjs +0 -3
  66. package/dist/erase.cjs +0 -64
  67. package/dist/erase.d.cts +0 -206
  68. package/dist/erase.d.mts +0 -206
  69. package/dist/erase.mjs +0 -49
  70. package/dist/helpers.d.cts +0 -14
  71. package/dist/helpers.d.mts +0 -14
  72. package/dist/helpers.d.ts +0 -14
  73. package/dist/hyperlink.cjs +0 -9
  74. package/dist/hyperlink.d.cts +0 -27
  75. package/dist/hyperlink.d.mts +0 -27
  76. package/dist/hyperlink.mjs +0 -7
  77. package/dist/image.cjs +0 -28
  78. package/dist/image.d.cts +0 -73
  79. package/dist/image.d.mts +0 -73
  80. package/dist/image.mjs +0 -24
  81. package/dist/index.cjs +0 -246
  82. package/dist/index.d.cts +0 -35
  83. package/dist/index.d.mts +0 -35
  84. package/dist/index.mjs +0 -25
  85. package/dist/iterm2/iterm2-properties.d.cts +0 -135
  86. package/dist/iterm2/iterm2-properties.d.mts +0 -135
  87. package/dist/iterm2/iterm2-properties.d.ts +0 -135
  88. package/dist/iterm2/iterm2-sequences.d.cts +0 -96
  89. package/dist/iterm2/iterm2-sequences.d.mts +0 -96
  90. package/dist/iterm2/iterm2-sequences.d.ts +0 -96
  91. package/dist/iterm2.cjs +0 -26
  92. package/dist/iterm2.d.cts +0 -58
  93. package/dist/iterm2.d.mts +0 -58
  94. package/dist/iterm2.mjs +0 -14
  95. package/dist/mode.cjs +0 -388
  96. package/dist/mode.d.cts +0 -657
  97. package/dist/mode.d.mts +0 -657
  98. package/dist/mode.mjs +0 -235
  99. package/dist/mouse.cjs +0 -127
  100. package/dist/mouse.d.cts +0 -230
  101. package/dist/mouse.d.mts +0 -230
  102. package/dist/mouse.mjs +0 -108
  103. package/dist/packem_shared/IT2_AUTO-5vTJQMm6.cjs +0 -15
  104. package/dist/packem_shared/IT2_AUTO-DnfCUXso.mjs +0 -8
  105. package/dist/packem_shared/ITerm2File-BGPqNSjB.cjs +0 -137
  106. package/dist/packem_shared/ITerm2File-DKFkdqdA.mjs +0 -130
  107. package/dist/packem_shared/constants-BK26O-46.cjs +0 -17
  108. package/dist/packem_shared/constants-CE7WkXh_.mjs +0 -9
  109. package/dist/packem_shared/cursor-CQKLCu7U.cjs +0 -105
  110. package/dist/packem_shared/cursor-DhFQcQ9g.mjs +0 -73
  111. package/dist/packem_shared/restoreCursor-C6pNB8UY.mjs +0 -336
  112. package/dist/packem_shared/restoreCursor-DC_ZKZwT.cjs +0 -342
  113. package/dist/passthrough.cjs +0 -38
  114. package/dist/passthrough.d.cts +0 -77
  115. package/dist/passthrough.d.mts +0 -77
  116. package/dist/passthrough.mjs +0 -31
  117. package/dist/reset.cjs +0 -9
  118. package/dist/reset.d.cts +0 -26
  119. package/dist/reset.d.mts +0 -26
  120. package/dist/reset.mjs +0 -4
  121. package/dist/screen.cjs +0 -41
  122. package/dist/screen.d.cts +0 -234
  123. package/dist/screen.d.mts +0 -234
  124. package/dist/screen.mjs +0 -29
  125. package/dist/scroll.cjs +0 -27
  126. package/dist/scroll.d.cts +0 -67
  127. package/dist/scroll.d.mts +0 -67
  128. package/dist/scroll.mjs +0 -20
  129. package/dist/status.cjs +0 -147
  130. package/dist/status.d.cts +0 -501
  131. package/dist/status.d.mts +0 -501
  132. package/dist/status.mjs +0 -104
  133. package/dist/strip.cjs +0 -20
  134. package/dist/strip.d.cts +0 -23
  135. package/dist/strip.d.mts +0 -23
  136. package/dist/strip.mjs +0 -18
  137. package/dist/termcap.cjs +0 -33
  138. package/dist/termcap.d.cts +0 -38
  139. package/dist/termcap.d.mts +0 -38
  140. package/dist/termcap.mjs +0 -27
  141. package/dist/title.cjs +0 -31
  142. package/dist/title.d.cts +0 -185
  143. package/dist/title.d.mts +0 -185
  144. package/dist/title.mjs +0 -20
  145. package/dist/window-ops.cjs +0 -85
  146. package/dist/window-ops.d.cts +0 -418
  147. package/dist/window-ops.d.mts +0 -418
  148. package/dist/window-ops.mjs +0 -63
  149. package/dist/xterm.cjs +0 -48
  150. package/dist/xterm.d.cts +0 -94
  151. package/dist/xterm.d.mts +0 -94
  152. package/dist/xterm.mjs +0 -35
package/dist/termcap.cjs DELETED
@@ -1,33 +0,0 @@
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 stringToHex = /* @__PURE__ */ __name((input) => {
10
- let hex = "";
11
- for (let index = 0; index < input.length; index += 1) {
12
- const charCode = input.codePointAt(index);
13
- if (charCode === void 0) {
14
- continue;
15
- }
16
- const byteHex = charCode.toString(16).toUpperCase();
17
- hex += byteHex.length === 1 ? `0${byteHex}` : byteHex;
18
- }
19
- return hex;
20
- }, "stringToHex");
21
- const XTGETTCAP = /* @__PURE__ */ __name((...caps) => {
22
- if (caps.length === 0) {
23
- return "";
24
- }
25
- const hexCaps = caps.map((cap) => stringToHex(cap));
26
- return `${constants.DCS}+q${hexCaps.join(constants.SEP)}${constants.ST}`;
27
- }, "XTGETTCAP");
28
- const requestTermcap = XTGETTCAP;
29
- const requestTerminfo = XTGETTCAP;
30
-
31
- exports.XTGETTCAP = XTGETTCAP;
32
- exports.requestTermcap = requestTermcap;
33
- exports.requestTerminfo = requestTerminfo;
@@ -1,38 +0,0 @@
1
- /**
2
- * Requests Termcap/Terminfo (XTGETTCAP) strings from the terminal.
3
- * Sequence: DCS + q &lt;Pt> ST
4
- * @param caps A list of termcap/terminfo capability names (e.g., "Co", "li", "cols").
5
- * @returns The XTGETTCAP sequence string.
6
- * @see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Device-Control-Strings-plus-q
7
- */
8
- export declare const XTGETTCAP: (...caps: string[]) => string;
9
- /**
10
- * Alias for {@link XTGETTCAP}.
11
- * Requests Termcap/Terminfo capability strings from the terminal.
12
- * @param caps A list of Termcap/Terminfo capability names.
13
- * @returns The XTGETTCAP escape sequence string.
14
- * @see XTGETTCAP
15
- * @example
16
- * ```typescript
17
- * import { requestTermcap } from "@visulima/ansi";
18
- *
19
- * const seq = requestTermcap("Co", "li"); // Requests colors and lines
20
- * process.stdout.write(seq);
21
- * ```
22
- */
23
- export declare const requestTermcap: (...caps: string[]) => string;
24
- /**
25
- * Alias for {@link XTGETTCAP}.
26
- * Requests Termcap/Terminfo capability strings from the terminal.
27
- * @param caps A list of Termcap/Terminfo capability names.
28
- * @returns The XTGETTCAP escape sequence string.
29
- * @see XTGETTCAP
30
- * @example
31
- * ```typescript
32
- * import { requestTerminfo } from "@visulima/ansi";
33
- *
34
- * const seq = requestTerminfo("Co", "li"); // Requests colors and lines
35
- * process.stdout.write(seq);
36
- * ```
37
- */
38
- export declare const requestTerminfo: (...caps: string[]) => string;
@@ -1,38 +0,0 @@
1
- /**
2
- * Requests Termcap/Terminfo (XTGETTCAP) strings from the terminal.
3
- * Sequence: DCS + q &lt;Pt> ST
4
- * @param caps A list of termcap/terminfo capability names (e.g., "Co", "li", "cols").
5
- * @returns The XTGETTCAP sequence string.
6
- * @see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Device-Control-Strings-plus-q
7
- */
8
- export declare const XTGETTCAP: (...caps: string[]) => string;
9
- /**
10
- * Alias for {@link XTGETTCAP}.
11
- * Requests Termcap/Terminfo capability strings from the terminal.
12
- * @param caps A list of Termcap/Terminfo capability names.
13
- * @returns The XTGETTCAP escape sequence string.
14
- * @see XTGETTCAP
15
- * @example
16
- * ```typescript
17
- * import { requestTermcap } from "@visulima/ansi";
18
- *
19
- * const seq = requestTermcap("Co", "li"); // Requests colors and lines
20
- * process.stdout.write(seq);
21
- * ```
22
- */
23
- export declare const requestTermcap: (...caps: string[]) => string;
24
- /**
25
- * Alias for {@link XTGETTCAP}.
26
- * Requests Termcap/Terminfo capability strings from the terminal.
27
- * @param caps A list of Termcap/Terminfo capability names.
28
- * @returns The XTGETTCAP escape sequence string.
29
- * @see XTGETTCAP
30
- * @example
31
- * ```typescript
32
- * import { requestTerminfo } from "@visulima/ansi";
33
- *
34
- * const seq = requestTerminfo("Co", "li"); // Requests colors and lines
35
- * process.stdout.write(seq);
36
- * ```
37
- */
38
- export declare const requestTerminfo: (...caps: string[]) => string;
package/dist/termcap.mjs DELETED
@@ -1,27 +0,0 @@
1
- import { D as DCS, a as ST, S as SEP } 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 stringToHex = /* @__PURE__ */ __name((input) => {
6
- let hex = "";
7
- for (let index = 0; index < input.length; index += 1) {
8
- const charCode = input.codePointAt(index);
9
- if (charCode === void 0) {
10
- continue;
11
- }
12
- const byteHex = charCode.toString(16).toUpperCase();
13
- hex += byteHex.length === 1 ? `0${byteHex}` : byteHex;
14
- }
15
- return hex;
16
- }, "stringToHex");
17
- const XTGETTCAP = /* @__PURE__ */ __name((...caps) => {
18
- if (caps.length === 0) {
19
- return "";
20
- }
21
- const hexCaps = caps.map((cap) => stringToHex(cap));
22
- return `${DCS}+q${hexCaps.join(SEP)}${ST}`;
23
- }, "XTGETTCAP");
24
- const requestTermcap = XTGETTCAP;
25
- const requestTerminfo = XTGETTCAP;
26
-
27
- export { XTGETTCAP, requestTermcap, requestTerminfo };
package/dist/title.cjs DELETED
@@ -1,31 +0,0 @@
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 validateTitle = /* @__PURE__ */ __name((title) => {
10
- if (typeof title !== "string") {
11
- throw new TypeError("Title must be a string");
12
- }
13
- return title.replaceAll(/[\u0007\u001B]/g, "");
14
- }, "validateTitle");
15
- const setIconNameAndWindowTitle = /* @__PURE__ */ __name((title) => `${constants.OSC}0;${validateTitle(title)}${constants.BEL}`, "setIconNameAndWindowTitle");
16
- const setIconName = /* @__PURE__ */ __name((iconName) => `${constants.OSC}1;${iconName}${constants.BEL}`, "setIconName");
17
- const setWindowTitle = /* @__PURE__ */ __name((title) => `${constants.OSC}2;${title}${constants.BEL}`, "setWindowTitle");
18
- const decswt = /* @__PURE__ */ __name((title) => setWindowTitle(`1;${title}`), "decswt");
19
- const decsin = /* @__PURE__ */ __name((name) => setWindowTitle(`L;${name}`), "decsin");
20
- const setIconNameAndWindowTitleWithST = /* @__PURE__ */ __name((title) => `${constants.OSC}0;${title}${constants.ST}`, "setIconNameAndWindowTitleWithST");
21
- const setIconNameWithST = /* @__PURE__ */ __name((iconName) => `${constants.OSC}1;${iconName}${constants.ST}`, "setIconNameWithST");
22
- const setWindowTitleWithST = /* @__PURE__ */ __name((title) => `${constants.OSC}2;${title}${constants.ST}`, "setWindowTitleWithST");
23
-
24
- exports.decsin = decsin;
25
- exports.decswt = decswt;
26
- exports.setIconName = setIconName;
27
- exports.setIconNameAndWindowTitle = setIconNameAndWindowTitle;
28
- exports.setIconNameAndWindowTitleWithST = setIconNameAndWindowTitleWithST;
29
- exports.setIconNameWithST = setIconNameWithST;
30
- exports.setWindowTitle = setWindowTitle;
31
- exports.setWindowTitleWithST = setWindowTitleWithST;
package/dist/title.d.cts DELETED
@@ -1,185 +0,0 @@
1
- /**
2
- * Sets the icon name and window title using an OSC (Operating System Command) sequence.
3
- * This typically affects the title shown in the window's title bar and the name used for the icon
4
- * when the window is minimized or in a taskbar.
5
- *
6
- * Uses the sequence: `OSC 0 ; title BEL`
7
- * - `OSC`: Operating System Command (`\x1b]`).
8
- * - `0`: Parameter indicating to set both icon name and window title.
9
- * - `title`: The string to set.
10
- * - `BEL`: Bell character (`\x07`) as terminator.
11
- * @param title The string to be set as both the icon name and the window title.
12
- * @returns The ANSI escape sequence for setting the icon name and window title.
13
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
14
- * @example
15
- * ```typescript
16
- * import { setIconNameAndWindowTitle } from "@visulima/ansi";
17
- *
18
- * process.stdout.write(setIconNameAndWindowTitle("My Application"));
19
- * // Sends: "\x1b]0;My Application\x07"
20
- * ```
21
- */
22
- export declare const setIconNameAndWindowTitle: (title: string) => string;
23
- /**
24
- * Sets the icon name using an OSC (Operating System Command) sequence.
25
- * This affects the name used for the icon when the window is minimized or in a taskbar.
26
- *
27
- * Uses the sequence: `OSC 1 ; iconName BEL`
28
- * - `OSC`: Operating System Command (`\x1b]`).
29
- * - `1`: Parameter indicating to set only the icon name.
30
- * - `iconName`: The string to set as the icon name.
31
- * - `BEL`: Bell character (`\x07`) as terminator.
32
- * @param iconName The string to be set as the icon name.
33
- * @returns The ANSI escape sequence for setting the icon name.
34
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
35
- * @example
36
- * ```typescript
37
- * import { setIconName } from "@visulima/ansi";
38
- *
39
- * process.stdout.write(setIconName("AppIcon"));
40
- * // Sends: "\x1b]1;AppIcon\x07"
41
- * ```
42
- */
43
- export declare const setIconName: (iconName: string) => string;
44
- /**
45
- * Sets the window title using an OSC (Operating System Command) sequence.
46
- * This affects the title shown in the window's title bar.
47
- *
48
- * Uses the sequence: `OSC 2 ; title BEL`
49
- * - `OSC`: Operating System Command (`\x1b]`).
50
- * - `2`: Parameter indicating to set only the window title.
51
- * - `title`: The string to set as the window title.
52
- * - `BEL`: Bell character (`\x07`) as terminator.
53
- * @param title The string to be set as the window title.
54
- * @returns The ANSI escape sequence for setting the window title.
55
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
56
- * @example
57
- * ```typescript
58
- * import { setWindowTitle } from "@visulima/ansi";
59
- *
60
- * process.stdout.write(setWindowTitle("Current Document - Editor"));
61
- * // Sends: "\x1b]2;Current Document - Editor\x07"
62
- * ```
63
- */
64
- export declare const setWindowTitle: (title: string) => string;
65
- /**
66
- * Sets a DEC Special Window Title (DECSWT) using an OSC sequence.
67
- * The original Go library implemented this by prepending "1;" to the title and using `setWindowTitle`,
68
- * resulting in an `OSC 2 ; 1;&lt;title&gt; BEL` sequence.
69
- * This differs from some interpretations where DECSWT might use `OSC 1`.
70
- * This implementation replicates the Go library's specific behavior.
71
- *
72
- * Note: DECSWT (`OSC 2;1;...BEL`) was introduced in the DEC VT520/VT525 family
73
- * and is ignored by earlier DEC terminals. Support varies across modern emulators;
74
- * for example, Zutty 0.6+ claims VT520 compatibility, but many others that handle
75
- * common OSC sequences may drop or ignore DECSWT.
76
- * If relying on this sequence, testing on actual VT520 hardware or emulators
77
- * with known VT520 support is recommended. Unsupported sequences are typically
78
- * silently ignored by most terminals.
79
- *
80
- * Uses the sequence: `OSC 2 ; 1;&lt;title&gt; BEL` (based on Go library's behavior)
81
- * @param title The title string.
82
- * @returns The ANSI escape sequence for DECSWT (as implemented).
83
- * @see EK-VT520-RM 5–134 (VT520 Programmer Reference Manual)
84
- * @see setWindowTitle
85
- * @example
86
- * ```typescript
87
- * import { decswt } from "@visulima/ansi";
88
- *
89
- * process.stdout.write(decswt("My Special Window"));
90
- * // Sends: "\\x1b]2;1;My Special Window\\x07"
91
- * ```
92
- */
93
- export declare const decswt: (title: string) => string;
94
- /**
95
- * Sets a DEC Special Icon Name (DECSIN) using an OSC sequence.
96
- * The original Go library implemented this by prepending "L;" to the name and using `setWindowTitle`,
97
- * resulting in an `OSC 2 ; L;&lt;name&gt; BEL` sequence.
98
- * This differs from some interpretations where DECSIN might use `OSC L` or `OSC 1`.
99
- * This implementation replicates the Go library's specific behavior.
100
- *
101
- * Note: DECSIN (`OSC 2;L;...BEL`) was introduced in the DEC VT520/VT525 family
102
- * and is ignored by earlier DEC terminals. Support varies across modern emulators;
103
- * for example, Zutty 0.6+ claims VT520 compatibility, but many others that handle
104
- * common OSC sequences may drop or ignore DECSIN.
105
- * If relying on this sequence, testing on actual VT520 hardware or emulators
106
- * with known VT520 support is recommended. Unsupported sequences are typically
107
- * silently ignored by most terminals.
108
- *
109
- * Uses the sequence: `OSC 2 ; L;&lt;name&gt; BEL` (based on Go library's behavior)
110
- * @param name The name or content for the DEC-style icon name.
111
- * @returns The ANSI escape sequence for DECSIN (as implemented).
112
- * @see EK-VT520-RM 5–134 (VT520 Programmer Reference Manual)
113
- * @see setWindowTitle
114
- * @example
115
- * ```typescript
116
- * import { decsin } from "@visulima/ansi";
117
- *
118
- * process.stdout.write(decsin("SpecialIcon"));
119
- * // Sends: "\\x1b]2;L;SpecialIcon\\x07"
120
- * ```
121
- */
122
- export declare const decsin: (name: string) => string;
123
- /**
124
- * Sets the icon name and window title using an OSC sequence, terminated with ST (String Terminator).
125
- * This is an alternative to the BEL-terminated version.
126
- *
127
- * Uses the sequence: `OSC 0 ; title ST`
128
- * - `OSC`: Operating System Command (`\x1b]`).
129
- * - `0`: Parameter indicating to set both icon name and window title.
130
- * - `title`: The string to set.
131
- * - `ST`: String Terminator (`\x1b\\`).
132
- * @param title The string to be set as both the icon name and the window title.
133
- * @returns The ANSI escape sequence for setting the icon name and window title, using ST.
134
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
135
- * @example
136
- * ```typescript
137
- * import { setIconNameAndWindowTitleWithST } from "@visulima/ansi";
138
- *
139
- * process.stdout.write(setIconNameAndWindowTitleWithST("My App ST"));
140
- * // Sends: "\x1b]0;My App ST\x1b\\"
141
- * ```
142
- */
143
- export declare const setIconNameAndWindowTitleWithST: (title: string) => string;
144
- /**
145
- * Sets the icon name using an OSC sequence, terminated with ST (String Terminator).
146
- * This is an alternative to the BEL-terminated version.
147
- *
148
- * Uses the sequence: `OSC 1 ; iconName ST`
149
- * - `OSC`: Operating System Command (`\x1b]`).
150
- * - `1`: Parameter indicating to set only the icon name.
151
- * - `iconName`: The string to set as the icon name.
152
- * - `ST`: String Terminator (`\x1b\\`).
153
- * @param iconName The string to be set as the icon name.
154
- * @returns The ANSI escape sequence for setting the icon name, using ST.
155
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
156
- * @example
157
- * ```typescript
158
- * import { setIconNameWithST } from "@visulima/ansi";
159
- *
160
- * process.stdout.write(setIconNameWithST("AppIcon ST"));
161
- * // Sends: "\x1b]1;AppIcon ST\x1b\\"
162
- * ```
163
- */
164
- export declare const setIconNameWithST: (iconName: string) => string;
165
- /**
166
- * Sets the window title using an OSC sequence, terminated with ST (String Terminator).
167
- * This is an alternative to the BEL-terminated version.
168
- *
169
- * Uses the sequence: `OSC 2 ; title ST`
170
- * - `OSC`: Operating System Command (`\x1b]`).
171
- * - `2`: Parameter indicating to set only the window title.
172
- * - `title`: The string to set as the window title.
173
- * - `ST`: String Terminator (`\x1b\\`).
174
- * @param title The string to be set as the window title.
175
- * @returns The ANSI escape sequence for setting the window title, using ST.
176
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
177
- * @example
178
- * ```typescript
179
- * import { setWindowTitleWithST } from "@visulima/ansi";
180
- *
181
- * process.stdout.write(setWindowTitleWithST("Document ST - Editor"));
182
- * // Sends: "\x1b]2;Document ST - Editor\x1b\\"
183
- * ```
184
- */
185
- export declare const setWindowTitleWithST: (title: string) => string;
package/dist/title.d.mts DELETED
@@ -1,185 +0,0 @@
1
- /**
2
- * Sets the icon name and window title using an OSC (Operating System Command) sequence.
3
- * This typically affects the title shown in the window's title bar and the name used for the icon
4
- * when the window is minimized or in a taskbar.
5
- *
6
- * Uses the sequence: `OSC 0 ; title BEL`
7
- * - `OSC`: Operating System Command (`\x1b]`).
8
- * - `0`: Parameter indicating to set both icon name and window title.
9
- * - `title`: The string to set.
10
- * - `BEL`: Bell character (`\x07`) as terminator.
11
- * @param title The string to be set as both the icon name and the window title.
12
- * @returns The ANSI escape sequence for setting the icon name and window title.
13
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
14
- * @example
15
- * ```typescript
16
- * import { setIconNameAndWindowTitle } from "@visulima/ansi";
17
- *
18
- * process.stdout.write(setIconNameAndWindowTitle("My Application"));
19
- * // Sends: "\x1b]0;My Application\x07"
20
- * ```
21
- */
22
- export declare const setIconNameAndWindowTitle: (title: string) => string;
23
- /**
24
- * Sets the icon name using an OSC (Operating System Command) sequence.
25
- * This affects the name used for the icon when the window is minimized or in a taskbar.
26
- *
27
- * Uses the sequence: `OSC 1 ; iconName BEL`
28
- * - `OSC`: Operating System Command (`\x1b]`).
29
- * - `1`: Parameter indicating to set only the icon name.
30
- * - `iconName`: The string to set as the icon name.
31
- * - `BEL`: Bell character (`\x07`) as terminator.
32
- * @param iconName The string to be set as the icon name.
33
- * @returns The ANSI escape sequence for setting the icon name.
34
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
35
- * @example
36
- * ```typescript
37
- * import { setIconName } from "@visulima/ansi";
38
- *
39
- * process.stdout.write(setIconName("AppIcon"));
40
- * // Sends: "\x1b]1;AppIcon\x07"
41
- * ```
42
- */
43
- export declare const setIconName: (iconName: string) => string;
44
- /**
45
- * Sets the window title using an OSC (Operating System Command) sequence.
46
- * This affects the title shown in the window's title bar.
47
- *
48
- * Uses the sequence: `OSC 2 ; title BEL`
49
- * - `OSC`: Operating System Command (`\x1b]`).
50
- * - `2`: Parameter indicating to set only the window title.
51
- * - `title`: The string to set as the window title.
52
- * - `BEL`: Bell character (`\x07`) as terminator.
53
- * @param title The string to be set as the window title.
54
- * @returns The ANSI escape sequence for setting the window title.
55
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
56
- * @example
57
- * ```typescript
58
- * import { setWindowTitle } from "@visulima/ansi";
59
- *
60
- * process.stdout.write(setWindowTitle("Current Document - Editor"));
61
- * // Sends: "\x1b]2;Current Document - Editor\x07"
62
- * ```
63
- */
64
- export declare const setWindowTitle: (title: string) => string;
65
- /**
66
- * Sets a DEC Special Window Title (DECSWT) using an OSC sequence.
67
- * The original Go library implemented this by prepending "1;" to the title and using `setWindowTitle`,
68
- * resulting in an `OSC 2 ; 1;&lt;title&gt; BEL` sequence.
69
- * This differs from some interpretations where DECSWT might use `OSC 1`.
70
- * This implementation replicates the Go library's specific behavior.
71
- *
72
- * Note: DECSWT (`OSC 2;1;...BEL`) was introduced in the DEC VT520/VT525 family
73
- * and is ignored by earlier DEC terminals. Support varies across modern emulators;
74
- * for example, Zutty 0.6+ claims VT520 compatibility, but many others that handle
75
- * common OSC sequences may drop or ignore DECSWT.
76
- * If relying on this sequence, testing on actual VT520 hardware or emulators
77
- * with known VT520 support is recommended. Unsupported sequences are typically
78
- * silently ignored by most terminals.
79
- *
80
- * Uses the sequence: `OSC 2 ; 1;&lt;title&gt; BEL` (based on Go library's behavior)
81
- * @param title The title string.
82
- * @returns The ANSI escape sequence for DECSWT (as implemented).
83
- * @see EK-VT520-RM 5–134 (VT520 Programmer Reference Manual)
84
- * @see setWindowTitle
85
- * @example
86
- * ```typescript
87
- * import { decswt } from "@visulima/ansi";
88
- *
89
- * process.stdout.write(decswt("My Special Window"));
90
- * // Sends: "\\x1b]2;1;My Special Window\\x07"
91
- * ```
92
- */
93
- export declare const decswt: (title: string) => string;
94
- /**
95
- * Sets a DEC Special Icon Name (DECSIN) using an OSC sequence.
96
- * The original Go library implemented this by prepending "L;" to the name and using `setWindowTitle`,
97
- * resulting in an `OSC 2 ; L;&lt;name&gt; BEL` sequence.
98
- * This differs from some interpretations where DECSIN might use `OSC L` or `OSC 1`.
99
- * This implementation replicates the Go library's specific behavior.
100
- *
101
- * Note: DECSIN (`OSC 2;L;...BEL`) was introduced in the DEC VT520/VT525 family
102
- * and is ignored by earlier DEC terminals. Support varies across modern emulators;
103
- * for example, Zutty 0.6+ claims VT520 compatibility, but many others that handle
104
- * common OSC sequences may drop or ignore DECSIN.
105
- * If relying on this sequence, testing on actual VT520 hardware or emulators
106
- * with known VT520 support is recommended. Unsupported sequences are typically
107
- * silently ignored by most terminals.
108
- *
109
- * Uses the sequence: `OSC 2 ; L;&lt;name&gt; BEL` (based on Go library's behavior)
110
- * @param name The name or content for the DEC-style icon name.
111
- * @returns The ANSI escape sequence for DECSIN (as implemented).
112
- * @see EK-VT520-RM 5–134 (VT520 Programmer Reference Manual)
113
- * @see setWindowTitle
114
- * @example
115
- * ```typescript
116
- * import { decsin } from "@visulima/ansi";
117
- *
118
- * process.stdout.write(decsin("SpecialIcon"));
119
- * // Sends: "\\x1b]2;L;SpecialIcon\\x07"
120
- * ```
121
- */
122
- export declare const decsin: (name: string) => string;
123
- /**
124
- * Sets the icon name and window title using an OSC sequence, terminated with ST (String Terminator).
125
- * This is an alternative to the BEL-terminated version.
126
- *
127
- * Uses the sequence: `OSC 0 ; title ST`
128
- * - `OSC`: Operating System Command (`\x1b]`).
129
- * - `0`: Parameter indicating to set both icon name and window title.
130
- * - `title`: The string to set.
131
- * - `ST`: String Terminator (`\x1b\\`).
132
- * @param title The string to be set as both the icon name and the window title.
133
- * @returns The ANSI escape sequence for setting the icon name and window title, using ST.
134
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
135
- * @example
136
- * ```typescript
137
- * import { setIconNameAndWindowTitleWithST } from "@visulima/ansi";
138
- *
139
- * process.stdout.write(setIconNameAndWindowTitleWithST("My App ST"));
140
- * // Sends: "\x1b]0;My App ST\x1b\\"
141
- * ```
142
- */
143
- export declare const setIconNameAndWindowTitleWithST: (title: string) => string;
144
- /**
145
- * Sets the icon name using an OSC sequence, terminated with ST (String Terminator).
146
- * This is an alternative to the BEL-terminated version.
147
- *
148
- * Uses the sequence: `OSC 1 ; iconName ST`
149
- * - `OSC`: Operating System Command (`\x1b]`).
150
- * - `1`: Parameter indicating to set only the icon name.
151
- * - `iconName`: The string to set as the icon name.
152
- * - `ST`: String Terminator (`\x1b\\`).
153
- * @param iconName The string to be set as the icon name.
154
- * @returns The ANSI escape sequence for setting the icon name, using ST.
155
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
156
- * @example
157
- * ```typescript
158
- * import { setIconNameWithST } from "@visulima/ansi";
159
- *
160
- * process.stdout.write(setIconNameWithST("AppIcon ST"));
161
- * // Sends: "\x1b]1;AppIcon ST\x1b\\"
162
- * ```
163
- */
164
- export declare const setIconNameWithST: (iconName: string) => string;
165
- /**
166
- * Sets the window title using an OSC sequence, terminated with ST (String Terminator).
167
- * This is an alternative to the BEL-terminated version.
168
- *
169
- * Uses the sequence: `OSC 2 ; title ST`
170
- * - `OSC`: Operating System Command (`\x1b]`).
171
- * - `2`: Parameter indicating to set only the window title.
172
- * - `title`: The string to set as the window title.
173
- * - `ST`: String Terminator (`\x1b\\`).
174
- * @param title The string to be set as the window title.
175
- * @returns The ANSI escape sequence for setting the window title, using ST.
176
- * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands Xterm OSC documentation}
177
- * @example
178
- * ```typescript
179
- * import { setWindowTitleWithST } from "@visulima/ansi";
180
- *
181
- * process.stdout.write(setWindowTitleWithST("Document ST - Editor"));
182
- * // Sends: "\x1b]2;Document ST - Editor\x1b\\"
183
- * ```
184
- */
185
- export declare const setWindowTitleWithST: (title: string) => string;
package/dist/title.mjs DELETED
@@ -1,20 +0,0 @@
1
- import { O as OSC, B as BEL, a as ST } 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 validateTitle = /* @__PURE__ */ __name((title) => {
6
- if (typeof title !== "string") {
7
- throw new TypeError("Title must be a string");
8
- }
9
- return title.replaceAll(/[\u0007\u001B]/g, "");
10
- }, "validateTitle");
11
- const setIconNameAndWindowTitle = /* @__PURE__ */ __name((title) => `${OSC}0;${validateTitle(title)}${BEL}`, "setIconNameAndWindowTitle");
12
- const setIconName = /* @__PURE__ */ __name((iconName) => `${OSC}1;${iconName}${BEL}`, "setIconName");
13
- const setWindowTitle = /* @__PURE__ */ __name((title) => `${OSC}2;${title}${BEL}`, "setWindowTitle");
14
- const decswt = /* @__PURE__ */ __name((title) => setWindowTitle(`1;${title}`), "decswt");
15
- const decsin = /* @__PURE__ */ __name((name) => setWindowTitle(`L;${name}`), "decsin");
16
- const setIconNameAndWindowTitleWithST = /* @__PURE__ */ __name((title) => `${OSC}0;${title}${ST}`, "setIconNameAndWindowTitleWithST");
17
- const setIconNameWithST = /* @__PURE__ */ __name((iconName) => `${OSC}1;${iconName}${ST}`, "setIconNameWithST");
18
- const setWindowTitleWithST = /* @__PURE__ */ __name((title) => `${OSC}2;${title}${ST}`, "setWindowTitleWithST");
19
-
20
- export { decsin, decswt, setIconName, setIconNameAndWindowTitle, setIconNameAndWindowTitleWithST, setIconNameWithST, setWindowTitle, setWindowTitleWithST };
@@ -1,85 +0,0 @@
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
- var XTermWindowOp = /* @__PURE__ */ ((XTermWindowOp2) => {
10
- XTermWindowOp2[XTermWindowOp2["DEICONIFY_WINDOW"] = 1] = "DEICONIFY_WINDOW";
11
- XTermWindowOp2[XTermWindowOp2["ICONIFY_WINDOW"] = 2] = "ICONIFY_WINDOW";
12
- XTermWindowOp2[XTermWindowOp2["LOWER_WINDOW"] = 6] = "LOWER_WINDOW";
13
- XTermWindowOp2[XTermWindowOp2["MAXIMIZE_WINDOW"] = 10] = "MAXIMIZE_WINDOW";
14
- XTermWindowOp2[XTermWindowOp2["MAXIMIZE_WINDOW_HORIZONTALLY"] = 10.2] = "MAXIMIZE_WINDOW_HORIZONTALLY";
15
- XTermWindowOp2[XTermWindowOp2["MAXIMIZE_WINDOW_VERTICALLY"] = 10.1] = "MAXIMIZE_WINDOW_VERTICALLY";
16
- XTermWindowOp2[XTermWindowOp2["MOVE_WINDOW"] = 3] = "MOVE_WINDOW";
17
- XTermWindowOp2[XTermWindowOp2["POP_WINDOW_TITLE"] = 23] = "POP_WINDOW_TITLE";
18
- XTermWindowOp2[XTermWindowOp2["PUSH_WINDOW_TITLE"] = 22] = "PUSH_WINDOW_TITLE";
19
- XTermWindowOp2[XTermWindowOp2["RAISE_WINDOW"] = 5] = "RAISE_WINDOW";
20
- XTermWindowOp2[XTermWindowOp2["REFRESH_WINDOW"] = 7] = "REFRESH_WINDOW";
21
- XTermWindowOp2[XTermWindowOp2["REPORT_CELL_SIZE_PIXELS"] = 16] = "REPORT_CELL_SIZE_PIXELS";
22
- XTermWindowOp2[XTermWindowOp2["REPORT_ICON_LABEL"] = 19] = "REPORT_ICON_LABEL";
23
- XTermWindowOp2[XTermWindowOp2["REPORT_TEXT_AREA_SIZE_CHARS"] = 14] = "REPORT_TEXT_AREA_SIZE_CHARS";
24
- XTermWindowOp2[XTermWindowOp2["REPORT_TEXT_AREA_SIZE_PIXELS"] = 18] = "REPORT_TEXT_AREA_SIZE_PIXELS";
25
- XTermWindowOp2[XTermWindowOp2["REPORT_WINDOW_POSITION"] = 13] = "REPORT_WINDOW_POSITION";
26
- XTermWindowOp2[XTermWindowOp2["REPORT_WINDOW_STATE"] = 11] = "REPORT_WINDOW_STATE";
27
- XTermWindowOp2[XTermWindowOp2["REPORT_WINDOW_TITLE"] = 21] = "REPORT_WINDOW_TITLE";
28
- XTermWindowOp2[XTermWindowOp2["REQUEST_WINDOW_SIZE_WIN_OP_COMPAT"] = 14] = "REQUEST_WINDOW_SIZE_WIN_OP_COMPAT";
29
- XTermWindowOp2[XTermWindowOp2["RESIZE_SCREEN_AND_TEXT_AREA"] = 24] = "RESIZE_SCREEN_AND_TEXT_AREA";
30
- XTermWindowOp2[XTermWindowOp2["RESIZE_TEXT_AREA_CHARS"] = 4] = "RESIZE_TEXT_AREA_CHARS";
31
- XTermWindowOp2[XTermWindowOp2["RESIZE_TEXT_AREA_PIXELS"] = 8] = "RESIZE_TEXT_AREA_PIXELS";
32
- XTermWindowOp2[XTermWindowOp2["RESTORE_MAXIMIZED_WINDOW"] = 9] = "RESTORE_MAXIMIZED_WINDOW";
33
- XTermWindowOp2[XTermWindowOp2["UNDO_FULL_SCREEN_MODE"] = 10.3] = "UNDO_FULL_SCREEN_MODE";
34
- return XTermWindowOp2;
35
- })(XTermWindowOp || {});
36
- const xtermWindowOp = /* @__PURE__ */ __name((p, ...ps) => {
37
- const allowedFloats = [10.1 /* MAXIMIZE_WINDOW_VERTICALLY */, 10.2 /* MAXIMIZE_WINDOW_HORIZONTALLY */, 10.3 /* UNDO_FULL_SCREEN_MODE */];
38
- if (allowedFloats.includes(p)) ; else if (p <= 0) {
39
- return "";
40
- }
41
- const parameters = [p];
42
- for (const value of ps) {
43
- if (value >= 0) {
44
- parameters.push(value);
45
- }
46
- }
47
- return `${constants.CSI}${parameters.join(";")}t`;
48
- }, "xtermWindowOp");
49
- const XTWINOPS = xtermWindowOp;
50
- const resizeTextAreaChars = /* @__PURE__ */ __name((height, width) => xtermWindowOp(4 /* RESIZE_TEXT_AREA_CHARS */, height, width), "resizeTextAreaChars");
51
- const requestTextAreaSizeChars = /* @__PURE__ */ __name(() => xtermWindowOp(14 /* REQUEST_WINDOW_SIZE_WIN_OP_COMPAT */), "requestTextAreaSizeChars");
52
- const requestCellSizePixels = /* @__PURE__ */ __name(() => xtermWindowOp(16 /* REPORT_CELL_SIZE_PIXELS */), "requestCellSizePixels");
53
- const requestTextAreaSizePixels = /* @__PURE__ */ __name(() => xtermWindowOp(18 /* REPORT_TEXT_AREA_SIZE_PIXELS */), "requestTextAreaSizePixels");
54
- const deiconifyWindow = /* @__PURE__ */ __name(() => xtermWindowOp(1 /* DEICONIFY_WINDOW */), "deiconifyWindow");
55
- const iconifyWindow = /* @__PURE__ */ __name(() => xtermWindowOp(2 /* ICONIFY_WINDOW */), "iconifyWindow");
56
- const moveWindow = /* @__PURE__ */ __name((x, y) => xtermWindowOp(3 /* MOVE_WINDOW */, x, y), "moveWindow");
57
- const raiseWindow = /* @__PURE__ */ __name(() => xtermWindowOp(5 /* RAISE_WINDOW */), "raiseWindow");
58
- const lowerWindow = /* @__PURE__ */ __name(() => xtermWindowOp(6 /* LOWER_WINDOW */), "lowerWindow");
59
- const refreshWindow = /* @__PURE__ */ __name(() => xtermWindowOp(7 /* REFRESH_WINDOW */), "refreshWindow");
60
- const resizeTextAreaPixels = /* @__PURE__ */ __name((height, width) => xtermWindowOp(8 /* RESIZE_TEXT_AREA_PIXELS */, height, width), "resizeTextAreaPixels");
61
- const restoreMaximizedWindow = /* @__PURE__ */ __name(() => xtermWindowOp(9 /* RESTORE_MAXIMIZED_WINDOW */), "restoreMaximizedWindow");
62
- const maximizeWindow = /* @__PURE__ */ __name(() => xtermWindowOp(10 /* MAXIMIZE_WINDOW */), "maximizeWindow");
63
- const reportWindowPosition = /* @__PURE__ */ __name(() => xtermWindowOp(13 /* REPORT_WINDOW_POSITION */), "reportWindowPosition");
64
- const reportWindowState = /* @__PURE__ */ __name(() => xtermWindowOp(11 /* REPORT_WINDOW_STATE */), "reportWindowState");
65
- const setPageSizeLines = /* @__PURE__ */ __name((lines) => xtermWindowOp(24 /* RESIZE_SCREEN_AND_TEXT_AREA */, lines), "setPageSizeLines");
66
-
67
- exports.XTWINOPS = XTWINOPS;
68
- exports.XTermWindowOp = XTermWindowOp;
69
- exports.deiconifyWindow = deiconifyWindow;
70
- exports.iconifyWindow = iconifyWindow;
71
- exports.lowerWindow = lowerWindow;
72
- exports.maximizeWindow = maximizeWindow;
73
- exports.moveWindow = moveWindow;
74
- exports.raiseWindow = raiseWindow;
75
- exports.refreshWindow = refreshWindow;
76
- exports.reportWindowPosition = reportWindowPosition;
77
- exports.reportWindowState = reportWindowState;
78
- exports.requestCellSizePixels = requestCellSizePixels;
79
- exports.requestTextAreaSizeChars = requestTextAreaSizeChars;
80
- exports.requestTextAreaSizePixels = requestTextAreaSizePixels;
81
- exports.resizeTextAreaChars = resizeTextAreaChars;
82
- exports.resizeTextAreaPixels = resizeTextAreaPixels;
83
- exports.restoreMaximizedWindow = restoreMaximizedWindow;
84
- exports.setPageSizeLines = setPageSizeLines;
85
- exports.xtermWindowOp = xtermWindowOp;