diff --git a/justfile b/justfile index 81dfc5c..d9a3630 100644 --- a/justfile +++ b/justfile @@ -61,4 +61,4 @@ deno-coverage: # Run with deno deno-run file="": - deno run --allow-all --allow-ffi --deny-net --deny-hrtime --unstable ./src/scroll.ts {{file}} + deno run --allow-all --allow-ffi --deny-hrtime --unstable ./src/scroll.ts {{file}} diff --git a/src/bun/terminal_io.ts b/src/bun/terminal_io.ts index 51c5951..4b5ac46 100644 --- a/src/bun/terminal_io.ts +++ b/src/bun/terminal_io.ts @@ -51,6 +51,11 @@ const BunTerminalIO: ITerminal = { return defaultTerminalSize; }, + readStdin: async function (): Promise { + const gen = BunTerminalIO.inputLoop(); + const chunk = await gen.next(); + return chunk.value!; + }, writeStdout: async function write(s: string): Promise { const buffer = new TextEncoder().encode(s); diff --git a/src/common/editor.ts b/src/common/editor.ts index f3a638c..7d05c48 100644 --- a/src/common/editor.ts +++ b/src/common/editor.ts @@ -232,8 +232,7 @@ class Editor { while (true) { this.setStatusMessage(`${p}${res}`); await this.refreshScreen(); - const chunk = await term.inputLoop().next(); - const char = chunk.value!; + const char = await term.readStdin(); // End the prompt if (char === KeyCommand.Enter) { this.setStatusMessage(''); diff --git a/src/common/runtime.ts b/src/common/runtime.ts index 9e6fd41..f953de1 100644 --- a/src/common/runtime.ts +++ b/src/common/runtime.ts @@ -71,6 +71,8 @@ export interface ITerminal { */ getTerminalSize(): Promise; + readStdin(): Promise; + /** * Pipe a string to stdout */ diff --git a/src/deno/deps.ts b/src/deno/deps.ts index bca48ad..40ae756 100644 --- a/src/deno/deps.ts +++ b/src/deno/deps.ts @@ -1 +1 @@ -export * as stdAssert from 'https://deno.land/std@0.205.0/assert/mod.ts'; +export * as stdAssert from 'https://deno.land/std@0.208.0/assert/mod.ts'; diff --git a/src/deno/terminal_io.ts b/src/deno/terminal_io.ts index 200e2a2..5f62f83 100644 --- a/src/deno/terminal_io.ts +++ b/src/deno/terminal_io.ts @@ -18,6 +18,11 @@ const DenoTerminalIO: ITerminal = { cols: size.columns, }); }, + readStdin: async function (): Promise { + const gen = DenoTerminalIO.inputLoop(); + const chunk = await gen.next(); + return chunk.value!; + }, writeStdout: async function write(s: string): Promise { const buffer: Uint8Array = new TextEncoder().encode(s); const stdout: WritableStream = Deno.stdout.writable;