Adding function to list all store entries. OS command palette thing coming soon
This commit is contained in:
parent
eef4daf8ec
commit
a30d2217b8
3 changed files with 25 additions and 12 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue