Monorepo for Aesthetic.Computer
aesthetic.computer
1// Dashboard, 24.03.11.14.58
2// A dashboard that could potentially run decoupled from
3// `session.mjs`.
4
5let termkit;
6
7// Dynamically import the `terminal-kit` library.
8try {
9 termkit = (await import("terminal-kit")).default;
10} catch (err) {
11 error("Failed to load terminal-kit", error);
12}
13
14if (termkit) {
15 const term = termkit.terminal;
16
17 const doc = term.createDocument({
18 palette: new termkit.Palette(),
19 });
20
21 // Create left (log) and right (client list) columns
22 const leftColumn = new termkit.Container({
23 parent: doc,
24 x: 0,
25 width: "100%",
26 height: "100%",
27 });
28
29 // const rightColumn = new termkit.Container({
30 // parent: doc,
31 // x: "70%",
32 // width: "30%",
33 // height: "100%",
34 // });
35
36 term.grabInput();
37
38 // console.log("grabbed input");
39
40 term.on("key", function (name, matches, data) {
41 console.log("'key' event:", name);
42
43 // Detect CTRL-C and exit 'manually'
44 if (name === "CTRL_C") {
45 process.exit();
46 }
47 });
48
49 term.on("mouse", function (name, data) {
50 console.log("'mouse' event:", name, data);
51 });
52
53 // Log box in the left column
54 const logBox = new termkit.TextBox({
55 parent: leftColumn,
56 content: "Your logs will appear here...\n",
57 scrollable: true,
58 vScrollBar: true,
59 x: 0,
60 y: 0,
61 width: "100%",
62 height: "100%",
63 mouse: true, // to allow mouse interactions if needed
64 });
65
66 // Static list box in the right column
67 // const clientList = new termkit.TextBox({
68 // parent: rightColumn,
69 // content: "Client List:\n",
70 // x: 0,
71 // y: 0,
72 // width: "100%",
73 // height: "100%",
74 // });
75
76 // Example functions to update contents
77 // function addLog(message) {
78 // logBox.setContent(logBox.getContent() + message + "\n");
79 // // logBox.scrollBottom();
80 // doc.draw();
81 // }
82
83 // function updateClientList(clients) {
84 // clientList.setContent("Client List:\n" + clients.join("\n"));
85 // doc.draw();
86 // }
87
88 // Example usage
89 // addLog("Server started...");
90 // updateClientList(["Client1", "Client2"]);
91
92 doc.draw();
93}