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 { Env } from './env'
|
||||||
|
import type { Value } from './types'
|
||||||
|
import { evaluate } from './interpreter'
|
||||||
import { tokenize } from './lexer'
|
import { tokenize } from './lexer'
|
||||||
import { Parser } from './parser'
|
import { Parser } from './parser'
|
||||||
import { runApp } from './runtime';
|
import { runApp } from './runtime';
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,25 @@ export function runApp(app: App, canvas: HTMLCanvasElement, source: string, env:
|
||||||
view: Value;
|
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>();
|
const componentInstances = new Map<string, ComponentInstance>();
|
||||||
|
|
||||||
// Focus tracking
|
// Focus tracking
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ testApp = {
|
||||||
combinedText = email & " " & password
|
combinedText = email & " " & password
|
||||||
};
|
};
|
||||||
|
|
||||||
topLevelText = "";
|
|
||||||
|
|
||||||
update = state event \ event
|
update = state event \ event
|
||||||
| _ \ state;
|
| _ \ state;
|
||||||
|
|
||||||
|
|
@ -37,15 +35,10 @@ view = state viewport \
|
||||||
Text { content = "Username: " & testApp.email, x = 8, y = 16 },
|
Text { content = "Username: " & testApp.email, x = 8, y = 16 },
|
||||||
Text { content = "Password: " & testApp.password, x = 8, y = 16 },
|
Text { content = "Password: " & testApp.password, x = 8, y = 16 },
|
||||||
Text { content = "Combined: " & testApp.combinedText, x = 8, y = 16 },
|
Text { content = "Combined: " & testApp.combinedText, x = 8, y = 16 },
|
||||||
textInput {
|
Column {
|
||||||
key = "top-level-text",
|
gap = 10,
|
||||||
initialValue = topLevelText,
|
children = map (t \ Text { content = t, x = 8, y = 16 }) (storeSearch "")
|
||||||
initialFocus = False,
|
}
|
||||||
w = 300,
|
|
||||||
h = 40,
|
|
||||||
onChange = text \ topLevelText := text
|
|
||||||
},
|
|
||||||
Text { content = "Top Level: " & topLevelText, x = 8, y = 16 }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue