shellwise 0.2.0 → 0.2.1
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/package.json +1 -1
- package/src/tui/renderer.ts +9 -4
package/package.json
CHANGED
package/src/tui/renderer.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { openSync, writeSync, closeSync } from "fs";
|
|
2
|
+
import { execSync } from "child_process";
|
|
2
3
|
|
|
3
4
|
const ESC = "\x1b[";
|
|
4
5
|
|
|
@@ -49,10 +50,14 @@ export function showCursor(): string {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export function getTerminalSize(): { rows: number; cols: number } {
|
|
52
|
-
// process.stdout
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
// Avoid process.stdout/stderr entirely — Bun crashes with kqueue error
|
|
54
|
+
// when they're accessed inside $() capture. Use stty instead.
|
|
55
|
+
try {
|
|
56
|
+
const output = execSync("stty size </dev/tty", { encoding: "utf-8" }).trim();
|
|
57
|
+
const [rows, cols] = output.split(" ").map(Number);
|
|
58
|
+
if (rows > 0 && cols > 0) return { rows, cols };
|
|
59
|
+
} catch {}
|
|
60
|
+
return { rows: 24, cols: 80 };
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
export function write(text: string): void {
|