diff --git a/src/components/applications/terminal/Terminal.jsx b/src/components/applications/terminal/Terminal.jsx index 6a04aaa..0eb715e 100644 --- a/src/components/applications/terminal/Terminal.jsx +++ b/src/components/applications/terminal/Terminal.jsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import styles from "./Terminal.module.css"; import { useVirtualRoot } from "../../../hooks/virtual-drive/VirtualRootContext.js"; import { Command } from "../../../features/applications/terminal/commands.js"; @@ -43,14 +43,16 @@ function InputLine({ value, prefix, onChange, onKeyUp, onKeyDown }) { ); } -export function Terminal() { +export function Terminal({ setTitle }) { const [inputKey, setInputKey] = useState(0); const [inputValue, setInputValue] = useState(""); const [history, setHistory] = useState([]); const virtualRoot = useVirtualRoot(); const [currentDirectory, setCurrentDirectory] = useState(virtualRoot.navigate("~")); - // console.log(currentDirectory); + useEffect(() => { + setTitle(`${USERNAME}@${HOSTNAME}: ${currentDirectory.root ? "/" : currentDirectory.path}`); + }, [currentDirectory.path, currentDirectory.root, setTitle]); const prefix = `${USERNAME}@${HOSTNAME}:${currentDirectory.root ? "/" : currentDirectory.path}$ `; diff --git a/src/components/applications/text-editor/TextEditor.jsx b/src/components/applications/text-editor/TextEditor.jsx index d7f0df1..c084648 100644 --- a/src/components/applications/text-editor/TextEditor.jsx +++ b/src/components/applications/text-editor/TextEditor.jsx @@ -1,12 +1,12 @@ import React, { useEffect, useState } from "react"; - import { VirtualFile } from "../../../features/virtual-drive/virtual-file.js"; import styles from "./TextEditor.module.css"; import { HeaderMenu } from "../.common/HeaderMenu.jsx"; import Markdown from "markdown-to-jsx"; +import Application from "../../../features/applications/application.js"; -const defaultZoom = 16; -const zoomSpeed = 4; +const DEFAULT_ZOOM = 16; +const ZOOM_FACTOR = 4; /** * @param {object} props @@ -14,13 +14,14 @@ const zoomSpeed = 4; * @param {Function} props.setTitle * @param {Function} props.close * @param {string} props.mode + * @param {Application} props.app */ -export function TextEditor({ file, setTitle, close, mode }) { +export function TextEditor({ file, setTitle, close, mode, app }) { const [currentFile, setCurrentFile] = useState(file); const [currentMode, setCurrentMode] = useState(mode); const [content, setContent] = useState(file?.content ?? ""); const [unsavedChanges, setUnsavedChanges] = useState(file == null); - const [zoom, setZoom] = useState(defaultZoom); + const [zoom, setZoom] = useState(DEFAULT_ZOOM); useEffect(() => { (async () => { @@ -51,8 +52,8 @@ export function TextEditor({ file, setTitle, close, mode }) { if (currentMode === "view") label += " (preview)"; - setTitle(`${label} - Text Editor`); - }, [currentFile, setTitle, unsavedChanges, currentMode]); + setTitle(`${label} - ${app.name}`); + }, [currentFile, setTitle, unsavedChanges, currentMode, app.name]); const newText = () => { setCurrentFile(null); @@ -101,13 +102,13 @@ export function TextEditor({ file, setTitle, close, mode }) { setCurrentMode(currentMode === "view" ? "edit" : "view"); }, "Zoom In": () => { - setZoom(zoom + zoomSpeed); + setZoom(zoom + ZOOM_FACTOR); }, "Zoom Out": () => { - setZoom(zoom - zoomSpeed); + setZoom(zoom - ZOOM_FACTOR); }, "Reset Zoom": () => { - setZoom(defaultZoom); + setZoom(DEFAULT_ZOOM); } } }} diff --git a/src/components/windows/Window.jsx b/src/components/windows/Window.jsx index ec20390..6ff257f 100644 --- a/src/components/windows/Window.jsx +++ b/src/components/windows/Window.jsx @@ -139,7 +139,7 @@ export const Window = memo(function Window({ id, app, size, position, focused =