2023-10-27 16:02:54 -04:00
|
|
|
/**
|
|
|
|
* The main entrypoint when using Deno as the runtime
|
|
|
|
*/
|
2023-11-01 15:05:31 -04:00
|
|
|
import { Termios } from './termios.ts'
|
|
|
|
|
2023-10-27 16:02:54 -04:00
|
|
|
export async function main(): Promise<number> {
|
2023-11-01 15:05:31 -04:00
|
|
|
const t = new Termios();
|
|
|
|
t.enableRawMode();
|
|
|
|
|
2023-10-27 16:02:54 -04:00
|
|
|
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();
|
2023-10-27 16:02:54 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|