diff --git a/vweb/src/forge_highlighter.js b/vweb/src/forge_highlighter.js index 7d99ecf..1b8bc58 100644 --- a/vweb/src/forge_highlighter.js +++ b/vweb/src/forge_highlighter.js @@ -93,16 +93,5 @@ export default { } return 'quote' } - }, - - indent: function (state, textAfter, cx) { - return 0 - //const closing = dedentPartial.test(textAfter); - //return state.basecol + cx.unit * (state.indentDepth - (closing ? 1 : 0)); - }, - - languageData: { - //indentOnInput: /^\s*(?:end|until|else|\)|\})$/, - //commentTokens: {line: '//', block: {open: '/*', close: '*/'}} } } \ No newline at end of file diff --git a/vweb/src/forge_simulator.jsx b/vweb/src/forge_simulator.jsx index 763cadc..306d990 100644 --- a/vweb/src/forge_simulator.jsx +++ b/vweb/src/forge_simulator.jsx @@ -10,11 +10,22 @@ export default function({ src: defaultSrc }) { const [binary, setBinary] = useState(null) // The assembled binary const [cpu, _setCpu] = useState(() => new WasmCPU()) // The actual CPU emulator const [errors, setErrors] = useState(null) // What's displayed on the compile errors tab - const [src, setSrc] = useState(() => undent(defaultSrc)) // The current Forge source const [status, setStatus] = useState('') // The contents of the status bar // Whether the emulator should be running. Has to be a ref because the CPU setTimeout loop won't ever see changes in it otherwise const running = useRef(false) + // The current Forge source. Our initial state tries to look something up from localStorage, + // then if that fails uses the prop. + const [src, setSrc] = useState(() => { + return window.localStorage.getItem('src') || undent(defaultSrc) + }) + + // When we update the src, also update the key in localStorage + const updateSrc = useCallback((newSrc) => { + setSrc(newSrc) + window.localStorage.setItem('src', newSrc) + }, []) + // Callback for the build button const build = useCallback(() => { try { @@ -65,7 +76,7 @@ export default function({ src: defaultSrc }) {
- {activeTab === 'editor' && } + {activeTab === 'editor' && } {activeTab === 'assembly' &&
{assembly}
} {activeTab === 'display' && } {activeTab === 'errors' &&
{errors}
}