diff options
-rw-r--r-- | deno.lock | 3 | ||||
-rw-r--r-- | main.ts | 10 | ||||
-rw-r--r-- | screen/home.ts | 9 | ||||
-rw-r--r-- | screen/login.ts | 18 |
4 files changed, 36 insertions, 4 deletions
diff --git a/deno.lock b/deno.lock index d1e49f9..4578e66 100644 --- a/deno.lock +++ b/deno.lock @@ -4,8 +4,7 @@ "packageJson": { "dependencies": [ "npm:@types/node@^22.9.0", - "npm:chalk@^5.3.0", - "npm:express@^4.21.1" + "npm:chalk@^5.3.0" ] } } diff --git a/main.ts b/main.ts index 4fe68ff..922b47a 100644 --- a/main.ts +++ b/main.ts @@ -4,10 +4,20 @@ 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); 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); diff --git a/screen/home.ts b/screen/home.ts index c6f6c19..296fec2 100644 --- a/screen/home.ts +++ b/screen/home.ts @@ -3,6 +3,14 @@ import { Screen } from "../screen.ts"; import type { Input, Text } from "../elements.ts"; import process from "node:process"; +function changeTitle(title: string) { + if (process.platform == 'win32') { + process.title = title; + } else { + process.stdout.write(`\x1b]2;${title}\x1b\x5c`); + } +} + export default { elements: [ { @@ -49,5 +57,6 @@ export default { onload (screen: Screen) { screen.client.setScreen(screen) screen.client.loadHome(screen) + changeTitle(`maelink - home`) } } \ No newline at end of file diff --git a/screen/login.ts b/screen/login.ts index 57121bb..57b269f 100644 --- a/screen/login.ts +++ b/screen/login.ts @@ -3,6 +3,15 @@ import { Screen } from "../screen.ts"; import { build } from "../screenbuilder.ts"; import HomeScreen from "./home.ts"; import { Input } from "../elements.ts"; +import process from "node:process" + +function changeTitle(title: string) { + if (process.platform == 'win32') { + process.title = title; + } else { + process.stdout.write(`\x1b]2;${title}\x1b\x5c`); + } +} export default { elements: [ @@ -42,15 +51,20 @@ export default { this.off() this.logs.push(`clicked button`) console.clear() - console.log("logging in...") + changeTitle('maelink - logging in...') + this.logs.push("logging in...") const usernameInput = this.elements.get("username-input") as Input; const passwordInput = this.elements.get("password-input") as Input; await this.client.login(usernameInput.value, passwordInput.value) + changeTitle('maelink - logged in as ' + usernameInput.value) build(HomeScreen, this.client); this.client }] } ], focus: "username-input", - name: 'login' + name: 'login', + onload() { + changeTitle(`maelink - log in`) + } } \ No newline at end of file |