From 390ff9bccf548b6b046f621f769acbd2a5aec3fa Mon Sep 17 00:00:00 2001 From: rhpidfyre Date: Sun, 2 Feb 2025 03:04:49 -0500 Subject: [PATCH] =?UTF-8?q?javascript=20time=20=F0=9F=98=AE=E2=80=8D?= =?UTF-8?q?=F0=9F=92=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/react/fs.ts | 17 ++++++++++++ src/components/react/shell.tsx | 45 ++++++++++++++++++++++++++++++++ src/components/react/terminal.ts | 10 +++++++ 3 files changed, 72 insertions(+) create mode 100644 src/components/react/fs.ts create mode 100644 src/components/react/shell.tsx create mode 100644 src/components/react/terminal.ts diff --git a/src/components/react/fs.ts b/src/components/react/fs.ts new file mode 100644 index 0000000..fead9dc --- /dev/null +++ b/src/components/react/fs.ts @@ -0,0 +1,17 @@ +const user = { + ["about_me"]: {}, + ["services"]: {} +} +const home = { + ["user"]: user +} +const root = { + ["bin"]: {}, + ["home"]: {} +} + +const fs = { + ["/"]: root +} + +export { fs } \ No newline at end of file diff --git a/src/components/react/shell.tsx b/src/components/react/shell.tsx new file mode 100644 index 0000000..6b27fcf --- /dev/null +++ b/src/components/react/shell.tsx @@ -0,0 +1,45 @@ +import { TermEvents } from "./terminal" + +let working_fs_dir = "user" +function GetWorkingDir(): string { + if (working_fs_dir === "user") { + return "~" + } + return working_fs_dir +} + +function ls() { + +} + +function Prompt() { + const cyan_user = user + const green_dir = {GetWorkingDir()} + return

{cyan_user}@host {green_dir}{"> "}

+} + +function ShellEvents() { + const shell_input = document.getElementById("shell-input") + if (shell_input) { + shell_input.addEventListener("keydown", (keyboard_event) => { + if (keyboard_event.key === "Enter") { + console.log("woah its the enter key") + } + }) + } +} + +function ShellPrompt() { + return
+ + +
+} + +export default function Shell() { + const shell_prompt = ShellPrompt() + TermEvents() + ShellEvents() + + return shell_prompt +} \ No newline at end of file diff --git a/src/components/react/terminal.ts b/src/components/react/terminal.ts new file mode 100644 index 0000000..351c920 --- /dev/null +++ b/src/components/react/terminal.ts @@ -0,0 +1,10 @@ +const terminal_window = document.querySelector("main"); + +export function TermEvents() { + if (terminal_window) { + terminal_window.addEventListener("click", (_event) => { + const shell_input = document.getElementById("shell-input") + if (shell_input) { shell_input.focus() } + }) + } +} \ No newline at end of file