@visulima/ansi 2.0.0 → 3.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.
Files changed (152) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE.md +1 -132
  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 +1 -27
  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 +1 -23
  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 -29
  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 -25
  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/erase.d.cts DELETED
@@ -1,206 +0,0 @@
1
- /**
2
- * Defines the modes for erasing parts of the display using the ED (Erase in Display) sequence.
3
- * The ED sequence is `CSI Ps J`, where `Ps` is one of these mode values.
4
- * @see {@link eraseDisplay} for the function that generates ED sequences.
5
- * @see {@link https://vt100.net/docs/vt510-rm/ED.html} VT510 Erase in Display (ED) documentation.
6
- * @enum {number}
7
- */
8
- export declare enum EraseDisplayMode {
9
- /**
10
- * Clears the entire screen. The cursor position usually does not change, but this can be
11
- * terminal-dependent. Some terminals might move the cursor to the home position (top-left).
12
- * This corresponds to `Ps=2` in `CSI Ps J`.
13
- * Sequence: `CSI 2J`.
14
- */
15
- EntireScreen = 2,
16
- /**
17
- * Clears the entire screen and, on supported terminals (like XTerm and derivatives),
18
- * also deletes all lines saved in the scrollback buffer.
19
- * This corresponds to `Ps=3` in `CSI Ps J` (an XTerm extension, widely adopted).
20
- * Sequence: `CSI 3J`.
21
- * @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
22
- */
23
- EntireScreenAndScrollback = 3,
24
- /**
25
- * Clears from the beginning of the screen to the current cursor position (inclusive).
26
- * This corresponds to `Ps=1` in `CSI Ps J`.
27
- * Sequence: `CSI 1J`.
28
- */
29
- ToBeginning = 1,
30
- /**
31
- * Clears from the current cursor position to the end of the screen (inclusive).
32
- * If the cursor is at the top-left, this clears the entire screen.
33
- * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps J`.
34
- * Sequence: `CSI J` or `CSI 0J`.
35
- */
36
- ToEnd = 0
37
- }
38
- /**
39
- * Generates an ANSI escape sequence to erase parts of the display (ED - Erase in Display).
40
- * The specific sequence is `CSI <mode>J`, where `<mode>` is a parameter from {@link EraseDisplayMode}.
41
- *
42
- * - If `mode` is `EraseDisplayMode.ToEnd` (or `0`), the sequence can be shortened to `CSI J`.
43
- * - The function validates the input `mode`. If an invalid number is provided, it defaults to `EraseDisplayMode.ToEnd`.
44
- * @param mode The erase mode, specified as a value from `EraseDisplayMode` or its corresponding number (0, 1, 2, 3).
45
- * @returns The ANSI escape sequence string for erasing in display.
46
- * @example
47
- * ```typescript
48
- * import { eraseDisplay, EraseDisplayMode } from '@visulima/ansi/erase';
49
- *
50
- * // Erase from cursor to end of screen
51
- * process.stdout.write(eraseDisplay(EraseDisplayMode.ToEnd)); // or eraseDisplay(0)
52
- *
53
- * // Erase entire screen
54
- * process.stdout.write(eraseDisplay(EraseDisplayMode.EntireScreen)); // or eraseDisplay(2)
55
- *
56
- * // Erase entire screen and scrollback buffer
57
- * process.stdout.write(eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)); // or eraseDisplay(3)
58
- * ```
59
- * @see {@link EraseDisplayMode}
60
- * @see {@link https://vt100.net/docs/vt510-rm/ED.html} VT510 Erase in Display (ED) documentation.
61
- */
62
- export declare const eraseDisplay: (mode: EraseDisplayMode | 0 | 1 | 2 | 3) => string;
63
- /**
64
- * Defines the modes for erasing parts of the current line using the EL (Erase in Line) sequence.
65
- * The EL sequence is `CSI Ps K`, where `Ps` is one of these mode values.
66
- * The cursor position is NOT affected by EL sequences.
67
- * @see {@link eraseInLine} for the function that generates EL sequences.
68
- * @see {@link https://vt100.net/docs/vt510-rm/EL.html} VT510 Erase in Line (EL) documentation.
69
- * @enum {number}
70
- */
71
- export declare enum EraseLineMode {
72
- /**
73
- * Clears the entire current line.
74
- * This corresponds to `Ps=2` in `CSI Ps K`.
75
- * Sequence: `CSI 2K`.
76
- */
77
- EntireLine = 2,
78
- /**
79
- * Clears from the beginning of the line to the current cursor position (inclusive).
80
- * This corresponds to `Ps=1` in `CSI Ps K`.
81
- * Sequence: `CSI 1K`.
82
- */
83
- ToBeginning = 1,
84
- /**
85
- * Clears from the current cursor position to the end of the line (inclusive).
86
- * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps K`.
87
- * Sequence: `CSI K` or `CSI 0K`.
88
- */
89
- ToEnd = 0
90
- }
91
- /**
92
- * Generates an ANSI escape sequence to erase parts of the current line (EL - Erase in Line).
93
- * The specific sequence is `CSI <mode>K`, where `<mode>` is a parameter from {@link EraseLineMode}.
94
- * The cursor position is NOT changed by this sequence.
95
- *
96
- * - If `mode` is `EraseLineMode.ToEnd` (or `0`), the sequence can be shortened to `CSI K`.
97
- * - The function validates the input `mode`. If an invalid number is provided, it defaults to `EraseLineMode.ToEnd`.
98
- * @param mode The erase mode, specified as a value from `EraseLineMode` or its corresponding number (0, 1, 2).
99
- * @returns The ANSI escape sequence string for erasing in line.
100
- * @example
101
- * ```typescript
102
- * import { eraseInLine, EraseLineMode } from '@visulima/ansi/erase';
103
- *
104
- * // Erase from cursor to end of line
105
- * process.stdout.write(eraseInLine(EraseLineMode.ToEnd)); // or eraseInLine(0)
106
- *
107
- * // Erase entire current line
108
- * process.stdout.write(eraseInLine(EraseLineMode.EntireLine)); // or eraseInLine(2)
109
- * ```
110
- * @see {@link EraseLineMode}
111
- * @see {@link https://vt100.net/docs/vt510-rm/EL.html} VT510 Erase in Line (EL) documentation.
112
- */
113
- export declare const eraseInLine: (mode: EraseLineMode | 0 | 1 | 2) => string;
114
- /**
115
- * Erases the screen from the current cursor position down to the bottom of the screen (inclusive).
116
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.ToEnd)`.
117
- * Sequence: `CSI J` (or `CSI 0J`).
118
- * @returns The ANSI escape sequence `CSI J`.
119
- * @see {@link eraseDisplay}
120
- * @see {@link EraseDisplayMode.ToEnd}
121
- */
122
- export declare const eraseDown: string;
123
- /**
124
- * Erases the entire current line. The cursor position does not change.
125
- * This is a convenience constant for `eraseInLine(EraseLineMode.EntireLine)`.
126
- * Sequence: `CSI 2K`.
127
- * @returns The ANSI escape sequence `CSI 2K`.
128
- * @see {@link eraseInLine}
129
- * @see {@link EraseLineMode.EntireLine}
130
- */
131
- export declare const eraseLine: string;
132
- /**
133
- * Erases from the current cursor position to the end of the current line (inclusive).
134
- * The cursor position does not change.
135
- * This is a convenience constant for `eraseInLine(EraseLineMode.ToEnd)`.
136
- * Sequence: `CSI K` (or `CSI 0K`).
137
- * @returns The ANSI escape sequence `CSI K`.
138
- * @see {@link eraseInLine}
139
- * @see {@link EraseLineMode.ToEnd}
140
- */
141
- export declare const eraseLineEnd: string;
142
- /**
143
- * Erases from the current cursor position to the beginning of the current line (inclusive).
144
- * The cursor position does not change.
145
- * This is a convenience constant for `eraseInLine(EraseLineMode.ToBeginning)`.
146
- * Sequence: `CSI 1K`.
147
- * @returns The ANSI escape sequence `CSI 1K`.
148
- * @see {@link eraseInLine}
149
- * @see {@link EraseLineMode.ToBeginning}
150
- */
151
- export declare const eraseLineStart: string;
152
- /**
153
- * Erases a specified number of lines, starting from the current line and moving upwards,
154
- * then moves the cursor to the beginning of the topmost erased line (which becomes the new current line).
155
- *
156
- * This is a custom helper function, not a single standard ANSI/VT sequence. It combines
157
- * multiple sequences: {@link eraseLine} to clear each line, {@link cursorUp} to move to the line above,
158
- * and finally {@link cursorToColumn1} to position the cursor at the start of the resulting current line.
159
- * @param count The total number of lines to erase. This includes the current line and `count-1` lines above it.
160
- * If `count` is 0 or negative, an empty string is returned (no operation).
161
- * @returns A string of concatenated ANSI escape sequences to perform the operation.
162
- * @example
163
- * ```typescript
164
- * import { eraseLines } from '@visulima/ansi/erase';
165
- *
166
- * // To erase the current line and the 2 lines above it (total 3 lines):
167
- * process.stdout.write(eraseLines(3));
168
- * // Conceptual sequence of operations:
169
- * // 1. Erase current line
170
- * // 2. Cursor up
171
- * // 3. Erase current line (which was the line above the original)
172
- * // 4. Cursor up
173
- * // 5. Erase current line (which was two lines above the original)
174
- * // 6. Cursor to column 1 (on this topmost erased line)
175
- * ```
176
- */
177
- export declare const eraseLines: (count: number) => string;
178
- /**
179
- * Erases the entire screen. The cursor position usually does not change, though this can be terminal-dependent.
180
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.EntireScreen)`.
181
- * Sequence: `CSI 2J`.
182
- * @returns The ANSI escape sequence `CSI 2J`.
183
- * @see {@link eraseDisplay}
184
- * @see {@link EraseDisplayMode.EntireScreen}
185
- */
186
- export declare const eraseScreen: string;
187
- /**
188
- * Erases the screen from the current cursor position up to the top of the screen (inclusive).
189
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.ToBeginning)`.
190
- * Sequence: `CSI 1J`.
191
- * @returns The ANSI escape sequence `CSI 1J`.
192
- * @see {@link eraseDisplay}
193
- * @see {@link EraseDisplayMode.ToBeginning}
194
- */
195
- export declare const eraseUp: string;
196
- /**
197
- * Erases the entire screen and, on supported terminals (like XTerm and derivatives),
198
- * also deletes all lines saved in the scrollback buffer.
199
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)`.
200
- * Sequence: `CSI 3J` (an XTerm extension, widely adopted).
201
- * @returns The ANSI escape sequence `CSI 3J`.
202
- * @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
203
- * @see {@link eraseDisplay}
204
- * @see {@link EraseDisplayMode.EntireScreenAndScrollback}
205
- */
206
- export declare const eraseScreenAndScrollback: string;
package/dist/erase.d.mts DELETED
@@ -1,206 +0,0 @@
1
- /**
2
- * Defines the modes for erasing parts of the display using the ED (Erase in Display) sequence.
3
- * The ED sequence is `CSI Ps J`, where `Ps` is one of these mode values.
4
- * @see {@link eraseDisplay} for the function that generates ED sequences.
5
- * @see {@link https://vt100.net/docs/vt510-rm/ED.html} VT510 Erase in Display (ED) documentation.
6
- * @enum {number}
7
- */
8
- export declare enum EraseDisplayMode {
9
- /**
10
- * Clears the entire screen. The cursor position usually does not change, but this can be
11
- * terminal-dependent. Some terminals might move the cursor to the home position (top-left).
12
- * This corresponds to `Ps=2` in `CSI Ps J`.
13
- * Sequence: `CSI 2J`.
14
- */
15
- EntireScreen = 2,
16
- /**
17
- * Clears the entire screen and, on supported terminals (like XTerm and derivatives),
18
- * also deletes all lines saved in the scrollback buffer.
19
- * This corresponds to `Ps=3` in `CSI Ps J` (an XTerm extension, widely adopted).
20
- * Sequence: `CSI 3J`.
21
- * @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
22
- */
23
- EntireScreenAndScrollback = 3,
24
- /**
25
- * Clears from the beginning of the screen to the current cursor position (inclusive).
26
- * This corresponds to `Ps=1` in `CSI Ps J`.
27
- * Sequence: `CSI 1J`.
28
- */
29
- ToBeginning = 1,
30
- /**
31
- * Clears from the current cursor position to the end of the screen (inclusive).
32
- * If the cursor is at the top-left, this clears the entire screen.
33
- * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps J`.
34
- * Sequence: `CSI J` or `CSI 0J`.
35
- */
36
- ToEnd = 0
37
- }
38
- /**
39
- * Generates an ANSI escape sequence to erase parts of the display (ED - Erase in Display).
40
- * The specific sequence is `CSI <mode>J`, where `<mode>` is a parameter from {@link EraseDisplayMode}.
41
- *
42
- * - If `mode` is `EraseDisplayMode.ToEnd` (or `0`), the sequence can be shortened to `CSI J`.
43
- * - The function validates the input `mode`. If an invalid number is provided, it defaults to `EraseDisplayMode.ToEnd`.
44
- * @param mode The erase mode, specified as a value from `EraseDisplayMode` or its corresponding number (0, 1, 2, 3).
45
- * @returns The ANSI escape sequence string for erasing in display.
46
- * @example
47
- * ```typescript
48
- * import { eraseDisplay, EraseDisplayMode } from '@visulima/ansi/erase';
49
- *
50
- * // Erase from cursor to end of screen
51
- * process.stdout.write(eraseDisplay(EraseDisplayMode.ToEnd)); // or eraseDisplay(0)
52
- *
53
- * // Erase entire screen
54
- * process.stdout.write(eraseDisplay(EraseDisplayMode.EntireScreen)); // or eraseDisplay(2)
55
- *
56
- * // Erase entire screen and scrollback buffer
57
- * process.stdout.write(eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)); // or eraseDisplay(3)
58
- * ```
59
- * @see {@link EraseDisplayMode}
60
- * @see {@link https://vt100.net/docs/vt510-rm/ED.html} VT510 Erase in Display (ED) documentation.
61
- */
62
- export declare const eraseDisplay: (mode: EraseDisplayMode | 0 | 1 | 2 | 3) => string;
63
- /**
64
- * Defines the modes for erasing parts of the current line using the EL (Erase in Line) sequence.
65
- * The EL sequence is `CSI Ps K`, where `Ps` is one of these mode values.
66
- * The cursor position is NOT affected by EL sequences.
67
- * @see {@link eraseInLine} for the function that generates EL sequences.
68
- * @see {@link https://vt100.net/docs/vt510-rm/EL.html} VT510 Erase in Line (EL) documentation.
69
- * @enum {number}
70
- */
71
- export declare enum EraseLineMode {
72
- /**
73
- * Clears the entire current line.
74
- * This corresponds to `Ps=2` in `CSI Ps K`.
75
- * Sequence: `CSI 2K`.
76
- */
77
- EntireLine = 2,
78
- /**
79
- * Clears from the beginning of the line to the current cursor position (inclusive).
80
- * This corresponds to `Ps=1` in `CSI Ps K`.
81
- * Sequence: `CSI 1K`.
82
- */
83
- ToBeginning = 1,
84
- /**
85
- * Clears from the current cursor position to the end of the line (inclusive).
86
- * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps K`.
87
- * Sequence: `CSI K` or `CSI 0K`.
88
- */
89
- ToEnd = 0
90
- }
91
- /**
92
- * Generates an ANSI escape sequence to erase parts of the current line (EL - Erase in Line).
93
- * The specific sequence is `CSI <mode>K`, where `<mode>` is a parameter from {@link EraseLineMode}.
94
- * The cursor position is NOT changed by this sequence.
95
- *
96
- * - If `mode` is `EraseLineMode.ToEnd` (or `0`), the sequence can be shortened to `CSI K`.
97
- * - The function validates the input `mode`. If an invalid number is provided, it defaults to `EraseLineMode.ToEnd`.
98
- * @param mode The erase mode, specified as a value from `EraseLineMode` or its corresponding number (0, 1, 2).
99
- * @returns The ANSI escape sequence string for erasing in line.
100
- * @example
101
- * ```typescript
102
- * import { eraseInLine, EraseLineMode } from '@visulima/ansi/erase';
103
- *
104
- * // Erase from cursor to end of line
105
- * process.stdout.write(eraseInLine(EraseLineMode.ToEnd)); // or eraseInLine(0)
106
- *
107
- * // Erase entire current line
108
- * process.stdout.write(eraseInLine(EraseLineMode.EntireLine)); // or eraseInLine(2)
109
- * ```
110
- * @see {@link EraseLineMode}
111
- * @see {@link https://vt100.net/docs/vt510-rm/EL.html} VT510 Erase in Line (EL) documentation.
112
- */
113
- export declare const eraseInLine: (mode: EraseLineMode | 0 | 1 | 2) => string;
114
- /**
115
- * Erases the screen from the current cursor position down to the bottom of the screen (inclusive).
116
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.ToEnd)`.
117
- * Sequence: `CSI J` (or `CSI 0J`).
118
- * @returns The ANSI escape sequence `CSI J`.
119
- * @see {@link eraseDisplay}
120
- * @see {@link EraseDisplayMode.ToEnd}
121
- */
122
- export declare const eraseDown: string;
123
- /**
124
- * Erases the entire current line. The cursor position does not change.
125
- * This is a convenience constant for `eraseInLine(EraseLineMode.EntireLine)`.
126
- * Sequence: `CSI 2K`.
127
- * @returns The ANSI escape sequence `CSI 2K`.
128
- * @see {@link eraseInLine}
129
- * @see {@link EraseLineMode.EntireLine}
130
- */
131
- export declare const eraseLine: string;
132
- /**
133
- * Erases from the current cursor position to the end of the current line (inclusive).
134
- * The cursor position does not change.
135
- * This is a convenience constant for `eraseInLine(EraseLineMode.ToEnd)`.
136
- * Sequence: `CSI K` (or `CSI 0K`).
137
- * @returns The ANSI escape sequence `CSI K`.
138
- * @see {@link eraseInLine}
139
- * @see {@link EraseLineMode.ToEnd}
140
- */
141
- export declare const eraseLineEnd: string;
142
- /**
143
- * Erases from the current cursor position to the beginning of the current line (inclusive).
144
- * The cursor position does not change.
145
- * This is a convenience constant for `eraseInLine(EraseLineMode.ToBeginning)`.
146
- * Sequence: `CSI 1K`.
147
- * @returns The ANSI escape sequence `CSI 1K`.
148
- * @see {@link eraseInLine}
149
- * @see {@link EraseLineMode.ToBeginning}
150
- */
151
- export declare const eraseLineStart: string;
152
- /**
153
- * Erases a specified number of lines, starting from the current line and moving upwards,
154
- * then moves the cursor to the beginning of the topmost erased line (which becomes the new current line).
155
- *
156
- * This is a custom helper function, not a single standard ANSI/VT sequence. It combines
157
- * multiple sequences: {@link eraseLine} to clear each line, {@link cursorUp} to move to the line above,
158
- * and finally {@link cursorToColumn1} to position the cursor at the start of the resulting current line.
159
- * @param count The total number of lines to erase. This includes the current line and `count-1` lines above it.
160
- * If `count` is 0 or negative, an empty string is returned (no operation).
161
- * @returns A string of concatenated ANSI escape sequences to perform the operation.
162
- * @example
163
- * ```typescript
164
- * import { eraseLines } from '@visulima/ansi/erase';
165
- *
166
- * // To erase the current line and the 2 lines above it (total 3 lines):
167
- * process.stdout.write(eraseLines(3));
168
- * // Conceptual sequence of operations:
169
- * // 1. Erase current line
170
- * // 2. Cursor up
171
- * // 3. Erase current line (which was the line above the original)
172
- * // 4. Cursor up
173
- * // 5. Erase current line (which was two lines above the original)
174
- * // 6. Cursor to column 1 (on this topmost erased line)
175
- * ```
176
- */
177
- export declare const eraseLines: (count: number) => string;
178
- /**
179
- * Erases the entire screen. The cursor position usually does not change, though this can be terminal-dependent.
180
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.EntireScreen)`.
181
- * Sequence: `CSI 2J`.
182
- * @returns The ANSI escape sequence `CSI 2J`.
183
- * @see {@link eraseDisplay}
184
- * @see {@link EraseDisplayMode.EntireScreen}
185
- */
186
- export declare const eraseScreen: string;
187
- /**
188
- * Erases the screen from the current cursor position up to the top of the screen (inclusive).
189
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.ToBeginning)`.
190
- * Sequence: `CSI 1J`.
191
- * @returns The ANSI escape sequence `CSI 1J`.
192
- * @see {@link eraseDisplay}
193
- * @see {@link EraseDisplayMode.ToBeginning}
194
- */
195
- export declare const eraseUp: string;
196
- /**
197
- * Erases the entire screen and, on supported terminals (like XTerm and derivatives),
198
- * also deletes all lines saved in the scrollback buffer.
199
- * This is a convenience constant for `eraseDisplay(EraseDisplayMode.EntireScreenAndScrollback)`.
200
- * Sequence: `CSI 3J` (an XTerm extension, widely adopted).
201
- * @returns The ANSI escape sequence `CSI 3J`.
202
- * @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
203
- * @see {@link eraseDisplay}
204
- * @see {@link EraseDisplayMode.EntireScreenAndScrollback}
205
- */
206
- export declare const eraseScreenAndScrollback: string;
package/dist/erase.mjs DELETED
@@ -1,49 +0,0 @@
1
- import { C as CSI } from './packem_shared/constants-CE7WkXh_.mjs';
2
- import { u as cursorUp, t as cursorToColumn1 } from './packem_shared/cursor-DhFQcQ9g.mjs';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var EraseDisplayMode = /* @__PURE__ */ ((EraseDisplayMode2) => {
7
- EraseDisplayMode2[EraseDisplayMode2["EntireScreen"] = 2] = "EntireScreen";
8
- EraseDisplayMode2[EraseDisplayMode2["EntireScreenAndScrollback"] = 3] = "EntireScreenAndScrollback";
9
- EraseDisplayMode2[EraseDisplayMode2["ToBeginning"] = 1] = "ToBeginning";
10
- EraseDisplayMode2[EraseDisplayMode2["ToEnd"] = 0] = "ToEnd";
11
- return EraseDisplayMode2;
12
- })(EraseDisplayMode || {});
13
- const eraseDisplay = /* @__PURE__ */ __name((mode) => {
14
- const validMode = mode >= 0 && mode <= 3 ? mode : 0 /* ToEnd */;
15
- return `${CSI + (validMode === 0 /* ToEnd */ ? "" : String(validMode))}J`;
16
- }, "eraseDisplay");
17
- var EraseLineMode = /* @__PURE__ */ ((EraseLineMode2) => {
18
- EraseLineMode2[EraseLineMode2["EntireLine"] = 2] = "EntireLine";
19
- EraseLineMode2[EraseLineMode2["ToBeginning"] = 1] = "ToBeginning";
20
- EraseLineMode2[EraseLineMode2["ToEnd"] = 0] = "ToEnd";
21
- return EraseLineMode2;
22
- })(EraseLineMode || {});
23
- const eraseInLine = /* @__PURE__ */ __name((mode) => {
24
- const validMode = mode >= 0 && mode <= 2 ? mode : 0 /* ToEnd */;
25
- return `${CSI + (validMode === 0 /* ToEnd */ ? "" : String(validMode))}K`;
26
- }, "eraseInLine");
27
- const eraseDown = eraseDisplay(0 /* ToEnd */);
28
- const eraseLine = eraseInLine(2 /* EntireLine */);
29
- const eraseLineEnd = eraseInLine(0 /* ToEnd */);
30
- const eraseLineStart = eraseInLine(1 /* ToBeginning */);
31
- const eraseLines = /* @__PURE__ */ __name((count) => {
32
- if (count <= 0) {
33
- return "";
34
- }
35
- let clear = "";
36
- for (let index = 0; index < count; index += 1) {
37
- clear += eraseLine;
38
- if (index < count - 1) {
39
- clear += cursorUp();
40
- }
41
- }
42
- clear += cursorToColumn1;
43
- return clear;
44
- }, "eraseLines");
45
- const eraseScreen = eraseDisplay(2 /* EntireScreen */);
46
- const eraseUp = eraseDisplay(1 /* ToBeginning */);
47
- const eraseScreenAndScrollback = eraseDisplay(3 /* EntireScreenAndScrollback */);
48
-
49
- export { EraseDisplayMode, EraseLineMode, eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLineStart, eraseLines, eraseScreen, eraseScreenAndScrollback, eraseUp };
@@ -1,14 +0,0 @@
1
- /**
2
- * Checks if the current environment is a browser-like environment.
3
- * It specifically checks for the presence of `globalThis.window.document`.
4
- */
5
- /**
6
- * Indicates whether the code is running inside Apple's Terminal.app.
7
- * This is true if not in a browser and the `TERM_PROGRAM` environment variable is "Apple_Terminal".
8
- */
9
- export declare const isTerminalApp: boolean;
10
- /**
11
- * Indicates whether the current platform is Windows.
12
- * This is true if not in a browser and `process.platform` is "win32".
13
- */
14
- export declare const isWindows: boolean;
@@ -1,14 +0,0 @@
1
- /**
2
- * Checks if the current environment is a browser-like environment.
3
- * It specifically checks for the presence of `globalThis.window.document`.
4
- */
5
- /**
6
- * Indicates whether the code is running inside Apple's Terminal.app.
7
- * This is true if not in a browser and the `TERM_PROGRAM` environment variable is "Apple_Terminal".
8
- */
9
- export declare const isTerminalApp: boolean;
10
- /**
11
- * Indicates whether the current platform is Windows.
12
- * This is true if not in a browser and `process.platform` is "win32".
13
- */
14
- export declare const isWindows: boolean;
package/dist/helpers.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * Checks if the current environment is a browser-like environment.
3
- * It specifically checks for the presence of `globalThis.window.document`.
4
- */
5
- /**
6
- * Indicates whether the code is running inside Apple's Terminal.app.
7
- * This is true if not in a browser and the `TERM_PROGRAM` environment variable is "Apple_Terminal".
8
- */
9
- export declare const isTerminalApp: boolean;
10
- /**
11
- * Indicates whether the current platform is Windows.
12
- * This is true if not in a browser and `process.platform` is "win32".
13
- */
14
- export declare const isWindows: boolean;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- const constants = require('./packem_shared/constants-BK26O-46.cjs');
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- const hyperlink = /* @__PURE__ */ __name((text, url) => [constants.OSC, "8", constants.SEP, constants.SEP, url, constants.BEL, text, constants.OSC, "8", constants.SEP, constants.SEP, constants.BEL].join(""), "hyperlink");
8
-
9
- module.exports = hyperlink;
@@ -1,29 +0,0 @@
1
- /**
2
- * Creates a clickable hyperlink in the terminal.
3
- *
4
- * This function constructs an ANSI escape sequence that, when printed to a compatible terminal,
5
- * renders as a clickable link. The link's visible text and its target URL are specified
6
- * by the `text` and `url` parameters, respectively.
7
- *
8
- * For information on terminal support for hyperlinks, see this
9
- * [Gist by Egmont Kob](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
10
- * To programmatically check for hyperlink support in the current environment,
11
- * consider using a library like [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks).
12
- * @param text The visible text of the link.
13
- * @param url The URL the link should point to.
14
- * @returns A string representing the ANSI escape sequence for the hyperlink.
15
- * @example
16
- * ```typescript
17
- * import { hyperlink } from "@visulima/ansi/hyperlink"; // Adjust import path as needed
18
- *
19
- * const aLink = hyperlink("Visulima", "https://www.visulima.com");
20
- * console.log(`Visit ${aLink} for more information.`);
21
- * // In a supported terminal, this will output:
22
- * // Visit Visulima for more information. (where "Visulima" is a clickable link)
23
- * ```
24
- * @see {@link https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda} for supported terminals.
25
- */
26
- declare const hyperlink: (text: string, url: string) => string;
27
-
28
-
29
- export = hyperlink;
@@ -1,27 +0,0 @@
1
- /**
2
- * Creates a clickable hyperlink in the terminal.
3
- *
4
- * This function constructs an ANSI escape sequence that, when printed to a compatible terminal,
5
- * renders as a clickable link. The link's visible text and its target URL are specified
6
- * by the `text` and `url` parameters, respectively.
7
- *
8
- * For information on terminal support for hyperlinks, see this
9
- * [Gist by Egmont Kob](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
10
- * To programmatically check for hyperlink support in the current environment,
11
- * consider using a library like [`supports-hyperlinks`](https://github.com/jamestalmage/supports-hyperlinks).
12
- * @param text The visible text of the link.
13
- * @param url The URL the link should point to.
14
- * @returns A string representing the ANSI escape sequence for the hyperlink.
15
- * @example
16
- * ```typescript
17
- * import { hyperlink } from "@visulima/ansi/hyperlink"; // Adjust import path as needed
18
- *
19
- * const aLink = hyperlink("Visulima", "https://www.visulima.com");
20
- * console.log(`Visit ${aLink} for more information.`);
21
- * // In a supported terminal, this will output:
22
- * // Visit Visulima for more information. (where "Visulima" is a clickable link)
23
- * ```
24
- * @see {@link https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda} for supported terminals.
25
- */
26
- declare const hyperlink: (text: string, url: string) => string;
27
- export default hyperlink;
@@ -1,7 +0,0 @@
1
- import { O as OSC, S as SEP, B as BEL } 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 hyperlink = /* @__PURE__ */ __name((text, url) => [OSC, "8", SEP, SEP, url, BEL, text, OSC, "8", SEP, SEP, BEL].join(""), "hyperlink");
6
-
7
- export { hyperlink as default };
package/dist/image.cjs DELETED
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const node_buffer = require('node:buffer');
6
- const constants = require('./packem_shared/constants-BK26O-46.cjs');
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- const image = /* @__PURE__ */ __name((data, options = {}) => {
11
- if (!data) {
12
- return "";
13
- }
14
- let returnValue = `${constants.OSC}1337;File=inline=1`;
15
- if (options.width !== void 0) {
16
- returnValue += `;width=${options.width}`;
17
- }
18
- if (options.height !== void 0) {
19
- returnValue += `;height=${options.height}`;
20
- }
21
- if (options.preserveAspectRatio === false) {
22
- returnValue += ";preserveAspectRatio=0";
23
- }
24
- const base64Data = node_buffer.Buffer.from(data).toString("base64");
25
- return `${returnValue}:${base64Data}${constants.BEL}`;
26
- }, "image");
27
-
28
- exports.image = image;