summary refs log tree commit diff
path: root/main.ts
blob: 40ab9c4c54cd0ea35e538845fd9245a556bed7c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// deno-lint-ignore-file no-process-globals
import LoginScreen from "./screen/login.ts";
import { build } from "./screenbuilder.ts";
import readline from 'node:readline';
import * as client from "./client.ts"

function changeTitle(title: string) {
    if (process.platform == 'win32') {
        process.title = title;
    } else {
        process.stdout.write(`\x1b]2;${title}\x1b\x5c`);
    }
}

readline.emitKeypressEvents(process.stdin);

export type Client = typeof client

if (process.stdin.isTTY) process.stdin.setRawMode(true); // makes the terminal send stdin without the user pressing enter

changeTitle(`maelink`)

let screen;
try {
    screen = build(LoginScreen, client);
    client.setScreen(screen)
} catch (error) {
    console.error(error);
    for (const log of screen?.logs ?? []) {
        console.log(log)
    }
}