Merge branch 'dillbo' of github.com:urbit/urbit-new into dillbo

This commit is contained in:
Galen Wolfe-Pauly 2015-04-07 13:37:54 -07:00
commit cbb47e0e41
6 changed files with 269 additions and 69 deletions

View File

@ -149,7 +149,7 @@
[%mess p=hasp q=mark r=wire s=json]
[%poll p=@uvH]
[%spur p=spur]
[%subs p=?(%put %delt) q=[p=hasp %json q=path]]
[%subs p=?(%put %delt) q=[hasp %json wire path]]
[%view p=ixor q=[~ u=@ud]]
==
::
@ -468,7 +468,10 @@
=. our ?~(hov our u.hov) :: XX
?- &2.sih
%crud +>.$(mow [[hen %slip %d %flog +.sih] mow])
%dumb (emule |.(~|(%gall-stub !!)))
%dumb
=. +> ?+(tee +> [%of ^] pop-duct:(ire-ix p.tee))
(emule |.(~|(gall-dumb/tee !!)))
::
%went +>.$
%thou
?> ?=([%ay ^] tee)
@ -783,7 +786,8 @@
::
%to
?> =('/' (need-body (ot wire/so ~):jo)) :: XX custom
=- [%mess [- +<]:dir +>.dir / (need-body (ot:jo xyro/some ~))]
=- :^ %mess [- +<]:dir +>.dir
(need-body (ot wire/(cu stab so) xyro/some ~):jo)
^= dir
=+ ful=(read but %p %tas %tas ~)
?^ ful u.ful
@ -805,7 +809,9 @@
?: ((sane %tas) i.but)
$(but [(scot %p our) but])
?> ?=(?(%delt %put) mef)
[%subs mef [(slav %p i.but) (slav %tas -.t.but)] u.p.pok +.t.but]
=+ :- hap=[(slav %p i.but) (slav %tas -.t.but)]
wir=(need-body (ot wire/(cu stab so) ~):jo)
[%subs mef hap u.p.pok wir +.t.but]
::
%auth
:- %auth
@ -876,8 +882,6 @@
[%& %js (add-json (joba %poll (jape polling-url)) poll:js)]
::
%subs
?> =((spud q.q.hem) (trip (need-body (ot wire/so ~):jo)))
:: XX custom wire
?- p.hem
%put [%| ((teba add-subs:for-view) q.hem)]
%delt [%| ((teba del-subs:for-view) q.hem)]
@ -1084,11 +1088,11 @@
(hurl-note [a b] [%g %mess [- + ~]:a him c])
::
++ add-subs
|= [a=hasp %json b=path] ^+ ..ix
(hurl-note [a b] [%g %show [- + ~]:a him b])
|= [a=hasp %json b=wire c=path] ^+ ..ix
(hurl-note [a b] [%g %show [- + ~]:a him c])
::
++ del-subs
|= [a=hasp %json b=path] ^+ ..ix
++ del-subs :: XX per path?
|= [a=hasp %json b=wire c=path] ^+ ..ix
(hurl-note [a b] [%g %nuke [- + ~]:a him])
::
++ get-rush
@ -1101,13 +1105,11 @@
%mean
?~ p.b :: XX actually a yawn-told-full
(get-even %mean [[(slav %p p.a) q.a] r.a] p.b)
=^ ned med ~(get to med)
(mean-json:abet(hen ned) 500 p.b)
(mean-json:pop-duct 500 p.b)
::
%nice
?: =(~ med) ~& resp-lost/ire ..ix
=^ ned med ~(get to med)
(nice-json:abet(hen ned))
(nice-json:pop-duct)
==
::
++ get-even
@ -1137,6 +1139,7 @@
|= a=[p=hasp wire]
(pass-note(hen `~) [%of ire (gsig a)] [%g %took [- + ~]:p.a him])
::
++ pop-duct =^(ned med ~(get to med) abet(hen ned))
++ poll
|= a=@u ^+ ..ix
?: =(a p.eve)

View File

@ -101,11 +101,11 @@
++ nail ,[p=hair q=tape] :: parsing input
++ numb ,@ :: just a number
++ pair |*([a=$+(* *) b=$+(* *)] ,[p=a q=b]) :: just a pair
++ wand |* a=(list $+(* *)) :: hetero list
++ wand |* a=(pole $+(* *)) :: hetero list
|= b=* ::
?~ a ~ ::
?@ b ~ ::
[i=(i.a -.b) t=$(a t.a, b +.b)] ::
[i=(-.a -.b) t=$(a +.a, b +.b)] ::
++ pass ,@ :: public key
++ path (list span) :: filesys location
++ pint ,[p=[p=@ q=@] q=[p=@ q=@]] :: line/column range

View File

@ -105,7 +105,7 @@
:: ::
++ work :: interface action
$% [%number p=? q=@ud] :: activate by number
[%listen p=(set partner)] ::
[%join p=(set partner)] ::
[%say p=speech] ::
[%invite p=span q=(list partner)] ::
[%banish p=span q=(list partner)] ::
@ -215,8 +215,8 @@
==
==
::
%+ stag %listen
;~(pfix (jest %listen) ;~(pfix ace parq))
%+ stag %join
;~(pfix (jest %join) ;~(pfix ace parq))
::
(stag %number nump)
(stag %target parz)
@ -293,17 +293,29 @@
(~(has in sources.shape:(~(got by stories) man.she)) `partner`n.paz)
==
::
++ sh-pass :: update passive aud
++ sh-pass :: passive from aud
|= aud=audience
^+ +>
=+ ^= sap
%- sh-pare
%- ~(gas in *(set partner))
(turn (~(tap by aud)) |=([a=partner *] a))
%- sh-poss
%- ~(gas in *(set partner))
(turn (~(tap by aud)) |=([a=partner *] a))
::
::
++ sh-poss :: passive update
|= lix=(set partner)
=+ sap=(sh-pare lix)
?: =(sap passive.she)
+>.$
sh-prod(passive.she sap)
::
++ sh-pest :: report listen
|= tay=partner
^+ +>
?. ?=(%& -.tay) +>
=+ sib=(~(get by ham.system.she) `station`p.tay)
?. |(?=(~ sib) !?=(%white p.cordon.u.sib))
+>.$
(sh-poss [tay ~ ~])
::
++ sh-rend :: print on one line
|= gam=telegram
(sh-pass:(sh-fact %txt ~(tr-line tr man.she gam)) q.q.gam)
@ -311,13 +323,17 @@
++ sh-numb :: print msg number
|= num=@ud
^+ +>
(sh-fact %txt " [{(scow %ud num)}]")
=+ bun=(scow %ud num)
=+ pad=(sub 36 (lent bun))
=+ now=`@da`(dis lat.hid 0xffff.ffff.ffff.ffff.0000.0000.0000.0000)
%+ sh-fact %txt
"----------------| [{bun}] {(runt [pad ' '] (scow %da now))}"
::
++ sh-repo-house-diff
|= [one=shelf two=shelf]
=| $= ret
$: new=(list (pair span (pair posture cord)))
old=(list (pair span (pair posture cord)))
$: old=(list (pair span (pair posture cord)))
new=(list (pair span (pair posture cord)))
cha=(list (pair span (pair posture cord)))
==
^+ ret
@ -344,8 +360,8 @@
++ sh-repo-atlas-diff
|= [one=atlas two=atlas]
=| $= ret
$: new=(list (pair ship status))
old=(list (pair ship status))
$: old=(list (pair ship status))
new=(list (pair ship status))
cha=(list (pair ship status))
==
^+ ret
@ -372,8 +388,8 @@
++ sh-repo-cabal-diff
|= [one=(map station config) two=(map station config)]
=| $= ret
$: new=(list (pair station config))
old=(list (pair station config))
$: old=(list (pair station config))
new=(list (pair station config))
cha=(list (pair station config))
==
^+ ret
@ -400,8 +416,8 @@
++ sh-repo-rogue-diff
|= [one=(map partner atlas) two=(map partner atlas)]
=| $= ret
$: new=(list (pair partner atlas))
old=(list (pair partner atlas))
$: old=(list (pair partner atlas))
new=(list (pair partner atlas))
cha=(list (pair partner atlas))
==
^+ ret
@ -428,8 +444,8 @@
++ sh-repo-whom-diff
|= [one=(set partner) two=(set partner)]
=| $= ret
$: new=(list partner)
old=(list partner)
$: old=(list partner)
new=(list partner)
==
^+ ret
=. ret
@ -453,8 +469,8 @@
++ sh-repo-ship-diff
|= [one=(set ship) two=(set ship)]
=| $= ret
$: new=(list ship)
old=(list ship)
$: old=(list ship)
new=(list ship)
==
^+ ret
=. ret
@ -538,14 +554,15 @@
::
++ sh-repo-cabal-changes
|= $: laz=(map station config)
new=(list (pair station config))
old=(list (pair station config))
new=(list (pair station config))
cha=(list (pair station config))
==
=. +>.$
|- ^+ +>.^$
?~ new +>.^$
=. +>.^$ $(new t.new)
=. +>.^$ (sh-pest [%& p.i.new])
%+ sh-repo-config-show
(weld ~(sn-phat sn man.she p.i.new) ": ")
[*config q.i.new]
@ -561,13 +578,12 @@
++ sh-repo-cabal
|= bal=cabal
^+ +>
=+ laz=loc.system.she
=. loc.system.she loc.bal
=. +>.$ (sh-repo-config-show "" laz loc.bal)
=+ laz=ham.system.she
=. ham.system.she ham.bal
%+ sh-repo-cabal-changes laz
(sh-repo-cabal-diff laz ham.bal)
=+ laz=system.she
=. system.she bal
=. +>.$
%+ sh-repo-cabal-changes ham.laz
(sh-repo-cabal-diff ham.laz ham.bal)
(sh-repo-config-show "" loc.laz loc.bal)
::
++ sh-repo-house
|= awl=(map span (pair posture cord))
@ -601,7 +617,8 @@
::
++ sh-note :: shell message
|= txt=tape
(sh-fact %txt (runt [16 '-'] `tape`[':' ' ' txt]))
^+ +>
(sh-fact %txt (runt [16 '-'] `tape`['|' ' ' (scag 62 txt)]))
::
++ sh-spaz :: print status
|= saz=status
@ -696,6 +713,7 @@
++ sh-repo :: apply report
|= rad=report
^+ +>
:: ~& [%sh-repo rad]
?- -.rad
%cabal (sh-repo-cabal +.rad)
%grams (sh-repo-grams +.rad)
@ -780,7 +798,7 @@
::
++ sh-tell :: add command
|= cod=command
%_(+> coz [cod coz])
%_(+> coz [cod coz])
::
++ sh-work :: do work
|= job=work
@ -791,7 +809,7 @@
++ work
?- -.job
%number (number +.job)
%listen (listen +.job)
%join (join +.job)
%invite (invite +.job)
%banish (banish +.job)
%create (create +.job)
@ -806,19 +824,20 @@
~& [%activate gam]
sh-prod(active.she `~(tr-pals tr man.she gam))
::
++ listen :: %listen
++ join :: %join
|= lix=(set partner)
^+ +>+>+>
=+ loc=loc.system.she
%^ sh-tell %design man.she
:- ~
=+ tal=(~(tap in lix))
%_ shape.roy
%_ loc
sources
|- ^- (set partner)
?~ tal sources.shape.roy
?: (~(has in sources.shape.roy) i.tal)
$(tal t.tal, sources.shape.roy (~(del in sources.shape.roy) i.tal))
$(tal t.tal, sources.shape.roy (~(put in sources.shape.roy) i.tal))
?~ tal sources.loc
?: (~(has in sources.loc) i.tal)
$(tal t.tal, sources.loc (~(del in sources.loc) i.tal))
$(tal t.tal, sources.loc (~(put in sources.loc) i.tal))
==
::
++ invite :: %invite
@ -836,11 +855,13 @@
^+ +>+>+>
?: (~(has in stories) nom)
(sh-lame "{(trip nom)}: already exists")
%^ sh-tell %design nom
:- ~
:+ *(set partner)
(end 3 62 txt)
[por ~]
=. +>+>+>
%^ sh-tell %design nom
:- ~
:+ *(set partner)
(end 3 62 txt)
[por ~]
(join [[%& our.hid nom] ~ ~])
::
++ target :: %target
|= lix=(set partner)
@ -881,8 +902,16 @@
=+ jub=sh-pork
?~ jub (sh-fact %bel ~)
=. +> (sh-work u.jub)
=+ buf=buf.say.she
=^ cal say.she (~(transmit cs say.she) [%set ~])
(sh-fact %mor [%nex ~] [%det cal] ~)
%- sh-fact
:* %mor
[%nex ~]
[%det cal]
?. ?=([%';' *] buf) ~
:_ ~
[%txt (weld "----------------| " (tufa buf))]
==
::
++ sh-sole :: apply edit
|= act=sole-action
@ -898,7 +927,22 @@
--
++ ra-abed :: resolve core
^- [(list move) _+>]
[(flop moves) +>]
:_ +>
=+ ^= yop
|- ^- (pair (list move) (list sole-effect))
?~ moves [~ ~]
=+ mor=$(moves t.moves)
?: ?& =(ost p.i.moves)
?=([%give %rush %sole-effect *] q.i.moves)
==
[p.mor [+>+.q.i.moves q.mor]]
[[i.moves p.mor] q.mor]
=+ :* moz=(flop p.yop)
^= foc ^- (unit sole-effect)
?~ q.yop ~
?~(t.q.yop `i.q.yop `[%mor (flop `(list sole-effect)`q.yop)])
==
?~(foc moz [[ost %give %rush %sole-effect u.foc] moz])
::
++ ra-abet :: complete core
ra-abed:ra-axel
@ -917,6 +961,7 @@
[p.mor [[p.i.moves +>+.q.i.moves] q.mor]]
=. moves p.rey
?: =(q.rey ~) +
=. q.rey (flop q.rey)
|- ^+ +>
?~ q.rey ra-axel
$(q.rey t.q.rey, +> (ra-back(ost p.i.q.rey) q.i.q.rey))
@ -929,6 +974,10 @@
++ ra-sole
|= act=sole-action
^+ +>
=+ shu=(~(get by shells) ost)
?~ shu
~& [%ra-console-broken ost]
+>.$
sh-abet:(~(sh-sole sh ~ (~(got by shells) ost)) act)
::
++ ra-emil :: ra-emit move list
@ -1036,6 +1085,7 @@
++ ra-cancel :: drop a bone
^+ .
=+ hep=(~(get by sup.hid) ost)
~& [%ra-cancel hep]
?~ hep +
?. ?=([@ @ *] q.u.hep)
+(general (~(del in general) ost))
@ -1232,8 +1282,8 @@
::
[%g %mean *]
?~ +>.sih
?. (~(has in sources.shape) tay) +>.$ :: XX hack for odd mean
(pa-acquire [tay ~])
~& [%pa-friend-mean +>.sih]
pa-monitor(sources.shape (~(del in sources.shape) tay))
::
[%g %rush %twit-feed *]
@ -1290,7 +1340,7 @@
:: ==
::
%& ~& [%pa-abjure [our.hid man] [p.p.tay q.p.tay]]
:~ :- /friend/nuke/[man]/(scot %p p.p.tay)/[q.p.tay]
:~ :- /friend/show/[man]/(scot %p p.p.tay)/[q.p.tay]
[%g %nuke [p.p.tay /talk] our.hid]
==
==
@ -1311,7 +1361,7 @@
::
%& :: ~& [%pa-acquire [our.hid man] [p.p.tay q.p.tay]]
:~ :- /friend/show/[man]/(scot %p p.p.tay)/[q.p.tay]
[%g %show [p.p.tay /talk] our.hid /af/[q.p.tay]/(scot %ud num)]
[%g %show [p.p.tay /talk] our.hid /afx/[q.p.tay]/(scot %ud num)]
==
==
::
@ -1644,7 +1694,7 @@
=+ oug==(who our.hid)
=+ txt=(tr-text oug)
?: =(~ txt) ""
=+ eck=?:((~(has by aud) [%& our.hid man]) '#' '-')
=+ eck=?:((~(has by aud) [%& our.hid man]) '*' '-')
=+ heb=?:(oug '>' '<')
=+ ^= baw
?: oug
@ -1667,7 +1717,7 @@
(weld ": " txt)
?: oug
(weld "@ " txt)
(weld " " txt)
(weld " " txt)
==
--
::
@ -1730,8 +1780,8 @@
|= ost=bone
^- [(list move) _+>]
:: ~& [%talk-pull `*`ost]
=. shells (~(del by shells) ost)
ra-abet:ra-ever:~(ra-cancel ra ost ~)
=^ moz +>.$ ra-abet:ra-ever:~(ra-cancel ra ost ~)
[moz +>.$(shells (~(del by shells) ost))]
::
++ poke-bit
|= [ost=bone you=ship ~]

142
main/lib/console/core.hook Normal file
View File

@ -0,0 +1,142 @@
::
:::: /hook/core/console/lib
::
:: This file is in the public domain.
::
/? 310
/- *console
!:
::::
::
|%
++ cs :: shared-state engine
|_ console-share
++ abet +<
++ apply
|= ted=console-edit
^+ +>
?- -.ted
%del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf)))
%ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted (slag p.ted buf)]))
%mor |- ^+ +>.^$
?~ p.ted
+>.^$
$(p.ted t.p.ted, +>.^$ ^$(ted i.p.ted))
%nop +>.$
%set +>.$(buf p.ted)
==
::
::::
:: ++transmute: symmetric operational transformation.
::
:: for any console state +>, obeys
::
:: =+ [x=(transmute a b) y=(transmute b a)]
:: .= (apply:(apply b) x)
:: (apply:(apply a) y)
::
++ transmute :: dex as after sin
|= [sin=console-edit dex=console-edit]
^- console-edit
?: ?=(%mor -.sin)
|- ^- console-edit
?~ p.sin dex
$(p.sin t.p.sin, dex ^$(sin i.p.sin))
::
?: ?=(%mor -.dex)
:- %mor
|- ^- (list console-edit)
?~ p.dex ~
[^$(dex i.p.dex) $(p.dex t.p.dex)]
::
?: |(?=(%nop -.sin) ?=(%nop -.dex)) dex
?: ?=(%set -.sin) [%nop ~]
?: ?=(%set -.dex) dex
::
?- -.sin
%del
?- -.dex
%del ?: =(p.sin p.dex) [%nop ~]
?:((lth p.sin p.dex) dex(p (dec p.dex)) dex)
%ins ?:((lte p.sin p.dex) dex(p (dec p.dex)) dex)
==
::
%ins
?- -.dex
%del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
%ins ?: =(p.sin p.dex)
?:((gth q.sin q.dex) dex dex(p +(p.dex)))
?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
==
==
::
++ commit :: local change
|= ted=console-edit
^- console-share
abet:(apply(own.ven +(own.ven), leg [ted leg]) ted)
::
::::
:: ++inverse: inverse of change in context.
::
:: for any console state +>, obeys
::
:: =(+> (apply:(apply a) (inverse a)))
::
++ inverse :: relative inverse
|= ted=console-edit
^- console-edit
=. ted ?.(?=([%mor * ~] ted) ted i.p.ted)
?- -.ted
%del [%ins p.ted (snag p.ted buf)]
%ins [%del p.ted]
%mor :- %mor
%- flop
|- ^- (list console-edit)
?~ p.ted ~
:- ^$(ted i.p.ted)
$(p.ted t.p.ted, +>.^$ (apply i.p.ted))
%nop [%nop ~]
%set [%set buf]
==
::
++ receive :: naturalize event
|= console-change
^- [console-edit console-share]
?> &(=(his.ler his.ven) (lte own.ler own.ven))
?> &(=(his.ler his.ven) (lte own.ler own.ven))
?> |(!=(own.ler own.ven) =(haw (sham buf)))
=. leg (scag (sub own.ven own.ler) leg)
:: ~? !=(own.ler own.ven) [%miss-leg leg]
=+ dat=(transmute [%mor leg] ted)
:: ~? !=(~ leg) [%transmute from/ted to/dat ~]
[dat abet:(apply(his.ven +(his.ven)) dat)]
::
++ remit :: conditional accept
|= [cal=console-change ask=$+((list ,@c) ?)]
^- [(unit console-change) console-share]
=+ old=buf
=^ dat +>+<.$ (receive cal)
?: (ask buf)
[~ +>+<.$]
=^ lic +>+<.$ (transmit (inverse(buf old) dat))
[`lic +>+<.$]
::
++ transmit :: outgoing change
|= ted=console-edit
^- [console-change console-share]
[[[his.ven own.ven] (sham buf) ted] (commit ted)]
::
++ transceive :: receive and invert
|= console-change
^- [console-edit console-share]
=+ old=buf
=^ dat +>+<.$ (receive +<.$)
[(inverse(buf old) dat) +>+<.$]
::
++ transpose :: adjust position
|= pos=@ud
=+ dat=(transmute [%mor leg] [%ins pos `@c`0])
?> ?=(%ins -.dat)
p.dat
--
--

3
main/lib/shu/core.hook Normal file
View File

@ -0,0 +1,3 @@
:: Alias
/+ sh-utils
.

View File

@ -103,6 +103,8 @@ window.urb.poll = function(params) {
return document.location.reload() // XX check autoreload
case "rush":
case "mean":
if(res.data.type == "mean")
err = res.data.data
var fn = $this.gsig(res.data.from)
if($this.cabs[fn])
$this.cabs[fn].call(this,err,