@visulima/ansi 4.0.0-alpha.9 → 4.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 (85) hide show
  1. package/CHANGELOG.md +290 -0
  2. package/LICENSE.md +0 -20
  3. package/README.md +41 -10
  4. package/dist/alternative-screen.d.ts +71 -70
  5. package/dist/alternative-screen.js +1 -8
  6. package/dist/background.d.ts +72 -0
  7. package/dist/background.js +1 -0
  8. package/dist/charset.d.ts +52 -0
  9. package/dist/charset.js +1 -0
  10. package/dist/clear.d.ts +74 -73
  11. package/dist/clear.js +1 -10
  12. package/dist/clipboard.d.ts +76 -0
  13. package/dist/clipboard.js +1 -0
  14. package/dist/constants.d.ts +18 -10
  15. package/dist/constants.js +1 -0
  16. package/dist/cursor.d.ts +421 -406
  17. package/dist/cursor.js +1 -3
  18. package/dist/cwd.d.ts +26 -0
  19. package/dist/cwd.js +1 -0
  20. package/dist/erase.d.ts +193 -192
  21. package/dist/erase.js +1 -47
  22. package/dist/finalterm.d.ts +47 -0
  23. package/dist/finalterm.js +1 -0
  24. package/dist/focus.d.ts +20 -0
  25. package/dist/focus.js +1 -0
  26. package/dist/hyperlink.d.ts +25 -25
  27. package/dist/hyperlink.js +1 -5
  28. package/dist/image.d.ts +70 -70
  29. package/dist/image.js +1 -40
  30. package/dist/index.d.ts +38 -35
  31. package/dist/index.js +1 -26
  32. package/dist/iterm2.d.ts +285 -58
  33. package/dist/iterm2.js +1 -12
  34. package/dist/keypad.d.ts +27 -0
  35. package/dist/keypad.js +1 -0
  36. package/dist/kitty-graphics.d.ts +17 -0
  37. package/dist/kitty-graphics.js +1 -0
  38. package/dist/mode.d.ts +585 -584
  39. package/dist/mode.js +1 -245
  40. package/dist/mouse.d.ts +227 -226
  41. package/dist/mouse.js +1 -106
  42. package/dist/notification.d.ts +30 -0
  43. package/dist/notification.js +1 -0
  44. package/dist/packem_shared/IT2_AUTO-K3GubKy7.js +1 -0
  45. package/dist/packem_shared/ITerm2File-BkLc5ipB.js +1 -0
  46. package/dist/packem_shared/cursor-BXG1O_IE.js +1 -0
  47. package/dist/packem_shared/restoreCursor-CyaXIMQf.js +2 -0
  48. package/dist/passthrough.d.ts +74 -73
  49. package/dist/passthrough.js +1 -29
  50. package/dist/paste.d.ts +23 -0
  51. package/dist/paste.js +1 -0
  52. package/dist/progress.d.ts +37 -36
  53. package/dist/progress.js +1 -0
  54. package/dist/reset.d.ts +25 -24
  55. package/dist/reset.js +1 -4
  56. package/dist/screen.d.ts +226 -225
  57. package/dist/screen.js +1 -27
  58. package/dist/scroll.d.ts +64 -63
  59. package/dist/scroll.js +1 -18
  60. package/dist/sixel.d.ts +19 -0
  61. package/dist/sixel.js +1 -0
  62. package/dist/status.d.ts +521 -520
  63. package/dist/status.js +1 -95
  64. package/dist/strip.d.ts +26 -1
  65. package/dist/strip.js +1 -13
  66. package/dist/termcap.d.ts +36 -35
  67. package/dist/termcap.js +1 -25
  68. package/dist/title.d.ts +176 -175
  69. package/dist/title.js +1 -19
  70. package/dist/urxvt.d.ts +15 -0
  71. package/dist/urxvt.js +1 -0
  72. package/dist/window-ops.d.ts +399 -398
  73. package/dist/window-ops.js +1 -61
  74. package/dist/xterm.d.ts +167 -84
  75. package/dist/xterm.js +1 -33
  76. package/package.json +60 -9
  77. package/dist/helpers.d.ts +0 -14
  78. package/dist/iterm2/iterm2-properties.d.ts +0 -135
  79. package/dist/iterm2/iterm2-sequences.d.ts +0 -96
  80. package/dist/packem_shared/IT2_AUTO-DyYWsxno.js +0 -6
  81. package/dist/packem_shared/ITerm2File-CUZDBk99.js +0 -137
  82. package/dist/packem_shared/constants-CE7WkXh_.js +0 -9
  83. package/dist/packem_shared/cursor-ChpV7cgs.js +0 -72
  84. package/dist/packem_shared/resetProgressBar-D9r2s7eV.js +0 -18
  85. package/dist/packem_shared/restoreCursor-GfYEeJqN.js +0 -323
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"./constants.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-BXG1O_IE.js";import{default as k}from"./packem_shared/restoreCursor-CyaXIMQf.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/cwd.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Returns a sequence that reports the current working directory to the terminal.
3
+ *
4
+ * Terminals such as iTerm2, WezTerm and others use this `OSC 7` sequence to keep
5
+ * track of the shell's working directory — for example to open new tabs/splits in
6
+ * the same directory. The payload is a `file://` URL built from the optional
7
+ * `host` and the joined `paths`.
8
+ *
9
+ * Sequence: `OSC 7 ; file://[host]/[path] BEL`
10
+ * @param host The host portion of the `file://` URL (use an empty string for the local machine).
11
+ * @param paths One or more path segments that are joined into the URL path.
12
+ * @returns The `OSC 7` escape sequence.
13
+ * @example
14
+ * ```typescript
15
+ * import { notifyWorkingDirectory } from "@visulima/ansi/cwd";
16
+ *
17
+ * process.stdout.write(notifyWorkingDirectory("", process.cwd()));
18
+ * ```
19
+ * @see {@link https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/20}
20
+ */
21
+ declare const notifyWorkingDirectory: (host: string, ...paths: string[]) => string;
22
+ /**
23
+ * Alias for {@link notifyWorkingDirectory}.
24
+ */
25
+ declare const setWorkingDirectory: (host: string, ...paths: string[]) => string;
26
+ export { notifyWorkingDirectory, setWorkingDirectory };
package/dist/cwd.js ADDED
@@ -0,0 +1 @@
1
+ import{stripOscTerminators as s,OSC as c,BEL as l}from"./constants.js";const $=(t,...o)=>{const r=o.filter(n=>n.length>0).join("/").replaceAll(/\/{2,}/g,"/"),e=r.startsWith("/")?r:`/${r}`,i=s(t);return`${c}7;file://${i}${encodeURI(e)}${l}`},g=$;export{$ as notifyWorkingDirectory,g as setWorkingDirectory};
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
+ import{CSI as s}from"./constants.js";import{v as a,w as c}from"./packem_shared/cursor-BXG1O_IE.js";var t=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireScreen=2]="EntireScreen",e[e.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",e))(t||{});const r=e=>{const n=e>=0&&e<=3?e:0;return`${s}${n===0?"":String(n)}J`};var E=(e=>(e[e.ToEnd=0]="ToEnd",e[e.ToBeginning=1]="ToBeginning",e[e.EntireLine=2]="EntireLine",e))(E||{});const o=e=>{const n=e>=0&&e<=2?e:0;return`${s}${n===0?"":String(n)}K`},g=r(0),S=o(2),T=o(0),L=o(1),p=e=>{if(e<=0)return"";let n="";for(let i=0;i<e;i+=1)n+=S,i<e-1&&(n+=c());return n+=a,n},u=r(2),m=r(1),f=r(3);export{t as EraseDisplayMode,E as EraseLineMode,r as eraseDisplay,g as eraseDown,o as eraseInLine,S as eraseLine,T as eraseLineEnd,L as eraseLineStart,p as eraseLines,u as eraseScreen,f as eraseScreenAndScrollback,m as eraseUp};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Returns a FinalTerm shell-integration sequence (`OSC 133`).
3
+ *
4
+ * The FinalTerm protocol lets shells mark the structure of their output — where
5
+ * the prompt starts, where the user's command begins, where its output starts
6
+ * and when it finished — so terminals can offer features like jump-to-prompt,
7
+ * command status and selection of command output.
8
+ *
9
+ * Sequence: `OSC 133 ; Pt BEL`
10
+ * @param pm The semicolon-delimited parameters of the sequence.
11
+ * @returns The `OSC 133` escape sequence.
12
+ * @see {@link https://iterm2.com/documentation-shell-integration.html}
13
+ */
14
+ declare const finalTerm: (...pm: string[]) => string;
15
+ /**
16
+ * Marks the start of the shell prompt. Sent just before the prompt is printed.
17
+ *
18
+ * Sequence: `OSC 133 ; A ; Pt BEL`
19
+ * @param pm Additional parameters appended after the `A` marker.
20
+ * @returns The `OSC 133 ; A` escape sequence.
21
+ */
22
+ declare const finalTermPrompt: (...pm: string[]) => string;
23
+ /**
24
+ * Marks the end of the prompt and the start of the user's command input.
25
+ *
26
+ * Sequence: `OSC 133 ; B ; Pt BEL`
27
+ * @param pm Additional parameters appended after the `B` marker.
28
+ * @returns The `OSC 133 ; B` escape sequence.
29
+ */
30
+ declare const finalTermCmdStart: (...pm: string[]) => string;
31
+ /**
32
+ * Marks the start of the command output (the command is about to be executed).
33
+ *
34
+ * Sequence: `OSC 133 ; C ; Pt BEL`
35
+ * @param pm Additional parameters appended after the `C` marker.
36
+ * @returns The `OSC 133 ; C` escape sequence.
37
+ */
38
+ declare const finalTermCmdExecuted: (...pm: string[]) => string;
39
+ /**
40
+ * Marks the end of the command output. May carry the command's exit code.
41
+ *
42
+ * Sequence: `OSC 133 ; D ; Pt BEL`
43
+ * @param pm Additional parameters appended after the `D` marker (e.g. the exit code).
44
+ * @returns The `OSC 133 ; D` escape sequence.
45
+ */
46
+ declare const finalTermCmdFinished: (...pm: string[]) => string;
47
+ export { finalTerm, finalTermCmdExecuted, finalTermCmdFinished, finalTermCmdStart, finalTermPrompt };
@@ -0,0 +1 @@
1
+ import{OSC as e,BEL as n,stripOscTerminators as t}from"./constants.js";const r=(...m)=>`${e}133;${m.map(i=>t(i)).join(";")}${n}`,o=(...m)=>r("A",...m),f=(...m)=>r("B",...m),T=(...m)=>r("C",...m),d=(...m)=>r("D",...m);export{r as finalTerm,T as finalTermCmdExecuted,d as finalTermCmdFinished,f as finalTermCmdStart,o as finalTermPrompt};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Event a terminal emits when the window gains focus, while focus event
3
+ * reporting is enabled (DEC private mode 1004).
4
+ *
5
+ * Sequence: `CSI I`
6
+ * @see {@link https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Focus-Tracking}
7
+ */
8
+ declare const FOCUS: string;
9
+ /**
10
+ * Event a terminal emits when the window loses focus, while focus event
11
+ * reporting is enabled (DEC private mode 1004).
12
+ *
13
+ * Sequence: `CSI O`
14
+ */
15
+ declare const BLUR: string;
16
+ /** Alias for {@link FOCUS}. */
17
+ declare const focusInEvent: string;
18
+ /** Alias for {@link BLUR}. */
19
+ declare const focusOutEvent: string;
20
+ export { BLUR, FOCUS, focusInEvent, focusOutEvent };
package/dist/focus.js ADDED
@@ -0,0 +1 @@
1
+ import{CSI as o}from"./constants.js";const t=`${o}I`,n=`${o}O`,e=t,f=n;export{n as BLUR,t as FOCUS,e as focusInEvent,f as focusOutEvent};
@@ -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
+ import{stripOscTerminators as r,OSC as t,SEP as o,BEL as s}from"./constants.js";const m=(n,a)=>{const c=r(a),e=r(n);return[t,"8",o,o,c,s,e,t,"8",o,o,s].join("")};export{m as default};