diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 658260d..e7b5fdd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: dope2: specifier: git+https://deemz.org/git/joeri/dope2.git - version: git+https://deemz.org/git/joeri/dope2.git#e631f11aa52b2adda8809c1b0b41cc991fbe8890 + version: git+https://deemz.org/git/joeri/dope2.git#443a13998dc3eccab26c27bee4fa056cdbc8f994 react: specifier: ^19.1.0 version: 19.1.0 @@ -633,8 +633,8 @@ packages: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} - dope2@git+https://deemz.org/git/joeri/dope2.git#e631f11aa52b2adda8809c1b0b41cc991fbe8890: - resolution: {commit: e631f11aa52b2adda8809c1b0b41cc991fbe8890, repo: https://deemz.org/git/joeri/dope2.git, type: git} + dope2@git+https://deemz.org/git/joeri/dope2.git#443a13998dc3eccab26c27bee4fa056cdbc8f994: + resolution: {commit: 443a13998dc3eccab26c27bee4fa056cdbc8f994, repo: https://deemz.org/git/joeri/dope2.git, type: git} version: 0.0.1 dunder-proto@1.0.1: @@ -1762,7 +1762,7 @@ snapshots: depd@2.0.0: {} - dope2@git+https://deemz.org/git/joeri/dope2.git#e631f11aa52b2adda8809c1b0b41cc991fbe8890: + dope2@git+https://deemz.org/git/joeri/dope2.git#443a13998dc3eccab26c27bee4fa056cdbc8f994: dependencies: functional-red-black-tree: 1.0.1 diff --git a/src/App.tsx b/src/App.tsx index 42d9d1a..05505d0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,14 +6,15 @@ import { CommandContext } from './CommandContext'; import { EnvContext } from './EnvContext'; export function App() { - const [history, setHistory] = useState([initialEditorState]); + // const [history, setHistory] = useState([initialEditorState]); // const [history, setHistory] = useState([nonEmptyEditorState]); - // const [history, setHistory] = useState([tripleFunctionCallEditorState]); + const [history, setHistory] = useState([tripleFunctionCallEditorState]); const [future, setFuture] = useState([]); - const pushHistory = (s: EditorState) => { - setHistory(history.concat([s])); + const pushHistory = (callback: (p: EditorState) => EditorState) => { + const newState = callback(history.at(-1)!); + setHistory(history.concat([newState])); setFuture([]); }; @@ -50,11 +51,11 @@ export function App() { window.onkeydown = onKeyDown; }, []); - const commands = [ - ["call" , "[c] call" ], - ["eval" , "[e] [Tab] [Enter] eval"], - ["transform", "[t] [.] transform" ], - ["let" , "[l] [=] let ... in ..." ], + const commands: [string, string[], string][] = [ + ["call" , ['c' ], "call" ], + ["eval" , ['e','Tab','Enter' ], "eval" ], + ["transform", ['t', '.' ], "transform" ], + ["let" , ['l', '=', 'a' ], "let ... in ..."], ]; const [highlighted, setHighlighted] = useState( @@ -74,8 +75,9 @@ export function App() { Commands: { - commands.map(([_, descr], i) => + commands.map(([_, keys, descr], i) => + {keys.map((key, j) => {key})} {descr} ) } @@ -86,11 +88,12 @@ export function App() { {}} onCancel={() => {}} filter={() => true} /> + +