scroll/src/deno/index.ts

21 lines
430 B
JavaScript
Raw Normal View History

/**
* The main entrypoint when using Deno as the runtime
*/
2023-11-01 15:25:52 -04:00
import {getTermios} from "../common/termios.ts";
2023-11-01 15:05:31 -04:00
export async function main(): Promise<number> {
2023-11-01 15:25:52 -04:00
const t = await getTermios()
2023-11-01 15:05:31 -04:00
t.enableRawMode();
const decoder = new TextDecoder();
for await (const chunk of Deno.stdin.readable) {
const char = String(decoder.decode(chunk)).trim();
if (char === 'q') {
2023-11-01 15:05:31 -04:00
t.disableRawMode();
return 0;
}
}
return -1;
}