Use Node stdin API for Bun to allow basic functionality to work again
All checks were successful
timw4mail/scroll/pipeline/head This commit looks good
All checks were successful
timw4mail/scroll/pipeline/head This commit looks good
This commit is contained in:
parent
ab42873182
commit
9d45cf9296
@ -7,6 +7,8 @@ import { defaultTerminalSize } from '../common/config.ts';
|
|||||||
import { readKey } from '../common/fns.ts';
|
import { readKey } from '../common/fns.ts';
|
||||||
import { ITerminal, ITerminalSize } from '../common/types.ts';
|
import { ITerminal, ITerminalSize } from '../common/types.ts';
|
||||||
|
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
|
||||||
async function _getTerminalSizeFromAnsi(): Promise<ITerminalSize> {
|
async function _getTerminalSizeFromAnsi(): Promise<ITerminalSize> {
|
||||||
// Tell the cursor to move to Row 999 and Column 999
|
// Tell the cursor to move to Row 999 and Column 999
|
||||||
// Since this command specifically doesn't go off the screen
|
// Since this command specifically doesn't go off the screen
|
||||||
@ -46,8 +48,13 @@ const BunTerminalIO: ITerminal = {
|
|||||||
// to have consistent argument lists
|
// to have consistent argument lists
|
||||||
argv: (Bun.argv.length > 2) ? Bun.argv.slice(2) : [],
|
argv: (Bun.argv.length > 2) ? Bun.argv.slice(2) : [],
|
||||||
inputLoop: async function* inputLoop() {
|
inputLoop: async function* inputLoop() {
|
||||||
for await (const chunk of Bun.stdin.stream()) {
|
// for await (const chunk of Bun.stdin.stream()) {
|
||||||
yield chunk;
|
// yield chunk;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return null;
|
||||||
|
for await (const chunk of process.stdin) {
|
||||||
|
yield encoder.encode(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -73,7 +80,7 @@ const BunTerminalIO: ITerminal = {
|
|||||||
return chunk.value ?? null;
|
return chunk.value ?? null;
|
||||||
},
|
},
|
||||||
writeStdout: async function write(s: string): Promise<void> {
|
writeStdout: async function write(s: string): Promise<void> {
|
||||||
const buffer = new TextEncoder().encode(s);
|
const buffer = encoder.encode(s);
|
||||||
|
|
||||||
await Bun.write(Bun.stdout, buffer);
|
await Bun.write(Bun.stdout, buffer);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user