@visulima/ansi 4.0.0-alpha.12 → 4.0.0-alpha.14

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 (61) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE.md +0 -3
  3. package/README.md +3 -0
  4. package/dist/alternative-screen.d.ts +71 -70
  5. package/dist/alternative-screen.js +1 -8
  6. package/dist/clear.d.ts +74 -73
  7. package/dist/clear.js +1 -10
  8. package/dist/cursor.d.ts +421 -406
  9. package/dist/cursor.js +1 -3
  10. package/dist/erase.d.ts +193 -192
  11. package/dist/erase.js +1 -47
  12. package/dist/hyperlink.d.ts +25 -25
  13. package/dist/hyperlink.js +1 -5
  14. package/dist/image.d.ts +71 -70
  15. package/dist/image.js +1 -40
  16. package/dist/index.d.ts +65 -35
  17. package/dist/index.js +1 -26
  18. package/dist/iterm2.d.ts +285 -58
  19. package/dist/iterm2.js +1 -12
  20. package/dist/mode.d.ts +585 -584
  21. package/dist/mode.js +1 -245
  22. package/dist/mouse.d.ts +227 -226
  23. package/dist/mouse.js +1 -106
  24. package/dist/packem_shared/IT2_AUTO-OiB8EaxU.js +1 -0
  25. package/dist/packem_shared/ITerm2File-XoC8RMzs.js +1 -0
  26. package/dist/packem_shared/constants-D12jy2Zh.js +1 -0
  27. package/dist/packem_shared/cursor-BAcJR4p_.js +1 -0
  28. package/dist/packem_shared/resetProgressBar-H_gzPKNE.js +1 -0
  29. package/dist/packem_shared/restoreCursor-CHy0jZuu.js +2 -0
  30. package/dist/passthrough.d.ts +74 -73
  31. package/dist/passthrough.js +1 -29
  32. package/dist/reset.d.ts +25 -24
  33. package/dist/reset.js +1 -4
  34. package/dist/screen.d.ts +226 -225
  35. package/dist/screen.js +1 -27
  36. package/dist/scroll.d.ts +64 -63
  37. package/dist/scroll.js +1 -18
  38. package/dist/status.d.ts +521 -520
  39. package/dist/status.js +1 -95
  40. package/dist/strip.d.ts +1 -1
  41. package/dist/strip.js +1 -13
  42. package/dist/termcap.d.ts +36 -35
  43. package/dist/termcap.js +1 -25
  44. package/dist/title.d.ts +176 -175
  45. package/dist/title.js +1 -19
  46. package/dist/window-ops.d.ts +399 -398
  47. package/dist/window-ops.js +1 -61
  48. package/dist/xterm.d.ts +85 -84
  49. package/dist/xterm.js +1 -33
  50. package/package.json +2 -5
  51. package/dist/constants.d.ts +0 -20
  52. package/dist/helpers.d.ts +0 -14
  53. package/dist/iterm2/iterm2-properties.d.ts +0 -135
  54. package/dist/iterm2/iterm2-sequences.d.ts +0 -96
  55. package/dist/packem_shared/IT2_AUTO-DyYWsxno.js +0 -6
  56. package/dist/packem_shared/ITerm2File-CUZDBk99.js +0 -137
  57. package/dist/packem_shared/constants-CE7WkXh_.js +0 -9
  58. package/dist/packem_shared/cursor-ChpV7cgs.js +0 -72
  59. package/dist/packem_shared/resetProgressBar-D9r2s7eV.js +0 -18
  60. package/dist/packem_shared/restoreCursor-GfYEeJqN.js +0 -323
  61. package/dist/progress.d.ts +0 -41
package/dist/cursor.js CHANGED
@@ -1,3 +1 @@
1
- import './packem_shared/constants-CE7WkXh_.js';
2
- export { C as CURSOR_BACKWARD_1, a as CURSOR_DOWN_1, b as CURSOR_FORWARD_1, c as CURSOR_UP_1, B as CursorStyle, R as REQUEST_CURSOR_POSITION, d as REQUEST_EXTENDED_CURSOR_POSITION, e as RESTORE_CURSOR_DEC, S as SAVE_CURSOR_DEC, f as cursorBackward, g as cursorBackwardTab, h as cursorDown, i as cursorForward, j as cursorHide, k as cursorHorizontalAbsolute, l as cursorHorizontalForwardTab, m as cursorLeft, n as cursorMove, o as cursorNextLine, p as cursorPosition, q as cursorPreviousLine, r as cursorRestore, s as cursorSave, t as cursorShow, u as cursorTo, v as cursorToColumn1, w as cursorUp, x as cursorVerticalAbsolute, y as eraseCharacter, z as setCursorStyle } from './packem_shared/cursor-ChpV7cgs.js';
3
- export { default as restoreCursor } from './packem_shared/restoreCursor-GfYEeJqN.js';
1
+ import"./packem_shared/constants-D12jy2Zh.js";import{C as o,a as u,b as e,c as R,B as c,R as t,d as S,e as C,S as _,f as O,g as E,h as U,i,j as l,k as T,l as n,m as D,n as d,o as w,p as A,q as b,r as f,s as m,t as p,u as N,v as P,w as v,x,y as B,z as I}from"./packem_shared/cursor-BAcJR4p_.js";import{default as k}from"./packem_shared/restoreCursor-CHy0jZuu.js";export{o as CURSOR_BACKWARD_1,u as CURSOR_DOWN_1,e as CURSOR_FORWARD_1,R as CURSOR_UP_1,c as CursorStyle,t as REQUEST_CURSOR_POSITION,S as REQUEST_EXTENDED_CURSOR_POSITION,C as RESTORE_CURSOR_DEC,_ as SAVE_CURSOR_DEC,O as cursorBackward,E as cursorBackwardTab,U as cursorDown,i as cursorForward,l as cursorHide,T as cursorHorizontalAbsolute,n as cursorHorizontalForwardTab,D as cursorLeft,d as cursorMove,w as cursorNextLine,A as cursorPosition,b as cursorPreviousLine,f as cursorRestore,m as cursorSave,p as cursorShow,N as cursorTo,P as cursorToColumn1,v as cursorUp,x as cursorVerticalAbsolute,B as eraseCharacter,k as restoreCursor,I as setCursorStyle};
package/dist/erase.d.ts CHANGED
@@ -1,206 +1,207 @@
1
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 from the current cursor position to the end of the screen (inclusive).
11
- * If the cursor is at the top-left, this clears the entire screen.
12
- * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps J`.
13
- * Sequence: `CSI J` or `CSI 0J`.
14
- */
15
- ToEnd = 0,
16
- /**
17
- * Clears from the beginning of the screen to the current cursor position (inclusive).
18
- * This corresponds to `Ps=1` in `CSI Ps J`.
19
- * Sequence: `CSI 1J`.
20
- */
21
- ToBeginning = 1,
22
- /**
23
- * Clears the entire screen. The cursor position usually does not change, but this can be
24
- * terminal-dependent. Some terminals might move the cursor to the home position (top-left).
25
- * This corresponds to `Ps=2` in `CSI Ps J`.
26
- * Sequence: `CSI 2J`.
27
- */
28
- EntireScreen = 2,
29
- /**
30
- * Clears the entire screen and, on supported terminals (like XTerm and derivatives),
31
- * also deletes all lines saved in the scrollback buffer.
32
- * This corresponds to `Ps=3` in `CSI Ps J` (an XTerm extension, widely adopted).
33
- * Sequence: `CSI 3J`.
34
- * @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
35
- */
36
- EntireScreenAndScrollback = 3
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
+ declare enum EraseDisplayMode {
9
+ /**
10
+ * Clears from the current cursor position to the end of the screen (inclusive).
11
+ * If the cursor is at the top-left, this clears the entire screen.
12
+ * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps J`.
13
+ * Sequence: `CSI J` or `CSI 0J`.
14
+ */
15
+ ToEnd = 0,
16
+ /**
17
+ * Clears from the beginning of the screen to the current cursor position (inclusive).
18
+ * This corresponds to `Ps=1` in `CSI Ps J`.
19
+ * Sequence: `CSI 1J`.
20
+ */
21
+ ToBeginning = 1,
22
+ /**
23
+ * Clears the entire screen. The cursor position usually does not change, but this can be
24
+ * terminal-dependent. Some terminals might move the cursor to the home position (top-left).
25
+ * This corresponds to `Ps=2` in `CSI Ps J`.
26
+ * Sequence: `CSI 2J`.
27
+ */
28
+ EntireScreen = 2,
29
+ /**
30
+ * Clears the entire screen and, on supported terminals (like XTerm and derivatives),
31
+ * also deletes all lines saved in the scrollback buffer.
32
+ * This corresponds to `Ps=3` in `CSI Ps J` (an XTerm extension, widely adopted).
33
+ * Sequence: `CSI 3J`.
34
+ * @remarks This mode is particularly useful for a more complete "reset" of the terminal view.
35
+ */
36
+ EntireScreenAndScrollback = 3,
37
37
  }
38
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;
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
+ declare const eraseDisplay: (mode: EraseDisplayMode | 0 | 1 | 2 | 3) => string;
63
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 from the current cursor position to the end of the line (inclusive).
74
- * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps K`.
75
- * Sequence: `CSI K` or `CSI 0K`.
76
- */
77
- ToEnd = 0,
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 the entire current line.
86
- * This corresponds to `Ps=2` in `CSI Ps K`.
87
- * Sequence: `CSI 2K`.
88
- */
89
- EntireLine = 2
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
+ declare enum EraseLineMode {
72
+ /**
73
+ * Clears from the current cursor position to the end of the line (inclusive).
74
+ * This corresponds to `Ps=0` (or `Ps` omitted) in `CSI Ps K`.
75
+ * Sequence: `CSI K` or `CSI 0K`.
76
+ */
77
+ ToEnd = 0,
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 the entire current line.
86
+ * This corresponds to `Ps=2` in `CSI Ps K`.
87
+ * Sequence: `CSI 2K`.
88
+ */
89
+ EntireLine = 2,
90
90
  }
91
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;
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
+ declare const eraseInLine: (mode: EraseLineMode | 0 | 1 | 2) => string;
114
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;
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
+ declare const eraseDown: string;
123
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;
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
+ declare const eraseLine: string;
132
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;
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
+ declare const eraseLineEnd: string;
142
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;
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
+ declare const eraseLineStart: string;
152
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;
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
+ declare const eraseLines: (count: number) => string;
178
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;
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
+ declare const eraseScreen: string;
187
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;
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
+ declare const eraseUp: string;
196
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;
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
+ declare const eraseScreenAndScrollback: string;
207
+ export { EraseDisplayMode, EraseLineMode, eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLineStart, eraseLines, eraseScreen, eraseScreenAndScrollback, eraseUp };
package/dist/erase.js CHANGED
@@ -1,47 +1 @@
1
- import { C as CSI } from './packem_shared/constants-CE7WkXh_.js';
2
- import { w as cursorUp, v as cursorToColumn1 } from './packem_shared/cursor-ChpV7cgs.js';
3
-
4
- var EraseDisplayMode = /* @__PURE__ */ ((EraseDisplayMode2) => {
5
- EraseDisplayMode2[EraseDisplayMode2["ToEnd"] = 0] = "ToEnd";
6
- EraseDisplayMode2[EraseDisplayMode2["ToBeginning"] = 1] = "ToBeginning";
7
- EraseDisplayMode2[EraseDisplayMode2["EntireScreen"] = 2] = "EntireScreen";
8
- EraseDisplayMode2[EraseDisplayMode2["EntireScreenAndScrollback"] = 3] = "EntireScreenAndScrollback";
9
- return EraseDisplayMode2;
10
- })(EraseDisplayMode || {});
11
- const eraseDisplay = (mode) => {
12
- const validMode = mode >= 0 && mode <= 3 ? mode : 0 /* ToEnd */;
13
- return `${CSI}${validMode === 0 /* ToEnd */ ? "" : String(validMode)}J`;
14
- };
15
- var EraseLineMode = /* @__PURE__ */ ((EraseLineMode2) => {
16
- EraseLineMode2[EraseLineMode2["ToEnd"] = 0] = "ToEnd";
17
- EraseLineMode2[EraseLineMode2["ToBeginning"] = 1] = "ToBeginning";
18
- EraseLineMode2[EraseLineMode2["EntireLine"] = 2] = "EntireLine";
19
- return EraseLineMode2;
20
- })(EraseLineMode || {});
21
- const eraseInLine = (mode) => {
22
- const validMode = mode >= 0 && mode <= 2 ? mode : 0 /* ToEnd */;
23
- return `${CSI}${validMode === 0 /* ToEnd */ ? "" : String(validMode)}K`;
24
- };
25
- const eraseDown = eraseDisplay(0 /* ToEnd */);
26
- const eraseLine = eraseInLine(2 /* EntireLine */);
27
- const eraseLineEnd = eraseInLine(0 /* ToEnd */);
28
- const eraseLineStart = eraseInLine(1 /* ToBeginning */);
29
- const eraseLines = (count) => {
30
- if (count <= 0) {
31
- return "";
32
- }
33
- let clear = "";
34
- for (let index = 0; index < count; index += 1) {
35
- clear += eraseLine;
36
- if (index < count - 1) {
37
- clear += cursorUp();
38
- }
39
- }
40
- clear += cursorToColumn1;
41
- return clear;
42
- };
43
- const eraseScreen = eraseDisplay(2 /* EntireScreen */);
44
- const eraseUp = eraseDisplay(1 /* ToBeginning */);
45
- const eraseScreenAndScrollback = eraseDisplay(3 /* EntireScreenAndScrollback */);
46
-
47
- export { EraseDisplayMode, EraseLineMode, eraseDisplay, eraseDown, eraseInLine, eraseLine, eraseLineEnd, eraseLineStart, eraseLines, eraseScreen, eraseScreenAndScrollback, eraseUp };
1
+ var t=Object.defineProperty;var s=(e,n)=>t(e,"name",{value:n,configurable:!0});import{C as c}from"./packem_shared/constants-D12jy2Zh.js";import{w as l,v as E}from"./packem_shared/cursor-BAcJR4p_.js";var S=Object.defineProperty,a=s((e,n)=>S(e,"name",{value:n,configurable:!0}),"o"),d=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(d||{});const r=a(e=>{const n=e>=0&&e<=3?e:0;return`${c}${n===0?"":String(n)}J`},"eraseDisplay");var g=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(g||{});const o=a(e=>{const n=e>=0&&e<=2?e:0;return`${c}${n===0?"":String(n)}K`},"eraseInLine"),f=r(0),u=o(2),m=o(0),v=o(1),b=a(e=>{if(e<=0)return"";let n="";for(let i=0;i<e;i+=1)n+=u,i<e-1&&(n+=l());return n+=E,n},"eraseLines"),y=r(2),B=r(1),D=r(3);export{d as EraseDisplayMode,g as EraseLineMode,r as eraseDisplay,f as eraseDown,o as eraseInLine,u as eraseLine,m as eraseLineEnd,v as eraseLineStart,b as eraseLines,y as eraseScreen,D as eraseScreenAndScrollback,B as eraseUp};
@@ -1,27 +1,27 @@
1
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
- */
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
26
  declare const hyperlink: (text: string, url: string) => string;
27
- export default hyperlink;
27
+ export { hyperlink as default };
package/dist/hyperlink.js CHANGED
@@ -1,5 +1 @@
1
- import { O as OSC, S as SEP, B as BEL } from './packem_shared/constants-CE7WkXh_.js';
2
-
3
- const hyperlink = (text, url) => [OSC, "8", SEP, SEP, url, BEL, text, OSC, "8", SEP, SEP, BEL].join("");
4
-
5
- export { hyperlink as default };
1
+ var i=Object.defineProperty;var n=(e,a)=>i(e,"name",{value:a,configurable:!0});import{O as o,S as r,B as t}from"./packem_shared/constants-D12jy2Zh.js";var s=Object.defineProperty,f=n((e,a)=>s(e,"name",{value:a,configurable:!0}),"n");const u=f((e,a)=>[o,"8",r,r,a,t,e,o,"8",r,r,t].join(""),"hyperlink");export{u as default};