Attempt to fix deno prompt
This commit is contained in:
parent
759450222f
commit
4d54d4bf8a
2
justfile
2
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}}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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('');
|
||||
|
@ -71,6 +71,8 @@ export interface ITerminal {
|
||||
*/
|
||||
getTerminalSize(): Promise<ITerminalSize>;
|
||||
|
||||
readStdin(): Promise<string>;
|
||||
|
||||
/**
|
||||
* Pipe a string to stdout
|
||||
*/
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user