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 3 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 {
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
| [] \ []

@ -1,4 +1,4 @@
myFontBackup = { glyphs = {
myFontBackup = { glyphs = {
"0" = {
w = 7,
h = 12,
@ -787,7 +787,7 @@
}
]
},
"A" = {
A = {
w = 7,
h = 12,
map = [
@ -873,7 +873,7 @@
}
]
},
"B" = {
B = {
w = 7,
h = 12,
map = [
@ -979,7 +979,7 @@
}
]
},
"C" = {
C = {
w = 7,
h = 12,
map = [
@ -1049,7 +1049,7 @@
}
]
},
"D" = {
D = {
w = 7,
h = 12,
map = [
@ -1139,7 +1139,7 @@
}
]
},
"E" = {
E = {
w = 7,
h = 12,
map = [
@ -1237,7 +1237,7 @@
}
]
},
"F" = {
F = {
w = 6,
h = 12,
map = [
@ -1307,7 +1307,7 @@
}
]
},
"G" = {
G = {
w = 7,
h = 12,
map = [
@ -1397,7 +1397,7 @@
}
]
},
"H" = {
H = {
w = 6,
h = 12,
map = [
@ -1475,7 +1475,7 @@
}
]
},
"I" = {
I = {
w = 7,
h = 12,
map = [
@ -1541,7 +1541,7 @@
}
]
},
"J" = {
J = {
w = 7,
h = 12,
map = [
@ -1603,7 +1603,7 @@
}
]
},
"K" = {
K = {
w = 7,
h = 12,
map = [
@ -1665,7 +1665,7 @@
}
]
},
"L" = {
L = {
w = 7,
h = 12,
map = [
@ -1715,7 +1715,7 @@
}
]
},
"M" = {
M = {
w = 7,
h = 12,
map = [
@ -1797,7 +1797,7 @@
}
]
},
"N" = {
N = {
w = 7,
h = 12,
map = [
@ -1879,7 +1879,7 @@
}
]
},
"O" = {
O = {
w = 7,
h = 12,
map = [
@ -1965,7 +1965,7 @@
}
]
},
"P" = {
P = {
w = 7,
h = 12,
map = [
@ -2047,7 +2047,7 @@
}
]
},
"Q" = {
Q = {
w = 7,
h = 12,
map = [
@ -2145,7 +2145,7 @@
}
]
},
"R" = {
R = {
w = 7,
h = 12,
map = [
@ -2239,7 +2239,7 @@
}
]
},
"S" = {
S = {
w = 7,
h = 12,
map = [
@ -2329,7 +2329,7 @@
}
]
},
"T" = {
T = {
w = 7,
h = 12,
map = [
@ -2387,7 +2387,7 @@
}
]
},
"U" = {
U = {
w = 7,
h = 12,
map = [
@ -2461,7 +2461,7 @@
}
]
},
"V" = {
V = {
w = 7,
h = 12,
map = [
@ -2519,7 +2519,7 @@
}
]
},
"W" = {
W = {
w = 7,
h = 12,
map = [
@ -2601,7 +2601,7 @@
}
]
},
"X" = {
X = {
w = 7,
h = 12,
map = [
@ -2659,7 +2659,7 @@
}
]
},
"Y" = {
Y = {
w = 7,
h = 12,
map = [
@ -2705,7 +2705,7 @@
}
]
},
"Z" = {
Z = {
w = 7,
h = 12,
map = [
@ -5512,5 +5512,326 @@
y = 5
}
]
},
"|" = {
w = 7,
h = 12,
map = [
{
x = 3,
y = 2
},
{
x = 3,
y = 3
},
{
x = 3,
y = 4
},
{
x = 3,
y = 5
},
{
x = 3,
y = 6
},
{
x = 3,
y = 7
},
{
x = 3,
y = 8
}
]
},
"~" = {
w = 7,
h = 12,
map = [
{
x = 0,
y = 5
},
{
x = 1,
y = 4
},
{
x = 2,
y = 4
},
{
x = 3,
y = 5
},
{
x = 4,
y = 6
},
{
x = 5,
y = 6
},
{
x = 6,
y = 5
}
]
},
"`" = {
w = 7,
h = 12,
map = [
{
x = 2,
y = 3
},
{
x = 3,
y = 4
},
{
x = 4,
y = 5
}
]
},
"-" = {
w = 7,
h = 12,
map = [
{
x = 1,
y = 5
},
{
x = 2,
y = 5
},
{
x = 3,
y = 5
},
{
x = 4,
y = 5
},
{
x = 5,
y = 5
}
]
},
"_" = {
w = 7,
h = 12,
map = [
{
x = 1,
y = 8
},
{
x = 2,
y = 8
},
{
x = 3,
y = 8
},
{
x = 4,
y = 8
},
{
x = 5,
y = 8
}
]
},
"'" = {
w = 7,
h = 12,
map = [
{
x = 3,
y = 2
},
{
x = 3,
y = 3
},
{
x = 3,
y = 4
}
]
},
"\"" = {
w = 7,
h = 12,
map = [
{
x = 2,
y = 2
},
{
x = 2,
y = 3
},
{
x = 2,
y = 4
},
{
x = 4,
y = 2
},
{
x = 4,
y = 3
},
{
x = 4,
y = 4
}
]
},
"," = {
w = 7,
h = 12,
map = [
{
x = 4,
y = 6
},
{
x = 4,
y = 7
},
{
x = 3,
y = 8
}
]
},
"." = {
w = 7,
h = 12,
map = [{
x = 3,
y = 8
}]
},
"<" = {
w = 7,
h = 12,
map = [
{
x = 4,
y = 2
},
{
x = 3,
y = 3
},
{
x = 2,
y = 4
},
{
x = 1,
y = 5
},
{
x = 2,
y = 6
},
{
x = 3,
y = 7
},
{
x = 4,
y = 8
}
]
},
">" = {
w = 7,
h = 12,
map = [
{
x = 2,
y = 2
},
{
x = 3,
y = 3
},
{
x = 4,
y = 4
},
{
x = 5,
y = 5
},
{
x = 4,
y = 6
},
{
x = 3,
y = 7
},
{
x = 2,
y = 8
}
]
},
":" = {
w = 7,
h = 12,
map = [
{
x = 3,
y = 7
},
{
x = 3,
y = 4
}
]
},
";" = {
w = 7,
h = 12,
map = [
{
x = 3,
y = 3
},
{
x = 3,
y = 6
},
{
x = 2,
y = 8
},
{
x = 3,
y = 7
}
]
},
" " = {
w = 7,
h = 12,
map = []
}
} };
} };

@ -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…
Cancel
Save