diff --git a/src/cg/10-os.cg b/src/cg/10-os.cg index c536045..78f3032 100644 --- a/src/cg/10-os.cg +++ b/src/cg/10-os.cg @@ -162,14 +162,16 @@ os = search = q \ storeRes = storeSearch q; + historyRes = filter (h \ fuzzyMatch q h) paletteHistory; [ + Section "HISTORY", + ...map (name \ Item { label = name }) historyRes, Section "STORE", ...map (name \ Item { label = name }) storeRes, Section "EVAL", Item { label = q } ]; - isUI = v \ hasField "kind" v; openOrFocus = title content width \ index title (map (w \ w.title) osState.windows) @@ -177,22 +179,24 @@ os = | None \ openWindow title content width; onSelect = input \ + historyEvent = paletteHistory := take 50 [input, ...(filter (e \ e != input) paletteHistory)]; dw = osState.wm.defaultWindowWidth; appWidth = app \ hasField "width" app | True \ app.width | false \ dw; - eval! input - | Defined name \ ( - app = inspector { name = name }; - openOrFocus name app.view (appWidth app)) - - | Value v \ (hasField "view" v - | True \ openOrFocus input v.view (appWidth v) - | False \ (getSource input == "" - | True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" }) dw - | False \ ( - app = inspector { name = input }; - openOrFocus input app.view (appWidth app)))) - - | Err msg \ (_ = debug! "OS Error" msg; noOp); + openEvent = eval! input + | Defined name \ ( + app = inspector { name = name }; + openOrFocus name app.view (appWidth app)) + + | Value v \ (hasField "view" v + | True \ openOrFocus input v.view (appWidth v) + | False \ (getSource input == "" + | True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" }) dw + | False \ ( + app = inspector { name = input }; + openOrFocus input app.view (appWidth app)))) + + | Err msg \ (_ = debug! "OS Error" msg; noOp); + batch [historyEvent, openEvent]; handleFocusLeftEvent = state \ newIndex = max 0 (osState.wm.focusedIndex - 1); diff --git a/src/main.ts b/src/main.ts index d01c35f..07edb31 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,6 +25,10 @@ try { const parser = new Parser(tokens, cgCode); const defs = parser.parse(); loadDefinitions(); + + // TODO remove once we're booting from store, files are backup + if (!store.paletteHistory) store.paletteHistory = []; + compileAndRun(defs); saveDefinitions();