diff --git a/src/App.jsx b/src/App.jsx index f412ad74..75c2e825 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -23,7 +23,7 @@ function App() { }); const [isLaunchpadOpen, setIsLaunchpadOpen] = useState(false); - // Toggle Launchpad when "L" key is pressed + // Handle keypress for opening launchpad useEffect(() => { const handleKeyDown = (e) => { if (e.ctrlKey && e.key === "l") { @@ -38,6 +38,7 @@ function App() { }; }, []); + // Handle adding a host const handleAddHost = () => { if (form.ip && form.user && form.password && form.port) { const newTerminal = { @@ -49,6 +50,8 @@ function App() { password: form.password, port: Number(form.port), }, + isSplit: false, + terminalRef: null, // Reference to the terminal instance }; setTerminals([...terminals, newTerminal]); setActiveTab(nextId); @@ -60,6 +63,7 @@ function App() { } }; + // Close a terminal tab const closeTab = (id) => { const newTerminals = terminals.filter((t) => t.id !== id); setTerminals(newTerminals); @@ -68,39 +72,42 @@ function App() { } }; + // Toggle split for a specific tab + const toggleSplit = (id) => { + setTerminals(terminals.map(t => + t.id === id ? { ...t, isSplit: !t.isSplit } : t + )); + }; + + // Get the split terminals + const splitTerminals = terminals.filter(t => t.isSplit); + const mainTerminal = terminals.find(t => t.id === activeTab); + return (
{/* Topbar */} -
- {/* Left: Title */} +
- Termix Icon + Termix Icon

Termix

- {/* Middle: Tabs with scroll */}
-
+
- {/* Open Launchpad Button */} + {/* Launchpad Button */} - {/* Right: Create Host Button */} + {/* Add Host Button */}
{/* Terminal Views */} -
- {terminals.map((terminal) => ( -
- +
+ {splitTerminals.length > 0 ? ( +
+ {splitTerminals.map((terminal) => ( +
+ { + if (ref && !terminal.terminalRef) { + // Store the terminal instance reference + setTerminals(prev => prev.map(t => + t.id === terminal.id ? { ...t, terminalRef: ref } : t + )); + } + }} + /> +
+ ))}
- ))} + ) : ( +
+ {mainTerminal && ( +
+ { + if (ref && !mainTerminal.terminalRef) { + // Store the terminal instance reference + setTerminals(prev => prev.map(t => + t.id === mainTerminal.id ? { ...t, terminalRef: ref } : t + )); + } + }} + /> +
+ )} +
+ )}
+ {/* Modal for adding a host */} {/* Launchpad Component */} - {isLaunchpadOpen && ( - setIsLaunchpadOpen(false)} /> - )} + {isLaunchpadOpen && setIsLaunchpadOpen(false)} />}
); diff --git a/src/TabList.jsx b/src/TabList.jsx index 79073a6b..28dd666e 100644 --- a/src/TabList.jsx +++ b/src/TabList.jsx @@ -1,14 +1,11 @@ -import {Button, ButtonGroup} from "@mui/joy"; +import { Button, ButtonGroup } from "@mui/joy"; import PropTypes from "prop-types"; -function TabList({ terminals, activeTab, setActiveTab, closeTab, theme }) { +function TabList({ terminals, activeTab, setActiveTab, closeTab, toggleSplit, theme }) { return (
{terminals.map((terminal, index) => ( -
+
+