@zhongqian97-code/ecode 0.3.10 → 0.3.12
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.js +27 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2100,6 +2100,13 @@ function confirmSelection(inputText, selectedPath) {
|
|
|
2100
2100
|
|
|
2101
2101
|
// src/ui/mouseInput.ts
|
|
2102
2102
|
var SGR_MOUSE_RE = /^\x1b\[<(\d+);\d+;\d+[Mm]/;
|
|
2103
|
+
function isMouseEvent(data) {
|
|
2104
|
+
const s = typeof data === "string" ? data : data.toString("binary");
|
|
2105
|
+
if (!s) return false;
|
|
2106
|
+
if (SGR_MOUSE_RE.test(s)) return true;
|
|
2107
|
+
if (s.length >= 6 && s.charCodeAt(0) === 27 && s[1] === "[" && s[2] === "M") return true;
|
|
2108
|
+
return false;
|
|
2109
|
+
}
|
|
2103
2110
|
function parseMouseScroll(data) {
|
|
2104
2111
|
const s = typeof data === "string" ? data : data.toString("binary");
|
|
2105
2112
|
if (!s) return null;
|
|
@@ -2188,19 +2195,30 @@ function App({ config: config2, version: version2, autoMode: autoMode2 = false,
|
|
|
2188
2195
|
useEffect3(() => {
|
|
2189
2196
|
if (!stdin || !stdout) return;
|
|
2190
2197
|
stdout.write("\x1B[?1000h\x1B[?1006h");
|
|
2191
|
-
const
|
|
2192
|
-
|
|
2193
|
-
if (
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
+
const origEmit = stdin.emit;
|
|
2199
|
+
stdin.emit = function(event, ...args) {
|
|
2200
|
+
if (event === "readable") {
|
|
2201
|
+
const chunk = stdin.read();
|
|
2202
|
+
if (chunk !== null) {
|
|
2203
|
+
if (isMouseEvent(chunk)) {
|
|
2204
|
+
const scrollEvent = parseMouseScroll(chunk);
|
|
2205
|
+
if (scrollEvent) {
|
|
2206
|
+
if (scrollEvent.direction === "up") {
|
|
2207
|
+
setScrollOffset((prev) => Math.min(prev + 3, Math.max(0, totalLinesRef.current - 1)));
|
|
2208
|
+
} else {
|
|
2209
|
+
setScrollOffset((prev) => Math.max(0, prev - 3));
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
return false;
|
|
2213
|
+
}
|
|
2214
|
+
stdin.unshift(chunk);
|
|
2215
|
+
}
|
|
2198
2216
|
}
|
|
2217
|
+
return origEmit.apply(stdin, [event, ...args]);
|
|
2199
2218
|
};
|
|
2200
|
-
stdin.on("data", onMouseData);
|
|
2201
2219
|
return () => {
|
|
2202
2220
|
stdout.write("\x1B[?1000l\x1B[?1006l");
|
|
2203
|
-
stdin.
|
|
2221
|
+
stdin.emit = origEmit;
|
|
2204
2222
|
};
|
|
2205
2223
|
}, [stdin, stdout]);
|
|
2206
2224
|
useEffect3(() => {
|