From a30d2217b805e08bf51a3b1f02d172c2cd14aae5 Mon Sep 17 00:00:00 2001 From: Dustin Swan Date: Sat, 7 Feb 2026 00:03:08 -0700 Subject: [PATCH] Adding function to list all store entries. OS command palette thing coming soon --- src/main.ts | 3 ++- src/runtime.ts | 19 +++++++++++++++++++ src/textinput-test.cg | 15 ++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main.ts b/src/main.ts index 20145fa..a0a5bac 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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'; diff --git a/src/runtime.ts b/src/runtime.ts index 5fd7932..7a9310f 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -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(); // Focus tracking diff --git a/src/textinput-test.cg b/src/textinput-test.cg index 412c62c..d871575 100644 --- a/src/textinput-test.cg +++ b/src/textinput-test.cg @@ -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 "") + } ] } };