Adding function to list all store entries. OS command palette thing coming soon

master
Dustin Swan 3 hours ago
parent eef4daf8ec
commit a30d2217b8
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -1,5 +1,6 @@
import { evaluate } from './interpreter'
import type { Env } from './env'
import type { Value } from './types'
import { evaluate } from './interpreter'
import { tokenize } from './lexer'
import { Parser } from './parser'
import { runApp } from './runtime';

@ -24,6 +24,25 @@ export function runApp(app: App, canvas: HTMLCanvasElement, source: string, env:
view: Value;
};
// Store-related builtins
env.set('storeSearch', {
kind: 'native',
name: 'storeNames',
arity: 1,
fn: (query) => {
const names: Value[] = [];
const searchTerm = query.kind === 'string' ? query.value.toLowerCase() : '';
for (const name of store.keys()) {
if (searchTerm === '' || name.toLowerCase().includes(searchTerm)) {
names.push({ kind: 'string', value: name });
}
}
return { kind: 'list', elements: names };
}
});
const componentInstances = new Map<string, ComponentInstance>();
// Focus tracking

@ -6,8 +6,6 @@ testApp = {
combinedText = email & " " & password
};
topLevelText = "";
update = state event \ event
| _ \ state;
@ -37,15 +35,10 @@ view = state viewport \
Text { content = "Username: " & testApp.email, x = 8, y = 16 },
Text { content = "Password: " & testApp.password, x = 8, y = 16 },
Text { content = "Combined: " & testApp.combinedText, x = 8, y = 16 },
textInput {
key = "top-level-text",
initialValue = topLevelText,
initialFocus = False,
w = 300,
h = 40,
onChange = text \ topLevelText := text
},
Text { content = "Top Level: " & topLevelText, x = 8, y = 16 }
Column {
gap = 10,
children = map (t \ Text { content = t, x = 8, y = 16 }) (storeSearch "")
}
]
}
};

Loading…
Cancel
Save