import React, { useRef, useEffect } from 'react'; interface CommandHistoryEntry { command: string; output: string; success: boolean; } interface TerminalProps { commandHistory: CommandHistoryEntry[]; command: string; setCommand: (cmd: string) => void; executeCommand: (cmd: string) => void; executing: boolean; currentPath: string; terminalMinimized: boolean; setTerminalMinimized: (val: boolean) => void; onGetCommandReference: () => void; onGetHints: () => void; onGetFHSReference: () => void; } const Terminal: React.FC = ({ commandHistory, command, setCommand, executeCommand, executing, currentPath, terminalMinimized, setTerminalMinimized, onGetCommandReference, onGetHints, onGetFHSReference, }) => { const terminalRef = useRef(null); const inputRef = useRef(null); // Auto-scroll terminal to bottom useEffect(() => { if (terminalRef.current) { terminalRef.current.scrollTop = terminalRef.current.scrollHeight; } }, [commandHistory]); // Auto-focus input after command execution useEffect(() => { if (!executing && inputRef.current && !terminalMinimized) { inputRef.current.focus(); } }, [executing, terminalMinimized]); // Terminal color scheme - always dark mode const terminalColors = { frame: 'bg-stone-200 border-stone-300', header: 'bg-stone-300 border-stone-400', headerText: 'text-stone-900', content: 'bg-black', closeButton: 'text-stone-700 hover:text-stone-900' }; return (
{/* Terminal Header */}

bash

{/* Terminal Content */} {!terminalMinimized && (
inputRef.current?.focus()} > {commandHistory.map((entry, index) => (
groundskeeper@molehill :: {entry.command.startsWith('Hunt started!') ? '~' : currentPath} $ {entry.command.startsWith('Hunt started!') ? '' : entry.command}
{entry.output && (
{entry.output.split('\n').map((line, i) => { // Special coloring for mole detection messages let lineClass = ''; if (line.includes('New mole detected')) { lineClass = 'text-yellow-400'; } else if (line.includes('⚠️')) { // Timer warnings if (line.includes('CRITICAL')) { lineClass = 'text-red-500'; } else if (line.includes('ALERT')) { lineClass = 'text-orange-400'; } else if (line.includes('WARNING')) { lineClass = 'text-yellow-400'; } } return (
{line}
); })}
)}
))} {/* Current input line */}
groundskeeper@molehill :: {currentPath} $
{command} _ setCommand(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); executeCommand(command); } }} disabled={executing} className="absolute inset-0 w-full bg-transparent text-transparent outline-none caret-transparent font-terminal" placeholder="" autoFocus spellCheck={false} autoComplete="off" autoCorrect="off" autoCapitalize="off" />
)}
); }; export default Terminal;