/** * Wrap the runtime-specific hook into stdin */ import { ITerminalIO, ITerminalSize } from '../common/mod.ts'; export async function* inputLoop() { for await (const chunk of Bun.stdin.stream()) { yield chunk; } } export async function write(s: string): Promise { const buffer = new TextEncoder().encode(s); await Bun.write(Bun.stdout, buffer); } export function getSize(): ITerminalSize { // @TODO implement // Check for tput // If has tput, use it to get terminal size // If not, try FFI fallback // Otherwise, return 80x25 as a last resort const fallback: ITerminalSize = { rows: 25, cols: 80 }; return fallback; } const BunTerminalIO: ITerminalIO = { inputLoop, getSize, write, }; export default BunTerminalIO;