Attempt to fix deno prompt

This commit is contained in:
Timothy Warren 2023-11-27 11:07:26 -05:00
parent 759450222f
commit 4d54d4bf8a
6 changed files with 15 additions and 4 deletions

View File

@ -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}}

View File

@ -51,6 +51,11 @@ const BunTerminalIO: ITerminal = {
return defaultTerminalSize;
},
readStdin: async function (): Promise<string> {
const gen = BunTerminalIO.inputLoop();
const chunk = await gen.next();
return chunk.value!;
},
writeStdout: async function write(s: string): Promise<void> {
const buffer = new TextEncoder().encode(s);

View File

@ -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('');

View File

@ -71,6 +71,8 @@ export interface ITerminal {
*/
getTerminalSize(): Promise<ITerminalSize>;
readStdin(): Promise<string>;
/**
* Pipe a string to stdout
*/

View File

@ -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';

View File

@ -18,6 +18,11 @@ const DenoTerminalIO: ITerminal = {
cols: size.columns,
});
},
readStdin: async function (): Promise<string> {
const gen = DenoTerminalIO.inputLoop();
const chunk = await gen.next();
return chunk.value!;
},
writeStdout: async function write(s: string): Promise<void> {
const buffer: Uint8Array = new TextEncoder().encode(s);
const stdout: WritableStream<Uint8Array> = Deno.stdout.writable;