Fixing bugs. escaping things when pretty printing. adding reflect host function. getting further with tree view
parent
f27b946790
commit
fec18486d8
@ -0,0 +1,46 @@
|
||||
tree = config \
|
||||
depth = config.depth;
|
||||
indent = depth * 20;
|
||||
|
||||
simple = content color \
|
||||
ui.positioned { x = indent, y = 0,
|
||||
child = ui.text { content = content, color = color }
|
||||
};
|
||||
|
||||
valueLabel = value \ value
|
||||
| NumberValue n \ Some (show n)
|
||||
| StringValue n \ Some ("\"" & n & "\"")
|
||||
| ConstructorValue { tag = tag } \ Some tag
|
||||
| FunctionValue _ \ Some "<fn>"
|
||||
| _ \ None;
|
||||
|
||||
config.value
|
||||
| NumberValue n \ simple (show n) "#6cf"
|
||||
| StringValue n \ simple ("\"" & n & "\"") "#f6a"
|
||||
| ConstructorValue { tag = tag } \ simple tag "#fc6"
|
||||
| FunctionValue _ \ simple "<fn>" "#888"
|
||||
| RecordValue entries \
|
||||
ui.column {
|
||||
gap = 0,
|
||||
children = map (entry \
|
||||
(valueLabel entry.value)
|
||||
| Some label \ simple (entry.key & " = " & label) "#aaa"
|
||||
| None \ ui.column { gap = 0, children = [
|
||||
simple entry.key "#aaa",
|
||||
tree { value = entry.value, depth = depth + 1 }
|
||||
]}
|
||||
) entries
|
||||
}
|
||||
| ListValue items \
|
||||
ui.column {
|
||||
gap = 0,
|
||||
children = mapWithIndex (item i \
|
||||
(valueLabel item)
|
||||
| Some label \ simple ((show i) & ": " & label) "#aaa"
|
||||
| None \ ui.column { gap = 0, children = [
|
||||
simple (show i) "#aaa",
|
||||
tree { value = item, depth = depth + 1 }
|
||||
]}
|
||||
) items
|
||||
}
|
||||
| _ \ ui.text { content = "?", color = "#666" };
|
||||
Loading…
Reference in New Issue