diff --git a/src/App.tsx b/src/App.tsx index c2cce23..53e2171 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,14 +4,8 @@ import { ExprBlock, type ExprBlockState } from './ExprBlock'; import { GlobalContext } from './GlobalContext'; import { biggerExample, higherOrder, higherOrder2Params, inc, initialEditorState, lambda2Params, nonEmptyEditorState, pushBool, tripleFunctionCallEditorState } from "./configurations"; import { removeFocus } from "./eval"; +import { actionShortcuts, getActions } from './actions'; -const commands: [string, string[], string][] = [ - ["call" , ['c' ], "call" ], - ["eval" , ['e','Tab','Enter'], "eval" ], - ["transform", ['t', '.' ], "transform" ], - ["let" , ['l', '=' ], "let … in …" ], - ["lambda" , ['a' ], "λx: …" ], -]; const examples: [string, ExprBlockState][] = [ ["empty editor" , initialEditorState ], @@ -114,9 +108,9 @@ export function App() { }, []); const [highlighted, setHighlighted] = useState( - commands.map(() => false)); + actionShortcuts.map(() => false)); - const doHighlight = Object.fromEntries(commands.map(([id], i) => { + const doHighlight = Object.fromEntries(actionShortcuts.map(([id], i) => { return [id, () => { setHighlighted(h => h.with(i, true)); setTimeout(() => setHighlighted(h => h.with(i, false)), 100); @@ -138,9 +132,10 @@ export function App() { { - commands.map(([_, keys, descr], i) => + actionShortcuts.map(([_, keys, descr], i) => {keys.map((key, j) => {key})} +   {descr} ) } @@ -173,18 +168,11 @@ export function App() { // console.log('suggestionPriority of App, always 0'); return 0; }} - addParam={(s: ExprBlockState) => { - pushHistory(state => ({ - kind: "call", - fn: removeFocus(state), - input: initialEditorState, - })); - doHighlight.call(); + addParam={() => { + getActions({doHighlight}, pushHistory).c(); }} /> - -