vterm.js 0.4.0 → 0.5.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.
- package/dist/index.mjs +124 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -270,8 +270,39 @@ function createScreen(options = {}) {
|
|
|
270
270
|
let defaultBgColor = null;
|
|
271
271
|
let cursorColor = null;
|
|
272
272
|
const specialColors = /* @__PURE__ */ new Map();
|
|
273
|
+
let pointerFgColor = null;
|
|
274
|
+
let pointerBgColor = null;
|
|
273
275
|
let highlightBgColor = null;
|
|
274
276
|
let highlightFgColor = null;
|
|
277
|
+
const colorStack = [];
|
|
278
|
+
function cloneColor(c) {
|
|
279
|
+
return c ? { ...c } : null;
|
|
280
|
+
}
|
|
281
|
+
function snapshotColorState() {
|
|
282
|
+
return {
|
|
283
|
+
palette256: palette256.map((c) => ({ ...c })),
|
|
284
|
+
defaultFgColor: cloneColor(defaultFgColor),
|
|
285
|
+
defaultBgColor: cloneColor(defaultBgColor),
|
|
286
|
+
cursorColor: cloneColor(cursorColor),
|
|
287
|
+
specialColors: [...specialColors].map(([idx, color]) => [idx, { ...color }]),
|
|
288
|
+
pointerFgColor: cloneColor(pointerFgColor),
|
|
289
|
+
pointerBgColor: cloneColor(pointerBgColor),
|
|
290
|
+
highlightBgColor: cloneColor(highlightBgColor),
|
|
291
|
+
highlightFgColor: cloneColor(highlightFgColor)
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
function restoreColorState(snapshot) {
|
|
295
|
+
palette256 = snapshot.palette256.map((c) => ({ ...c }));
|
|
296
|
+
defaultFgColor = cloneColor(snapshot.defaultFgColor);
|
|
297
|
+
defaultBgColor = cloneColor(snapshot.defaultBgColor);
|
|
298
|
+
cursorColor = cloneColor(snapshot.cursorColor);
|
|
299
|
+
specialColors.clear();
|
|
300
|
+
for (const [idx, color] of snapshot.specialColors) specialColors.set(idx, { ...color });
|
|
301
|
+
pointerFgColor = cloneColor(snapshot.pointerFgColor);
|
|
302
|
+
pointerBgColor = cloneColor(snapshot.pointerBgColor);
|
|
303
|
+
highlightBgColor = cloneColor(snapshot.highlightBgColor);
|
|
304
|
+
highlightFgColor = cloneColor(snapshot.highlightFgColor);
|
|
305
|
+
}
|
|
275
306
|
let tabStops = defaultTabStops(cols);
|
|
276
307
|
function defaultTabStops(c) {
|
|
277
308
|
const s = /* @__PURE__ */ new Set();
|
|
@@ -288,6 +319,12 @@ function createScreen(options = {}) {
|
|
|
288
319
|
return 0;
|
|
289
320
|
}
|
|
290
321
|
let textScale = 1;
|
|
322
|
+
const CELL_W_PX = 8;
|
|
323
|
+
const CELL_H_PX = 17;
|
|
324
|
+
const FONT_ASCENT_PX = 14;
|
|
325
|
+
let fontSize = 12;
|
|
326
|
+
let fontWindowSize = 12;
|
|
327
|
+
let locale = "en_US.UTF-8";
|
|
291
328
|
let advancedClipboard = "";
|
|
292
329
|
let viewportOffset = 0;
|
|
293
330
|
let charsetG0 = false;
|
|
@@ -388,6 +425,9 @@ function createScreen(options = {}) {
|
|
|
388
425
|
softWrapped[top] = false;
|
|
389
426
|
}
|
|
390
427
|
}
|
|
428
|
+
function scrollViewport(delta) {
|
|
429
|
+
viewportOffset = Math.max(0, Math.min(scrollback.length, viewportOffset + delta));
|
|
430
|
+
}
|
|
391
431
|
/** Find the previous non-spacer cell (the cell before curX, skipping wide-char spacers) */
|
|
392
432
|
function getPrevCell() {
|
|
393
433
|
if (curX === 0 && curY === 0) return null;
|
|
@@ -1626,6 +1666,30 @@ function createScreen(options = {}) {
|
|
|
1626
1666
|
if (c) cursorColor = c;
|
|
1627
1667
|
}
|
|
1628
1668
|
break;
|
|
1669
|
+
case 13:
|
|
1670
|
+
if (value === "?") {
|
|
1671
|
+
if (onResponse) onResponse(`\x1b]13;${formatColorResponse(pointerFgColor ?? defaultFgColor ?? {
|
|
1672
|
+
r: 255,
|
|
1673
|
+
g: 255,
|
|
1674
|
+
b: 255
|
|
1675
|
+
})}\x1b\\`);
|
|
1676
|
+
} else {
|
|
1677
|
+
const c = parseColorSpec(value);
|
|
1678
|
+
if (c) pointerFgColor = c;
|
|
1679
|
+
}
|
|
1680
|
+
break;
|
|
1681
|
+
case 14:
|
|
1682
|
+
if (value === "?") {
|
|
1683
|
+
if (onResponse) onResponse(`\x1b]14;${formatColorResponse(pointerBgColor ?? defaultBgColor ?? {
|
|
1684
|
+
r: 0,
|
|
1685
|
+
g: 0,
|
|
1686
|
+
b: 0
|
|
1687
|
+
})}\x1b\\`);
|
|
1688
|
+
} else {
|
|
1689
|
+
const c = parseColorSpec(value);
|
|
1690
|
+
if (c) pointerBgColor = c;
|
|
1691
|
+
}
|
|
1692
|
+
break;
|
|
1629
1693
|
case 17:
|
|
1630
1694
|
if (value === "?") {
|
|
1631
1695
|
if (onResponse) onResponse(`\x1b]17;${formatColorResponse(highlightBgColor ?? defaultFgColor ?? {
|
|
@@ -1755,6 +1819,12 @@ function createScreen(options = {}) {
|
|
|
1755
1819
|
case 112:
|
|
1756
1820
|
cursorColor = null;
|
|
1757
1821
|
break;
|
|
1822
|
+
case 113:
|
|
1823
|
+
pointerFgColor = null;
|
|
1824
|
+
break;
|
|
1825
|
+
case 114:
|
|
1826
|
+
pointerBgColor = null;
|
|
1827
|
+
break;
|
|
1758
1828
|
case 117:
|
|
1759
1829
|
highlightBgColor = null;
|
|
1760
1830
|
break;
|
|
@@ -1820,6 +1890,53 @@ function createScreen(options = {}) {
|
|
|
1820
1890
|
}
|
|
1821
1891
|
}
|
|
1822
1892
|
break;
|
|
1893
|
+
case 701:
|
|
1894
|
+
if (value === "?") {
|
|
1895
|
+
if (onResponse) onResponse(`\x1b]701;${locale}\x1b\\`);
|
|
1896
|
+
} else if (value !== "") locale = value;
|
|
1897
|
+
break;
|
|
1898
|
+
case 702:
|
|
1899
|
+
if (onResponse) onResponse("\x1B]702;vterm.js;vterm;0;2\x1B\\");
|
|
1900
|
+
break;
|
|
1901
|
+
case 720: {
|
|
1902
|
+
const n = parseInt(value, 10);
|
|
1903
|
+
scrollViewport(!isNaN(n) && n > 0 ? n : 1);
|
|
1904
|
+
break;
|
|
1905
|
+
}
|
|
1906
|
+
case 721: {
|
|
1907
|
+
const n = parseInt(value, 10);
|
|
1908
|
+
scrollViewport(-(!isNaN(n) && n > 0 ? n : 1));
|
|
1909
|
+
break;
|
|
1910
|
+
}
|
|
1911
|
+
case 776:
|
|
1912
|
+
if (onResponse) onResponse(`\x1b]776;${CELL_W_PX};${CELL_H_PX};${FONT_ASCENT_PX}\x1b\\`);
|
|
1913
|
+
break;
|
|
1914
|
+
case 7770:
|
|
1915
|
+
if (value === "?") {
|
|
1916
|
+
if (onResponse) onResponse(`\x1b]7770;${fontSize}\x1b\\`);
|
|
1917
|
+
} else if (value === "") fontSize = 12;
|
|
1918
|
+
else {
|
|
1919
|
+
const n = parseInt(value, 10);
|
|
1920
|
+
if (!isNaN(n) && n > 0) fontSize = n;
|
|
1921
|
+
}
|
|
1922
|
+
break;
|
|
1923
|
+
case 7777:
|
|
1924
|
+
if (value === "?") {
|
|
1925
|
+
if (onResponse) onResponse(`\x1b]7777;${fontWindowSize}\x1b\\`);
|
|
1926
|
+
} else if (value === "") fontWindowSize = 12;
|
|
1927
|
+
else {
|
|
1928
|
+
const n = parseInt(value, 10);
|
|
1929
|
+
if (!isNaN(n) && n > 0) fontWindowSize = n;
|
|
1930
|
+
}
|
|
1931
|
+
break;
|
|
1932
|
+
case 30001:
|
|
1933
|
+
colorStack.push(snapshotColorState());
|
|
1934
|
+
break;
|
|
1935
|
+
case 30101: {
|
|
1936
|
+
const snapshot = colorStack.pop();
|
|
1937
|
+
if (snapshot) restoreColorState(snapshot);
|
|
1938
|
+
break;
|
|
1939
|
+
}
|
|
1823
1940
|
case 5522:
|
|
1824
1941
|
if (value === "?" && onResponse) onResponse(`\x1b]5522;${btoa(advancedClipboard)}\x1b\\`);
|
|
1825
1942
|
else try {
|
|
@@ -1943,6 +2060,9 @@ function createScreen(options = {}) {
|
|
|
1943
2060
|
altScrollMode = false;
|
|
1944
2061
|
utf8MouseMode = false;
|
|
1945
2062
|
textScale = 1;
|
|
2063
|
+
fontSize = 12;
|
|
2064
|
+
fontWindowSize = 12;
|
|
2065
|
+
locale = "en_US.UTF-8";
|
|
1946
2066
|
advancedClipboard = "";
|
|
1947
2067
|
viewportOffset = 0;
|
|
1948
2068
|
charsetG0 = false;
|
|
@@ -1954,8 +2074,11 @@ function createScreen(options = {}) {
|
|
|
1954
2074
|
defaultBgColor = null;
|
|
1955
2075
|
cursorColor = null;
|
|
1956
2076
|
specialColors.clear();
|
|
2077
|
+
pointerFgColor = null;
|
|
2078
|
+
pointerBgColor = null;
|
|
1957
2079
|
highlightBgColor = null;
|
|
1958
2080
|
highlightFgColor = null;
|
|
2081
|
+
colorStack.length = 0;
|
|
1959
2082
|
tabStops = defaultTabStops(cols);
|
|
1960
2083
|
lastChar = "";
|
|
1961
2084
|
pendingRegionalIndicator = null;
|
|
@@ -2369,9 +2492,7 @@ function createScreen(options = {}) {
|
|
|
2369
2492
|
getNotifications: () => [...notifications],
|
|
2370
2493
|
getScrollbackLength: () => scrollback.length,
|
|
2371
2494
|
getViewportOffset: () => viewportOffset,
|
|
2372
|
-
scrollViewport
|
|
2373
|
-
viewportOffset = Math.max(0, Math.min(scrollback.length, viewportOffset + delta));
|
|
2374
|
-
},
|
|
2495
|
+
scrollViewport,
|
|
2375
2496
|
getSemanticZones: () => semanticZones.map((z) => ({ ...z })),
|
|
2376
2497
|
getSixelImages: () => sixelImages.map((img) => ({ ...img }))
|
|
2377
2498
|
};
|