store paths are now arrays, because '.' needed to be a valid path ident. more quoting crap. font is done! well.. it's something. probably not 'done'

master
Dustin Swan 4 days ago
parent 515ad7fc9c
commit 6fe94ddfb2
Signed by: dustinswan
GPG Key ID: 30D46587E2100467

@ -309,5 +309,5 @@ function prettyPrintPattern(pattern: Pattern): string {
} }
function needsQuotes(key: string): boolean { function needsQuotes(key: string): boolean {
return !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key); return key === '_' || !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(key);
} }

@ -59,6 +59,12 @@ drop = n list \ { n = n, list = list }
| { n = 0, list = _ } \ list | { n = 0, list = _ } \ list
| { n = _, list = [x, ...xs] } \ drop (n - 1) xs; | { n = _, list = [x, ...xs] } \ drop (n - 1) xs;
# join : String \ List String \ String
join = s list \ list
| [] \ ""
| [x] \ x
| [x, ...xs] \ (x & s & (join s xs));
# zipWith : (a \ b \ c) \ List a \ List b \ List c # zipWith : (a \ b \ c) \ List a \ List b \ List c
zipWith = f l1 l2 \ l1 zipWith = f l1 l2 \ l1
| [] \ [] | [] \ []

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
fontEditor = config \ fontEditor = config \
defaults = { defaults = {
path = "newFont" path = ["newFont"]
}; };
c = { ...defaults, ...config }; c = { ...defaults, ...config };
@ -13,13 +13,13 @@ fontEditor = config \
view = ctx \ view = ctx \
editGlyph = path \ editGlyph = path \
app = pixelEditor { path = path }; app = pixelEditor { path = path };
ctx.openApp path app.view app.width; ctx.openApp (join "." path) app.view app.width;
ui.stateful { ui.stateful {
focusable = True, focusable = True,
autoFocus = True, autoFocus = True,
key = "fontEditor-" & c.path, key = "fontEditor-" & (join "." c.path),
init = existing init = existing
| Some v \ { | Some v \ {
@ -62,7 +62,7 @@ fontEditor = config \
x = floor ((tileSize - glyph.w * scale) / 2); x = floor ((tileSize - glyph.w * scale) / 2);
ui.clickable { ui.clickable {
onClick = \ editGlyph (c.path & ".glyphs." & key), onClick = \ editGlyph [...c.path, "glyphs", key],
child = ui.stack { child = ui.stack {
children = [ children = [
ui.rect { w = tileSize, h = tileSize, strokeWidth = 1, strokeColor = "#fff" }, ui.rect { w = tileSize, h = tileSize, strokeWidth = 1, strokeColor = "#fff" },
@ -84,7 +84,7 @@ fontEditor = config \
h = headerHeight, h = headerHeight,
key = "new-glyph-button", key = "new-glyph-button",
label = "New Glyph", label = "New Glyph",
onSubmit = key \ rebindAt (c.path & ".glyphs." & key) { w = 7, h = 12, map = [] } onSubmit = key \ rebindAt [...c.path, "glyphs", key] { w = 7, h = 12, map = [] }
} }
] ]
}; };

@ -36,7 +36,6 @@ pixelEditor = config \
{ state = newState, emit = saveGlyph newState }); { state = newState, emit = saveGlyph newState });
existing = getAt c.path; existing = getAt c.path;
_ = debug! "existing" existing;
# return App # return App
{ {
@ -46,7 +45,7 @@ pixelEditor = config \
focusable = True, focusable = True,
autoFocus = True, autoFocus = True,
key = "pixelEditor-" & c.path, key = "pixelEditor-" & (join "." c.path),
init = existing init = existing
| Some v \ { | Some v \ {
@ -117,8 +116,6 @@ pixelEditor = config \
gap = 10, gap = 10,
children = [ children = [
ui.positioned { x = 0, y = 8, child = ui.text { content = c.path, color = "#fff" } },
textInput { textInput {
key = "width-input", key = "width-input",
w = 40, w = 40,

@ -80,7 +80,7 @@ export const _rt = {
return String(value); return String(value);
}, },
chars: (s: string) => s.split(''), chars: (s: string) => s.split(''),
join: (delim: string) => (xs: string[]) => xs.join(delim), // join: (delim: string) => (xs: string[]) => xs.join(delim),
split: (delim: string) => (xs: string) => xs.split(delim), split: (delim: string) => (xs: string) => xs.split(delim),
slice: (s: string | any[]) => (start: number) => (end: number) => s.slice(start, end), slice: (s: string | any[]) => (start: number) => (end: number) => s.slice(start, end),
"debug!": (label: string) => (value: any) => { console.log(label, value); return value; }, "debug!": (label: string) => (value: any) => { console.log(label, value); return value; },
@ -107,12 +107,11 @@ export const _rt = {
.filter(name => _rt.fuzzyMatch(query)(name)._tag === 'True') .filter(name => _rt.fuzzyMatch(query)(name)._tag === 'True')
.sort((a, b) => a.length - b.length); .sort((a, b) => a.length - b.length);
}, },
getAt: (pathStr: string) => { getAt: (path: any[]) => {
const parts = pathStr.split('.'); let obj: any = store[path[0]];
let obj: any = store[parts[0]]; for (let i = 1; i < path.length; i++) {
for (let i = 1; i < parts.length; i++) {
if (obj === undefined || obj === null) return { _tag: 'None' }; if (obj === undefined || obj === null) return { _tag: 'None' };
obj = obj[parts[i]]; obj = obj[path[i]];
} }
return obj === undefined ? { _tag: 'None' } : { _tag: 'Some', _0: obj }; return obj === undefined ? { _tag: 'None' } : { _tag: 'Some', _0: obj };
}, },
@ -155,12 +154,11 @@ export const _rt = {
} }
syncToAst(name); syncToAst(name);
}, },
rebindAt: (pathStr: string) => (value: string) => { rebindAt: (path: any[]) => (value: any) => {
const parts = pathStr.split('.'); const name = path[0];
const name = parts[0]; const rest = path.slice(1);
const path = parts.slice(1);
return { _tag: 'Rebind', _0: name, _1: path, _2: value }; return { _tag: 'Rebind', _0: name, _1: rest, _2: value };
}, },
"undefine!": (name: string) => { "undefine!": (name: string) => {
delete store[name]; delete store[name];

Loading…
Cancel
Save