@visulima/ansi 1.0.17 → 1.1.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 (134) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE.md +76 -74
  3. package/README.md +336 -2
  4. package/dist/alternative-screen.cjs +11 -5
  5. package/dist/alternative-screen.d.cts +74 -4
  6. package/dist/alternative-screen.d.mts +74 -4
  7. package/dist/alternative-screen.d.ts +74 -4
  8. package/dist/alternative-screen.mjs +8 -4
  9. package/dist/clear.cjs +10 -18
  10. package/dist/clear.d.cts +77 -7
  11. package/dist/clear.d.mts +77 -7
  12. package/dist/clear.d.ts +77 -7
  13. package/dist/clear.mjs +8 -15
  14. package/dist/constants.d.cts +20 -0
  15. package/dist/constants.d.mts +20 -0
  16. package/dist/constants.d.ts +20 -0
  17. package/dist/cursor.cjs +20 -3
  18. package/dist/cursor.d.cts +436 -30
  19. package/dist/cursor.d.mts +436 -30
  20. package/dist/cursor.d.ts +436 -30
  21. package/dist/cursor.mjs +3 -3
  22. package/dist/erase.cjs +44 -13
  23. package/dist/erase.d.cts +206 -9
  24. package/dist/erase.d.mts +206 -9
  25. package/dist/erase.d.ts +206 -9
  26. package/dist/erase.mjs +40 -14
  27. package/dist/helpers.d.cts +14 -0
  28. package/dist/helpers.d.mts +14 -0
  29. package/dist/helpers.d.ts +14 -0
  30. package/dist/hyperlink.cjs +9 -0
  31. package/dist/hyperlink.d.cts +29 -0
  32. package/dist/hyperlink.d.mts +27 -0
  33. package/dist/hyperlink.d.ts +29 -0
  34. package/dist/hyperlink.mjs +7 -0
  35. package/dist/image.cjs +12 -5
  36. package/dist/image.d.cts +69 -58
  37. package/dist/image.d.mts +69 -58
  38. package/dist/image.d.ts +69 -58
  39. package/dist/image.mjs +10 -5
  40. package/dist/index.cjs +209 -11
  41. package/dist/index.d.cts +35 -12
  42. package/dist/index.d.mts +35 -12
  43. package/dist/index.d.ts +35 -12
  44. package/dist/index.mjs +20 -7
  45. package/dist/iterm2/iterm2-properties.d.cts +135 -0
  46. package/dist/iterm2/iterm2-properties.d.mts +135 -0
  47. package/dist/iterm2/iterm2-properties.d.ts +135 -0
  48. package/dist/iterm2/iterm2-sequences.d.cts +96 -0
  49. package/dist/iterm2/iterm2-sequences.d.mts +96 -0
  50. package/dist/iterm2/iterm2-sequences.d.ts +96 -0
  51. package/dist/iterm2.cjs +26 -0
  52. package/dist/iterm2.d.cts +58 -0
  53. package/dist/iterm2.d.mts +58 -0
  54. package/dist/iterm2.d.ts +58 -0
  55. package/dist/iterm2.mjs +14 -0
  56. package/dist/mode.cjs +388 -0
  57. package/dist/mode.d.cts +657 -0
  58. package/dist/mode.d.mts +657 -0
  59. package/dist/mode.d.ts +657 -0
  60. package/dist/mode.mjs +235 -0
  61. package/dist/mouse.cjs +127 -0
  62. package/dist/mouse.d.cts +230 -0
  63. package/dist/mouse.d.mts +230 -0
  64. package/dist/mouse.d.ts +230 -0
  65. package/dist/mouse.mjs +108 -0
  66. package/dist/packem_shared/IT2_AUTO-5vTJQMm6.cjs +15 -0
  67. package/dist/packem_shared/IT2_AUTO-DnfCUXso.mjs +8 -0
  68. package/dist/packem_shared/ITerm2File-BGPqNSjB.cjs +137 -0
  69. package/dist/packem_shared/ITerm2File-DKFkdqdA.mjs +130 -0
  70. package/dist/packem_shared/{constants-D8u2npjW.cjs → constants-BK26O-46.cjs} +4 -0
  71. package/dist/packem_shared/constants-CE7WkXh_.mjs +9 -0
  72. package/dist/packem_shared/cursor-CQKLCu7U.cjs +105 -0
  73. package/dist/packem_shared/cursor-DhFQcQ9g.mjs +73 -0
  74. package/dist/packem_shared/{restoreCursor-UYYzYxTZ.mjs → restoreCursor-C6pNB8UY.mjs} +4 -21
  75. package/dist/packem_shared/{restoreCursor-Bjacc7pa.cjs → restoreCursor-DC_ZKZwT.cjs} +4 -21
  76. package/dist/passthrough.cjs +38 -0
  77. package/dist/passthrough.d.cts +77 -0
  78. package/dist/passthrough.d.mts +77 -0
  79. package/dist/passthrough.d.ts +77 -0
  80. package/dist/passthrough.mjs +31 -0
  81. package/dist/reset.cjs +9 -0
  82. package/dist/reset.d.cts +26 -0
  83. package/dist/reset.d.mts +26 -0
  84. package/dist/reset.d.ts +26 -0
  85. package/dist/reset.mjs +4 -0
  86. package/dist/screen.cjs +41 -0
  87. package/dist/screen.d.cts +234 -0
  88. package/dist/screen.d.mts +234 -0
  89. package/dist/screen.d.ts +234 -0
  90. package/dist/screen.mjs +29 -0
  91. package/dist/scroll.cjs +17 -3
  92. package/dist/scroll.d.cts +67 -4
  93. package/dist/scroll.d.mts +67 -4
  94. package/dist/scroll.d.ts +67 -4
  95. package/dist/scroll.mjs +16 -4
  96. package/dist/status.cjs +147 -0
  97. package/dist/status.d.cts +501 -0
  98. package/dist/status.d.mts +501 -0
  99. package/dist/status.d.ts +501 -0
  100. package/dist/status.mjs +104 -0
  101. package/dist/strip.cjs +1 -1
  102. package/dist/strip.d.cts +23 -1
  103. package/dist/strip.d.mts +22 -2
  104. package/dist/strip.d.ts +23 -1
  105. package/dist/strip.mjs +1 -1
  106. package/dist/termcap.cjs +33 -0
  107. package/dist/termcap.d.cts +38 -0
  108. package/dist/termcap.d.mts +38 -0
  109. package/dist/termcap.d.ts +38 -0
  110. package/dist/termcap.mjs +27 -0
  111. package/dist/title.cjs +31 -0
  112. package/dist/title.d.cts +185 -0
  113. package/dist/title.d.mts +185 -0
  114. package/dist/title.d.ts +185 -0
  115. package/dist/title.mjs +20 -0
  116. package/dist/window-ops.cjs +85 -0
  117. package/dist/window-ops.d.cts +418 -0
  118. package/dist/window-ops.d.mts +418 -0
  119. package/dist/window-ops.d.ts +418 -0
  120. package/dist/window-ops.mjs +63 -0
  121. package/dist/xterm.cjs +48 -0
  122. package/dist/xterm.d.cts +94 -0
  123. package/dist/xterm.d.mts +94 -0
  124. package/dist/xterm.d.ts +94 -0
  125. package/dist/xterm.mjs +35 -0
  126. package/package.json +153 -9
  127. package/dist/link.cjs +0 -9
  128. package/dist/link.d.cts +0 -3
  129. package/dist/link.d.mts +0 -3
  130. package/dist/link.d.ts +0 -3
  131. package/dist/link.mjs +0 -7
  132. package/dist/packem_shared/constants-CqXMfQy0.mjs +0 -7
  133. package/dist/packem_shared/cursor-BzPDI1bk.mjs +0 -42
  134. package/dist/packem_shared/cursor-DSN9nA2g.cjs +0 -57
package/dist/scroll.d.ts CHANGED
@@ -1,4 +1,67 @@
1
- declare const scrollDown: (count?: number) => string;
2
- declare const scrollUp: (count?: number) => string;
3
-
4
- export { scrollDown, scrollUp };
1
+ /**
2
+ * Scrolls the content of the active scrolling region upwards by a specified number of lines.
3
+ * (SU - Scroll Up)
4
+ *
5
+ * New blank lines are added at the bottom of the scrolling region.
6
+ * If the parameter `count` is 1 or omitted, it defaults to scrolling one line.
7
+ * The cursor position is not affected by this command.
8
+ *
9
+ * Sequence: `CSI Pn S`
10
+ * - `Pn`: Number of lines to scroll up (default: 1).
11
+ * @param count The number of lines to scroll up. Defaults to 1. If 0, an empty string is returned as no operation is performed.
12
+ * @returns The ANSI escape sequence for scrolling up.
13
+ * @see {@link https://vt100.net/docs/vt510-rm/SU.html VT510 SU Documentation}
14
+ * @example
15
+ * ```typescript
16
+ * import { scrollUp } from \'@visulima/ansi/scroll\';
17
+ *
18
+ * // Scroll up 1 line
19
+ * process.stdout.write(scrollUp()); // CSI S
20
+ * process.stdout.write(scrollUp(1)); // CSI S
21
+ *
22
+ * // Scroll up 5 lines
23
+ * process.stdout.write(scrollUp(5)); // CSI 5S
24
+ *
25
+ * // No operation
26
+ * process.stdout.write(scrollUp(0)); // ""
27
+ * ```
28
+ */
29
+ export declare const scrollUp: (count?: number) => string;
30
+ /**
31
+ * Scrolls the content of the active scrolling region downwards by a specified number of lines.
32
+ * (SD - Scroll Down)
33
+ *
34
+ * New blank lines are added at the top of the scrolling region.
35
+ * If the parameter `count` is 1 or omitted, it defaults to scrolling one line.
36
+ * The cursor position is not affected by this command.
37
+ *
38
+ * Sequence: `CSI Pn T`
39
+ * - `Pn`: Number of lines to scroll down (default: 1).
40
+ * @param count The number of lines to scroll down. Defaults to 1. If 0, an empty string is returned.
41
+ * @returns The ANSI escape sequence for scrolling down.
42
+ * @see {@link https://vt100.net/docs/vt510-rm/SD.html VT510 SD Documentation}
43
+ * @example
44
+ * ```typescript
45
+ * import { scrollDown } from \'@visulima/ansi/scroll\';
46
+ *
47
+ * // Scroll down 1 line
48
+ * process.stdout.write(scrollDown()); // CSI T
49
+ * process.stdout.write(scrollDown(1)); // CSI T
50
+ *
51
+ * // Scroll down 3 lines
52
+ * process.stdout.write(scrollDown(3)); // CSI 3T
53
+ * ```
54
+ */
55
+ export declare const scrollDown: (count?: number) => string;
56
+ /**
57
+ * ANSI escape sequence to scroll up one line: `CSI S`.
58
+ * This is equivalent to `scrollUp(1)`.
59
+ * @see {@link scrollUp}
60
+ */
61
+ export declare const SCROLL_UP_1: string;
62
+ /**
63
+ * ANSI escape sequence to scroll down one line: `CSI T`.
64
+ * This is equivalent to `scrollDown(1)`.
65
+ * @see {@link scrollDown}
66
+ */
67
+ export declare const SCROLL_DOWN_1: string;
package/dist/scroll.mjs CHANGED
@@ -1,8 +1,20 @@
1
- import { C as CSI } from './packem_shared/constants-CqXMfQy0.mjs';
1
+ import { C as CSI } from './packem_shared/constants-CE7WkXh_.mjs';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- const scrollDown = /* @__PURE__ */ __name((count = 1) => `${CSI}T`.repeat(count), "scrollDown");
6
- const scrollUp = /* @__PURE__ */ __name((count = 1) => `${CSI}S`.repeat(count), "scrollUp");
5
+ const scrollUp = /* @__PURE__ */ __name((count = 1) => {
6
+ if (count === 0) {
7
+ return "";
8
+ }
9
+ return `${CSI + (count <= 1 ? "" : count)}S`;
10
+ }, "scrollUp");
11
+ const scrollDown = /* @__PURE__ */ __name((count = 1) => {
12
+ if (count === 0) {
13
+ return "";
14
+ }
15
+ return `${CSI + (count <= 1 ? "" : count)}T`;
16
+ }, "scrollDown");
17
+ const SCROLL_UP_1 = `${CSI}S`;
18
+ const SCROLL_DOWN_1 = `${CSI}T`;
7
19
 
8
- export { scrollDown, scrollUp };
20
+ export { SCROLL_DOWN_1, SCROLL_UP_1, scrollDown, scrollUp };
@@ -0,0 +1,147 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const constants = require('./packem_shared/constants-BK26O-46.cjs');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ class AnsiStatusReportImpl {
10
+ constructor(reportCode) {
11
+ this.reportCode = reportCode;
12
+ }
13
+ static {
14
+ __name(this, "AnsiStatusReportImpl");
15
+ }
16
+ isDecReport = false;
17
+ }
18
+ class DecStatusReportImpl {
19
+ constructor(reportCode) {
20
+ this.reportCode = reportCode;
21
+ }
22
+ static {
23
+ __name(this, "DecStatusReportImpl");
24
+ }
25
+ isDecReport = true;
26
+ }
27
+ const createAnsiStatusReport = /* @__PURE__ */ __name((code) => new AnsiStatusReportImpl(code), "createAnsiStatusReport");
28
+ const createDecStatusReport = /* @__PURE__ */ __name((code) => new DecStatusReportImpl(code), "createDecStatusReport");
29
+ const deviceStatusReport = /* @__PURE__ */ __name((...reports) => {
30
+ if (reports.length === 0) {
31
+ return "";
32
+ }
33
+ let hasDecReport = false;
34
+ const reportCodes = reports.map((report) => {
35
+ if (report.isDecReport) {
36
+ hasDecReport = true;
37
+ }
38
+ return report.reportCode.toString();
39
+ });
40
+ let seq = constants.CSI;
41
+ if (hasDecReport) {
42
+ seq += "?";
43
+ }
44
+ return `${seq + reportCodes.join(constants.SEP)}n`;
45
+ }, "deviceStatusReport");
46
+ const DSR = /* @__PURE__ */ __name((report) => deviceStatusReport(report), "DSR");
47
+ const requestCursorPositionReport = `${constants.CSI}6n`;
48
+ const requestExtendedCursorPositionReport = `${constants.CSI}?6n`;
49
+ const cursorPositionReport = /* @__PURE__ */ __name((line, column) => {
50
+ const r = Math.max(1, line);
51
+ const c = Math.max(1, column);
52
+ return `${constants.CSI + r.toString() + constants.SEP + c.toString()}R`;
53
+ }, "cursorPositionReport");
54
+ const CPR = cursorPositionReport;
55
+ const extendedCursorPositionReport = /* @__PURE__ */ __name((line, column, page) => {
56
+ const r = Math.max(1, line);
57
+ const c = Math.max(1, column);
58
+ let seq = `${constants.CSI}?`;
59
+ seq += r.toString() + constants.SEP + c.toString();
60
+ if (page > 0) {
61
+ seq += constants.SEP + page.toString();
62
+ }
63
+ seq += "R";
64
+ return seq;
65
+ }, "extendedCursorPositionReport");
66
+ const DECXCPR = extendedCursorPositionReport;
67
+ const RequestNameVersion = `${constants.CSI}>0q`;
68
+ const XTVERSION = RequestNameVersion;
69
+ const requestPrimaryDeviceAttributes = `${constants.CSI}c`;
70
+ const DA1 = requestPrimaryDeviceAttributes;
71
+ const reportPrimaryDeviceAttributes = /* @__PURE__ */ __name((...attributes) => {
72
+ if (attributes.length === 0) {
73
+ return "";
74
+ }
75
+ return `${constants.CSI}?${attributes.join(constants.SEP)}c`;
76
+ }, "reportPrimaryDeviceAttributes");
77
+ const requestSecondaryDeviceAttributes = `${constants.CSI}>c`;
78
+ const DA2 = requestSecondaryDeviceAttributes;
79
+ const reportSecondaryDeviceAttributes = /* @__PURE__ */ __name((version, level, cartridge = 0) => {
80
+ const pv = Math.max(0, version);
81
+ const pl = Math.max(0, level);
82
+ const pc = Math.max(0, cartridge);
83
+ return `${constants.CSI}>${pv}${constants.SEP}${pl}${constants.SEP}${pc}c`;
84
+ }, "reportSecondaryDeviceAttributes");
85
+ const requestTertiaryDeviceAttributes = `${constants.CSI}=c`;
86
+ const DA3 = requestTertiaryDeviceAttributes;
87
+ const reportTertiaryDeviceAttributes = /* @__PURE__ */ __name((unitID) => `${constants.DCS}!|${unitID}${constants.ST}`, "reportTertiaryDeviceAttributes");
88
+ const requestPrimaryDeviceAttributesParam0 = `${constants.CSI}0c`;
89
+ const requestSecondaryDeviceAttributesParam0 = `${constants.CSI}>0c`;
90
+ const requestTertiaryDeviceAttributesParam0 = `${constants.CSI}=0c`;
91
+ const requestTerminalStatus = createAnsiStatusReport(5);
92
+ const DSR_TerminalStatus = deviceStatusReport(requestTerminalStatus);
93
+ const reportTerminalOK = `${constants.CSI}0n`;
94
+ const reportTerminalNotOK = `${constants.CSI}3n`;
95
+ const requestPrinterStatusDEC = createDecStatusReport(15);
96
+ const DSR_PrinterStatusDEC = deviceStatusReport(requestPrinterStatusDEC);
97
+ const reportPrinterReadyDEC = `${constants.CSI}?10n`;
98
+ const reportPrinterNotReadyDEC = `${constants.CSI}?11n`;
99
+ const reportPrinterNoPaperDEC = `${constants.CSI}?13n`;
100
+ const requestUDKStatusDEC = createDecStatusReport(25);
101
+ const DSR_UDKStatusDEC = deviceStatusReport(requestUDKStatusDEC);
102
+ const reportUDKLockedDEC = `${constants.CSI}?20n`;
103
+ const reportUDKUnlockedDEC = `${constants.CSI}?21n`;
104
+ const requestKeyboardLanguageDEC = createDecStatusReport(26);
105
+ const DSR_KeyboardLanguageDEC = deviceStatusReport(requestKeyboardLanguageDEC);
106
+ const reportKeyboardLanguageDEC = /* @__PURE__ */ __name((langCode) => `${constants.CSI}?27${constants.SEP}${langCode.toString()}n`, "reportKeyboardLanguageDEC");
107
+
108
+ exports.CPR = CPR;
109
+ exports.DA1 = DA1;
110
+ exports.DA2 = DA2;
111
+ exports.DA3 = DA3;
112
+ exports.DECXCPR = DECXCPR;
113
+ exports.DSR = DSR;
114
+ exports.DSR_KeyboardLanguageDEC = DSR_KeyboardLanguageDEC;
115
+ exports.DSR_PrinterStatusDEC = DSR_PrinterStatusDEC;
116
+ exports.DSR_TerminalStatus = DSR_TerminalStatus;
117
+ exports.DSR_UDKStatusDEC = DSR_UDKStatusDEC;
118
+ exports.RequestNameVersion = RequestNameVersion;
119
+ exports.XTVERSION = XTVERSION;
120
+ exports.createAnsiStatusReport = createAnsiStatusReport;
121
+ exports.createDecStatusReport = createDecStatusReport;
122
+ exports.cursorPositionReport = cursorPositionReport;
123
+ exports.deviceStatusReport = deviceStatusReport;
124
+ exports.extendedCursorPositionReport = extendedCursorPositionReport;
125
+ exports.reportKeyboardLanguageDEC = reportKeyboardLanguageDEC;
126
+ exports.reportPrimaryDeviceAttributes = reportPrimaryDeviceAttributes;
127
+ exports.reportPrinterNoPaperDEC = reportPrinterNoPaperDEC;
128
+ exports.reportPrinterNotReadyDEC = reportPrinterNotReadyDEC;
129
+ exports.reportPrinterReadyDEC = reportPrinterReadyDEC;
130
+ exports.reportSecondaryDeviceAttributes = reportSecondaryDeviceAttributes;
131
+ exports.reportTerminalNotOK = reportTerminalNotOK;
132
+ exports.reportTerminalOK = reportTerminalOK;
133
+ exports.reportTertiaryDeviceAttributes = reportTertiaryDeviceAttributes;
134
+ exports.reportUDKLockedDEC = reportUDKLockedDEC;
135
+ exports.reportUDKUnlockedDEC = reportUDKUnlockedDEC;
136
+ exports.requestCursorPositionReport = requestCursorPositionReport;
137
+ exports.requestExtendedCursorPositionReport = requestExtendedCursorPositionReport;
138
+ exports.requestKeyboardLanguageDEC = requestKeyboardLanguageDEC;
139
+ exports.requestPrimaryDeviceAttributes = requestPrimaryDeviceAttributes;
140
+ exports.requestPrimaryDeviceAttributesParam0 = requestPrimaryDeviceAttributesParam0;
141
+ exports.requestPrinterStatusDEC = requestPrinterStatusDEC;
142
+ exports.requestSecondaryDeviceAttributes = requestSecondaryDeviceAttributes;
143
+ exports.requestSecondaryDeviceAttributesParam0 = requestSecondaryDeviceAttributesParam0;
144
+ exports.requestTerminalStatus = requestTerminalStatus;
145
+ exports.requestTertiaryDeviceAttributes = requestTertiaryDeviceAttributes;
146
+ exports.requestTertiaryDeviceAttributesParam0 = requestTertiaryDeviceAttributesParam0;
147
+ exports.requestUDKStatusDEC = requestUDKStatusDEC;