mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-21 13:51:50 +03:00
6cbb6b060d
This reverts commit 8e1e40d75b3ab15c194b6bf9570f3edc46e2de58. This reverts commit f073c490f9fd7c5abc033af4857df92229877de7. This reverts commit f187d2d7e01a54823f3e979af9bbd148b398e7e9. This reverts commit bc272862a73cfce1b118586ca39d3a377d841f1b. This reverts commit 30a397513f8890a3406dc7ab91c6e067e3bbfbbb. This reverts commit 4fc6856fb50d88c20a0f533392ca606641c5f38f. Conflicts: urb/urbit.pill urb/zod/base/lib/drum.hoon
4.2 KiB
4.2 KiB
section 2eK, formatting (layout)
++re
Pretty-printing engine
++ re
|_ tac=tank
Pretty-printing engine.
tac
is a ++tank
.
/~zod/try=> ~(. re leaf/"ham")
<2.ghl [[%leaf ""] <414.gly 100.xkc 1.ypj %164>]>
++ram
Flatten to tape
++ ram
^- tape
?- -.tac
%leaf p.tac
%palm ram(tac [%rose [p.p.tac (weld q.p.tac r.p.tac) s.p.tac] q.tac])
%rose
%+ weld
q.p.tac
|- ^- tape
?~ q.tac
r.p.tac
=+ voz=$(q.tac t.q.tac)
(weld ram(tac i.q.tac) ?~(t.q.tac voz (weld p.p.tac voz)))
==
::
Flatten tank out into a tape.
/~zod/try=> ~(ram re leaf/"foo")
"foo"
/~zod/try=> ~(ram re rose/["." "(" ")"]^~[leaf/"bar" leaf/"baz" leaf/"bam"])
"(bar.baz.bam)"
++win
Render at indent
++ win
|= [tab=@ edg=@]
=+ lug=`wall`~
|^ |- ^- wall
?- -.tac
%leaf (rig p.tac)
%palm
?: fit
(rig ram)
?~ q.tac
(rig q.p.tac)
?~ t.q.tac
(rig(tab (add 2 tab), lug $(tac i.q.tac)) q.p.tac)
=> .(q.tac `(list tank)`q.tac)
=+ lyn=(mul 2 (lent q.tac))
=+ ^= qyr
|- ^- wall
?~ q.tac
lug
%= ^$
tac i.q.tac
tab (add tab (sub lyn 2))
lug $(q.tac t.q.tac, lyn (sub lyn 2))
==
(wig(lug qyr) q.p.tac)
::
%rose
?: fit
(rig ram)
=+ ^= gyl
|- ^- wall
?~ q.tac
?:(=(%$ r.p.tac) lug (rig r.p.tac))
^$(tac i.q.tac, lug $(q.tac t.q.tac), tab din)
?: =(%$ q.p.tac)
gyl
(wig(lug gyl) q.p.tac)
==
::
Render at indent level tab
and width edg
.
tab
and edg
are atoms.
/~zod/try=> (~(win re leaf/"samoltekon-lapdok") 0 20)
<<"samoltekon-lapdok">>
/~zod/try=> (~(win re leaf/"samoltekon-lapdok") 0 10)
<<"\/samolt\/" " ekon-l" " apdok" "\/ \/">>
/~zod/try=> (~(win re rose/["--" "[" "]"]^~[leaf/"1423" leaf/"2316"]) 0 20)
<<"[1423--2316]">>
/~zod/try=> (~(win re rose/["--" "[" "]"]^~[leaf/"1423" leaf/"2316"]) 0 10)
<<"[ 1423" " 2316" "]">>
++din
++ din (mod (add 2 tab) (mul 2 (div edg 3)))
XX document
++fit
Fit on one line test
++ fit (lte (lent ram) (sub edg tab))
Determine whether tac
fits on one line. Internal to ++win
++rig
Wrap in \/
++ rig
|= hom=tape
^- wall
?: (lte (lent hom) (sub edg tab))
[(runt [tab ' '] hom) lug]
=> .(tab (add tab 2), edg (sub edg 2))
=+ mut=(trim (sub edg tab) hom)
:- (runt [(sub tab 2) ' '] ['\\' '/' (weld p.mut `_hom`['\\' '/' ~])])
=> .(hom q.mut)
|-
?~ hom
:- %+ runt
[(sub tab 2) ' ']
['\\' '/' (runt [(sub edg tab) ' '] ['\\' '/' ~])]
lug
=> .(mut (trim (sub edg tab) hom))
[(runt [tab ' '] p.mut) $(hom q.mut)]
::
Wrap tape in \/
if it doesn't fit at current indentation. Internal to
++win
++wig
++win
render tape
++ wig
|= hom=tape
^- wall
?~ lug
(rig hom)
=+ lin=(lent hom)
=+ wug=:(add 1 tab lin)
?. =+ mir=i.lug
|- ?~ mir
|
?|(=(0 wug) ?&(=(' ' i.mir) $(mir t.mir, wug (dec wug))))
(rig hom) :: ^ XX regular form?
[(runt [tab ' '] (weld hom `tape`[' ' (slag wug i.lug)])) t.lug]
--
--
Render tape. Internal to ++win
.