xonecas.io
6615
Yc

yoctoselect / commit edeea31

feat: ANSI escape helpers

xonecas2026-03-21 edeea311837ec49b1a89d3a1755c57e2966c1a65 parent 1d11db1

1 file changed

src/ansi.ts+21−0
@@ -0,0 +1,21 @@
1+const ESC = "\x1b[";
2+
3+export function cursorUp(n: number): string {
4+ return n > 0 ? `${ESC}${n}A` : "";
5+}
6+
7+export function clearDown(): string {
8+ return `${ESC}J`;
9+}
10+
11+export function hideCursor(): string {
12+ return `${ESC}?25l`;
13+}
14+
15+export function showCursor(): string {
16+ return `${ESC}?25h`;
17+}
18+
19+export function write(s: string): void {
20+ process.stdout.write(s);
21+}