import { initialEditorState } from "./configurations"; import { removeFocus } from "./eval"; export const actionShortcuts: [string, string[], string][] = [ ["call" , ['c'], "expr ⌴" ], ["transform", ['.'], "⌴ expr" ], ["assign" , ['a'], "let (⌴ = expr) in ⌴"], ["declare" , ['d'], "let (⌴ = ⌴) in expr"], ["lambda" , ['l'], "λ⌴. expr" ], ]; export function getActions(globalContext, setState) { return { c: () => { setState(state => ({ kind: "call", fn: removeFocus(state), input: initialEditorState, })); globalContext?.doHighlight.call(); }, '.': () => { setState(state => ({ kind: "call", fn: initialEditorState, input: removeFocus(state), })); globalContext?.doHighlight.transform(); }, a: () => { setState(state => ({ kind: "let", name: "", focus: true, value: removeFocus(state), inner: removeFocus(initialEditorState), })); globalContext?.doHighlight.assign(); }, d: () => { setState(state => ({ kind: "let", name: "", focus: true, value: removeFocus(initialEditorState), inner: removeFocus(state), })); globalContext?.doHighlight.declare(); }, l: () => { setState(state => ({ kind: "lambda", paramName: "", focus: true, expr: removeFocus(state), })); globalContext?.doHighlight.lambda(); }, }; }