Palette history

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

@ -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);

@ -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();

Loading…
Cancel
Save