diff --git a/src/six/components/codeEditor/CodeEditor.tsx b/src/six/components/codeEditor/CodeEditor.tsx index 57c6db9f..8a951dd4 100644 --- a/src/six/components/codeEditor/CodeEditor.tsx +++ b/src/six/components/codeEditor/CodeEditor.tsx @@ -4,6 +4,7 @@ import * as monaco from 'monaco-editor'; import './styles.css'; import FontSizeMenu from '../fontSizeMenu/FontSizeMenu'; import LanguageSelector from '../languageSelector/LanguageSelector'; +import DefaultCodeModal from '../defaultCodeModal/DefaultCodeModal'; interface CodeEditorProps { code: string; @@ -35,6 +36,10 @@ const CodeEditor: React.FC = ({ const editorRef = useRef(null); const monacoInstance = useMonaco(); + const [showDefaultModal, setShowDefaultModal] = useState(false); + const openDefaultModal = () => setShowDefaultModal(true); + const closeDefaultModal = () => setShowDefaultModal(false); + const [fontSize, setFontSize] = useState(16); const [useLocalFontSize, setUseLocalFontSize] = useState(false); useState(null); @@ -513,7 +518,36 @@ const CodeEditor: React.FC = ({ }} /> + + { + setCode(newCode); + if (editorRef.current) { + const model = editorRef.current.getModel(); + if (model) model.setValue(newCode); + } + }} + language={lang} + /> void; + setCode: (code: string) => void; + language: string; +}) { + const handleConfirm = () => { + if (language === 'c') { + setCode(DEFAULT_C_CODE); + } else { + setCode(DEFAULT_CPP_CODE); + } + handleClose(); + }; + + return ( + + + + Reset Editor to Default Code + + + + This will replace the current editor contents with the default starter code. This action + cannot be undone unless you have a saved copy. Are you sure you want to continue? + + + + + + + + + ); +} diff --git a/src/six/pages/graphs/graphsPage.tsx b/src/six/pages/graphs/graphsPage.tsx index 9028f914..7125cbaf 100644 --- a/src/six/pages/graphs/graphsPage.tsx +++ b/src/six/pages/graphs/graphsPage.tsx @@ -37,7 +37,7 @@ interface compileOption { const DEFAULT_LANG = 'c'; // Fallback default code for empty sessions (matches SessionManager) -const DEFAULT_C_CODE = `#include +export const DEFAULT_C_CODE = `#include #include typedef struct { @@ -72,7 +72,7 @@ int main() { return 0; }`; -const DEFAULT_CPP_CODE = `#include +export const DEFAULT_CPP_CODE = `#include #include using namespace std; class IntArray {