Palette history

master
Dustin Swan 5 days ago
parent a874101a3d
commit 76e6868cac
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -162,14 +162,16 @@ os =
search = q \ search = q \
storeRes = storeSearch q; storeRes = storeSearch q;
historyRes = filter (h \ fuzzyMatch q h) paletteHistory;
[ [
Section "HISTORY",
...map (name \ Item { label = name }) historyRes,
Section "STORE", Section "STORE",
...map (name \ Item { label = name }) storeRes, ...map (name \ Item { label = name }) storeRes,
Section "EVAL", Section "EVAL",
Item { label = q } Item { label = q }
]; ];
isUI = v \ hasField "kind" v;
openOrFocus = title content width \ openOrFocus = title content width \
index title (map (w \ w.title) osState.windows) index title (map (w \ w.title) osState.windows)
@ -177,22 +179,24 @@ os =
| None \ openWindow title content width; | None \ openWindow title content width;
onSelect = input \ onSelect = input \
historyEvent = paletteHistory := take 50 [input, ...(filter (e \ e != input) paletteHistory)];
dw = osState.wm.defaultWindowWidth; dw = osState.wm.defaultWindowWidth;
appWidth = app \ hasField "width" app | True \ app.width | false \ dw; appWidth = app \ hasField "width" app | True \ app.width | false \ dw;
eval! input openEvent = eval! input
| Defined name \ ( | Defined name \ (
app = inspector { name = name }; app = inspector { name = name };
openOrFocus name app.view (appWidth app)) openOrFocus name app.view (appWidth app))
| Value v \ (hasField "view" v | Value v \ (hasField "view" v
| True \ openOrFocus input v.view (appWidth v) | True \ openOrFocus input v.view (appWidth v)
| False \ (getSource input == "" | False \ (getSource input == ""
| True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" }) dw | True \ openOrFocus input (_ \ ui.text { content = show v, color = "white" }) dw
| False \ ( | False \ (
app = inspector { name = input }; app = inspector { name = input };
openOrFocus input app.view (appWidth app)))) openOrFocus input app.view (appWidth app))))
| Err msg \ (_ = debug! "OS Error" msg; noOp); | Err msg \ (_ = debug! "OS Error" msg; noOp);
batch [historyEvent, openEvent];
handleFocusLeftEvent = state \ handleFocusLeftEvent = state \
newIndex = max 0 (osState.wm.focusedIndex - 1); newIndex = max 0 (osState.wm.focusedIndex - 1);

@ -25,6 +25,10 @@ try {
const parser = new Parser(tokens, cgCode); const parser = new Parser(tokens, cgCode);
const defs = parser.parse(); const defs = parser.parse();
loadDefinitions(); loadDefinitions();
// TODO remove once we're booting from store, files are backup
if (!store.paletteHistory) store.paletteHistory = [];
compileAndRun(defs); compileAndRun(defs);
saveDefinitions(); saveDefinitions();

Loading…
Cancel
Save