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'
This commit is contained in:
parent
515ad7fc9c
commit
6fe94ddfb2
6 changed files with 5859 additions and 5537 deletions
|
|
@ -309,5 +309,5 @@ function prettyPrintPattern(pattern: Pattern): string {
|
|||
}
|
||||
|
||||
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 = _, 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 = f l1 l2 \ l1
|
||||
| [] \ []
|
||||
|
|
|
|||
11353
src/cg/06-font.cg
11353
src/cg/06-font.cg
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
fontEditor = config \
|
||||
defaults = {
|
||||
path = "newFont"
|
||||
path = ["newFont"]
|
||||
};
|
||||
|
||||
c = { ...defaults, ...config };
|
||||
|
|
@ -13,13 +13,13 @@ fontEditor = config \
|
|||
view = ctx \
|
||||
editGlyph = path \
|
||||
app = pixelEditor { path = path };
|
||||
ctx.openApp path app.view app.width;
|
||||
ctx.openApp (join "." path) app.view app.width;
|
||||
|
||||
ui.stateful {
|
||||
focusable = True,
|
||||
autoFocus = True,
|
||||
|
||||
key = "fontEditor-" & c.path,
|
||||
key = "fontEditor-" & (join "." c.path),
|
||||
|
||||
init = existing
|
||||
| Some v \ {
|
||||
|
|
@ -62,7 +62,7 @@ fontEditor = config \
|
|||
x = floor ((tileSize - glyph.w * scale) / 2);
|
||||
|
||||
ui.clickable {
|
||||
onClick = \ editGlyph (c.path & ".glyphs." & key),
|
||||
onClick = \ editGlyph [...c.path, "glyphs", key],
|
||||
child = ui.stack {
|
||||
children = [
|
||||
ui.rect { w = tileSize, h = tileSize, strokeWidth = 1, strokeColor = "#fff" },
|
||||
|
|
@ -84,7 +84,7 @@ fontEditor = config \
|
|||
h = headerHeight,
|
||||
key = "new-glyph-button",
|
||||
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 });
|
||||
|
||||
existing = getAt c.path;
|
||||
_ = debug! "existing" existing;
|
||||
|
||||
# return App
|
||||
{
|
||||
|
|
@ -46,7 +45,7 @@ pixelEditor = config \
|
|||
focusable = True,
|
||||
autoFocus = True,
|
||||
|
||||
key = "pixelEditor-" & c.path,
|
||||
key = "pixelEditor-" & (join "." c.path),
|
||||
|
||||
init = existing
|
||||
| Some v \ {
|
||||
|
|
@ -117,8 +116,6 @@ pixelEditor = config \
|
|||
gap = 10,
|
||||
|
||||
children = [
|
||||
ui.positioned { x = 0, y = 8, child = ui.text { content = c.path, color = "#fff" } },
|
||||
|
||||
textInput {
|
||||
key = "width-input",
|
||||
w = 40,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export const _rt = {
|
|||
return String(value);
|
||||
},
|
||||
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),
|
||||
slice: (s: string | any[]) => (start: number) => (end: number) => s.slice(start, end),
|
||||
"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')
|
||||
.sort((a, b) => a.length - b.length);
|
||||
},
|
||||
getAt: (pathStr: string) => {
|
||||
const parts = pathStr.split('.');
|
||||
let obj: any = store[parts[0]];
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
getAt: (path: any[]) => {
|
||||
let obj: any = store[path[0]];
|
||||
for (let i = 1; i < path.length; i++) {
|
||||
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 };
|
||||
},
|
||||
|
|
@ -155,12 +154,11 @@ export const _rt = {
|
|||
}
|
||||
syncToAst(name);
|
||||
},
|
||||
rebindAt: (pathStr: string) => (value: string) => {
|
||||
const parts = pathStr.split('.');
|
||||
const name = parts[0];
|
||||
const path = parts.slice(1);
|
||||
rebindAt: (path: any[]) => (value: any) => {
|
||||
const name = path[0];
|
||||
const rest = path.slice(1);
|
||||
|
||||
return { _tag: 'Rebind', _0: name, _1: path, _2: value };
|
||||
return { _tag: 'Rebind', _0: name, _1: rest, _2: value };
|
||||
},
|
||||
"undefine!": (name: string) => {
|
||||
delete store[name];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue