mirror of
https://github.com/urbit/shrub.git
synced 2025-01-05 02:57:18 +03:00
Merge branch 'factor' of https://github.com/ohaitch/urbit into factor
Conflicts:
urb/zod/web/tree/main.js
Tree@fbcdee088d
This commit is contained in:
commit
7c9a506b84
@ -441,19 +441,26 @@
|
||||
++ etag
|
||||
'''
|
||||
if(!window.urb) window.urb = {}
|
||||
urb.waspFrom = function(sel,attr){
|
||||
Array.prototype.map.call(document.querySelectorAll(sel),
|
||||
function(ele){
|
||||
if(!ele[attr] || (new URL(ele[attr])).host != document.location.host)
|
||||
return;
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open("HEAD", ele[attr])
|
||||
xhr.send()
|
||||
xhr.onload = function(){
|
||||
var dep = this.getResponseHeader("etag")
|
||||
if(dep) urb.wasp(JSON.parse(dep.substr(2)))
|
||||
}})}
|
||||
if(urb.wasp){urb.waspFrom('script','src'); urb.waspFrom('link','href')}
|
||||
urb.waspAll = function(sel){
|
||||
Array.prototype.map.call(document.querySelectorAll(sel), urb.waspElem)
|
||||
}
|
||||
urb.waspElem = function(ele){
|
||||
url = ele.src || ele.href
|
||||
if(!url || (new URL(url)).host != document.location.host)
|
||||
return;
|
||||
urb.waspUrl(url)
|
||||
}
|
||||
urb.waspUrl = function(url){
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open("HEAD", url)
|
||||
xhr.send()
|
||||
xhr.onload = urb.waspLoadedXHR
|
||||
}
|
||||
urb.waspLoadedXHR = function(){
|
||||
var dep = this.getResponseHeader("etag")
|
||||
if(dep) urb.wasp(JSON.parse(dep.substr(2)))
|
||||
}
|
||||
if(urb.wasp){urb.waspAll('script'); urb.waspAll('link')}
|
||||
'''
|
||||
--
|
||||
++ xml
|
||||
|
@ -677,10 +677,10 @@
|
||||
(stag %fan ;~(pfix dot fan:read))
|
||||
(stag %for ;~(pfix com for:read))
|
||||
(stag %hel ;~(pfix cen day:read))
|
||||
(stag %hub ;~(pfix pat day:read))
|
||||
(stag %lin ;~(pfix pam lin:read))
|
||||
(stag %man ;~(pfix tar man:read))
|
||||
(stag %nap ;~(pfix cab day:read))
|
||||
(stag %now ;~(pfix pam day:read))
|
||||
(stag %now ;~(pfix pat day:read))
|
||||
(stag %saw ;~(pfix sem saw:read))
|
||||
(stag %see ;~(pfix col see:read))
|
||||
(stag %sic ;~(pfix ket sic:read))
|
||||
@ -721,6 +721,12 @@
|
||||
%+ rail fail
|
||||
=- ;~(sfix (star -) gap duz)
|
||||
;~(pfix gap fas ;~(plug hath day))
|
||||
::
|
||||
++ lin
|
||||
%+ rail
|
||||
;~(plug (plus ;~(sfix sym pam)) day)
|
||||
=+ (cook |=(a=term [a ~]) sym)
|
||||
;~(pfix gap ;~(plug - day))
|
||||
::
|
||||
++ man
|
||||
%+ rail fail
|
||||
@ -1343,7 +1349,7 @@
|
||||
%+ cope (maim cof pit able)
|
||||
|= [cof=cafe bax=vase]
|
||||
%+ cope (chap cof bax [%fan fan.hyd])
|
||||
|= [cof=cafe gox=vase]
|
||||
|= [cof=cafe mar=mark gox=vase]
|
||||
%+ cope (maim cof (slop gox bax) [%tssg (flop boy)])
|
||||
|= [cof=cafe fin=vase]
|
||||
(fine cof fin)
|
||||
@ -1384,7 +1390,7 @@
|
||||
%+ cope $(poy t.poy)
|
||||
|= [cof=cafe nex=(list (pair ,@ vase))]
|
||||
%+ cope (chap(s.how [p.i.poy s.how]) cof bax hon)
|
||||
(flux |=(elt=vase [[q.i.poy elt] nex]))
|
||||
(flux |=([mar=mark elt=vase] [[q.i.poy elt] nex]))
|
||||
%- flux
|
||||
|= yal=(list (pair ,@ vase)) ^- vase
|
||||
?~ yal [[%cube 0 [%atom %n]] 0]
|
||||
@ -1402,40 +1408,42 @@
|
||||
(flue cof)
|
||||
(cope nod (flux some))
|
||||
%- flux
|
||||
|= doy=(map ,@ vase) ^- vase
|
||||
|= doy=(map ,@ cage) ^- vase
|
||||
?~ doy [[%cube 0 [%atom %n]] 0]
|
||||
%+ slop
|
||||
(slop [[%atom %ta] p.n.doy] q.n.doy)
|
||||
(slop [[%atom %ta] p.n.doy] q.q.n.doy)
|
||||
(slop $(doy l.doy) $(doy r.doy))
|
||||
::
|
||||
++ chap :: produce resources
|
||||
|= [cof=cafe bax=vase hon=horn]
|
||||
^- (bolt vase)
|
||||
^- (bolt cage)
|
||||
?- -.hon
|
||||
%ape (maim cof bax p.hon)
|
||||
%ape (cope (maim cof bax p.hon) (flux |=(a=vase [%noun a])))
|
||||
%arg
|
||||
%+ cope (maim cof bax p.hon)
|
||||
|= [cof=cafe gat=vase]
|
||||
%+ cope (maim cof !>(~) ((jock |) arg))
|
||||
|= [cof=cafe val=vase]
|
||||
(maul cof gat (slop !>(how) val))
|
||||
%+ cope (maul cof gat (slop !>(how) val))
|
||||
(flux |=(a=vase noun/a))
|
||||
::
|
||||
%alt
|
||||
%. cof
|
||||
|= cof=cafe ^- (bolt vase)
|
||||
|= cof=cafe ^- (bolt cage)
|
||||
?~ p.hon (flaw cof leaf/"ford: out of options" ~)
|
||||
(coop ^$(cof cof, hon i.p.hon) ..$(p.hon t.p.hon))
|
||||
::
|
||||
%dub
|
||||
%+ cope $(hon q.hon)
|
||||
(flux |=(vax=vase [[%face p.hon p.vax] q.vax]))
|
||||
(flux |=([mar=mark vax=vase] [mar [%face p.hon p.vax] q.vax]))
|
||||
::
|
||||
%fan
|
||||
%- cope :_ (flux |=(a=vase noun/a))
|
||||
%+ cope
|
||||
|- ^- (bolt (list vase))
|
||||
?~ p.hon (flue cof)
|
||||
%+ cope ^$(cof cof, hon i.p.hon)
|
||||
|= [cof=cafe vax=vase]
|
||||
|= [cof=cafe mar=mark vax=vase]
|
||||
%+ cope ^$(cof cof, p.hon t.p.hon)
|
||||
(flux |=(tev=(list vase) [vax tev]))
|
||||
|= [cof=cafe tev=(list vase)]
|
||||
@ -1446,15 +1454,23 @@
|
||||
::
|
||||
%for
|
||||
=+ opt=|.(>(turn p.hon |=([a=path ^] a))<)
|
||||
|- ^- (bolt vase)
|
||||
|- ^- (bolt cage)
|
||||
?~ p.hon (flaw cof leaf/"ford: no match" >(tope how)< *opt ~)
|
||||
?: =(p.i.p.hon (scag (lent p.i.p.hon) (flop s.how)))
|
||||
^$(hon q.i.p.hon)
|
||||
$(p.hon t.p.hon)
|
||||
::
|
||||
%hel $(hon p.hon, lit |)
|
||||
%hub (chad cof bax %ud p.hon)
|
||||
%lin
|
||||
%+ cope $(hon q.hon)
|
||||
|= [cof=cafe cay=cage] ^- (bolt cage)
|
||||
?~ p.hon (fine cof cay)
|
||||
%+ cope $(p.hon t.p.hon)
|
||||
|= [cof=cafe cay=cage]
|
||||
(cope (make cof %cast i.p.hon `cay) furl)
|
||||
::
|
||||
%man
|
||||
%- cope :_ (flux |=(a=vase noun/a))
|
||||
|- ^- (bolt vase)
|
||||
?~ p.hon (fine cof [[%cube 0 [%atom %n]] 0])
|
||||
%+ cope $(p.hon l.p.hon)
|
||||
@ -1462,42 +1478,50 @@
|
||||
%+ cope ^$(cof cof, p.hon r.p.hon)
|
||||
|= [cof=cafe rig=vase]
|
||||
%+ cope ^^^$(cof cof, hon q.n.p.hon)
|
||||
|= [cof=cafe vax=vase]
|
||||
|= [cof=cafe mar=mark vax=vase]
|
||||
%+ fine cof
|
||||
%+ slop
|
||||
(slop [[%atom %tas] p.n.p.hon] vax)
|
||||
(slop lef rig)
|
||||
::
|
||||
%now (chad cof bax %da p.hon)
|
||||
%nap (chai cof bax p.hon)
|
||||
%now
|
||||
%+ cope (chad cof bax %da p.hon)
|
||||
(flux |=(a=vase noun/a))
|
||||
::
|
||||
%nap
|
||||
%+ cope (chai cof bax p.hon)
|
||||
(flux |=(a=vase noun/a))
|
||||
::
|
||||
%saw
|
||||
%+ cope $(hon q.hon)
|
||||
|= [cof=cafe mar=mark sam=vase]
|
||||
%+ cope (maim cof bax p.hon)
|
||||
|= [cof=cafe gat=vase]
|
||||
%+ cope (maul cof gat sam)
|
||||
(flux |=(a=vase noun/a))
|
||||
::
|
||||
%see
|
||||
=. r.p.hon ?:(?=([%ud 0] r.p.hon) r.how r.p.hon)
|
||||
$(hon q.hon, how p.hon)
|
||||
::
|
||||
%saw
|
||||
%+ cope $(hon q.hon)
|
||||
|= [cof=cafe sam=vase]
|
||||
%+ cope (maim cof bax p.hon)
|
||||
|= [cof=cafe gat=vase]
|
||||
(maul cof gat sam)
|
||||
::
|
||||
%sic
|
||||
%+ cope $(hon q.hon)
|
||||
|= [cof=cafe vax=vase]
|
||||
|= [cof=cafe mar=mark vax=vase]
|
||||
%+ cope (maim cof bax [%bctr p.hon])
|
||||
|= [cof=cafe tug=vase]
|
||||
?. (~(nest ut p.tug) | p.vax)
|
||||
(flaw cof [%leaf "type error: {<p.hon>} {<q.hon>}"]~)
|
||||
(fine cof [p.tug q.vax])
|
||||
(fine cof [mar p.tug q.vax])
|
||||
::
|
||||
%toy
|
||||
?: p.hon
|
||||
=. arg ?.(lit arg many/~)
|
||||
(cope (cope (make cof %bake q.hon arg how) furl) feel)
|
||||
(cope (make cof %bake q.hon arg how) furl)
|
||||
%+ cool |.(leaf/"ford: hook {<q.hon>} {<(tope how)>}")
|
||||
%+ cope (fade cof %hoon how)
|
||||
|= [cof=cafe hyd=hood]
|
||||
(cope (abut:(meow how arg) cof hyd) (lake q.hon))
|
||||
%+ cope (abut:(meow how arg) cof hyd)
|
||||
;~(cope (lake q.hon) (flux |=(a=vase [q.hon a])))
|
||||
==
|
||||
::
|
||||
++ head :: consume structures
|
||||
|
@ -2493,15 +2493,14 @@
|
||||
$% [%ape p=twig] :: /~ twig by hand
|
||||
[%arg p=twig] :: /$ argument
|
||||
[%alt p=(list horn)] :: /| options
|
||||
:: [%day p=horn] :: list by @dr
|
||||
[%dub p=term q=horn] :: /= apply face
|
||||
[%fan p=(list horn)] :: /. list
|
||||
[%for p=(list (pair path:spur horn))] :: /, switch by path
|
||||
[%hel p=horn] :: /% propagate args
|
||||
[%hub p=horn] :: /@ list by @ud
|
||||
[%lin p=(list mark) q=horn] :: /& translates
|
||||
[%man p=(map span horn)] :: /* hetero map
|
||||
[%nap p=horn] :: /_ homo map
|
||||
[%now p=horn] :: /& list by @da
|
||||
[%now p=horn] :: /@ list by @da
|
||||
[%saw p=twig q=horn] :: /; operate on
|
||||
[%see p=beam q=horn] :: /: relative to
|
||||
[%sic p=tile q=horn] :: /^ cast
|
||||
|
@ -1,64 +1,38 @@
|
||||
/- tree-include
|
||||
!:
|
||||
|%
|
||||
++ extract
|
||||
|= a=marl ^- tape
|
||||
?~ a ~
|
||||
%- weld :_ $(a t.a)
|
||||
?. ?=(_:/(**) i.a)
|
||||
$(a c.i.a)
|
||||
v.i.a.g.i.a
|
||||
::
|
||||
++ getall
|
||||
++ getall :: search in manx
|
||||
|= tag=(list mane)
|
||||
|= ele=manx ^- marl
|
||||
?: (lien tag |=(a=mane =(a n.g.ele)))
|
||||
~[ele]
|
||||
(zing (turn c.ele ..$))
|
||||
++ baff |*([a=(unit) b=(trap)] ?^(a a *b))
|
||||
++ find-in-tree
|
||||
|* [paz=fist:jo fun=$+(* (unit))]
|
||||
|= jon=json
|
||||
=+ a=`(list json)`~[jon]
|
||||
|^ (try)
|
||||
++ try
|
||||
|. ^+ *fun
|
||||
?~ a ~
|
||||
%+ biff (paz i.a)
|
||||
|* [b=(list json) c=*] ^+ *fun
|
||||
(baff (baff (fun c) try(a b)) try(a t.a))
|
||||
--
|
||||
::
|
||||
++ map-to-json
|
||||
++ map-to-json :: hoon data to json
|
||||
|* [a=$+(* cord) b=$+(* json)]
|
||||
|* c=(map) ^- json
|
||||
|* c=(map) ^- json :: XX c=(map _+<.a _+<.b)
|
||||
~! c
|
||||
(jobe (turn (~(tap by c)) |*([k=* v=*] [(a k) (b v)])))
|
||||
::
|
||||
++ json-front
|
||||
|= a=json ^- json
|
||||
=- (fall `(unit json)`- ~)
|
||||
%. a
|
||||
%+ find-in-tree (ot c/(ar some) gn/so ga/(om so) ~):jo
|
||||
|= [nom=span atr=(map span cord)] ^- (unit json)
|
||||
?. (~(has by atr) 'urb:front') ~
|
||||
?> ?=(%meta nom)
|
||||
(biff (~(get by atr) %value) poja)
|
||||
::
|
||||
++ read-schem
|
||||
=< (cook to-noun (cook to-tree apex))
|
||||
:: a.b_c.d => [[%a %b] [%c %d]]
|
||||
:: a.b_c, a_b__c => [[%a %b] %c]
|
||||
:: a_b_c, a__b_c => [%a [%b %c]]
|
||||
++ read-schem :: decode gapped noun
|
||||
=< (cook to-noun (cook build-grove apex))
|
||||
|%
|
||||
++ noun $|(term [noun noun]) :: shadow
|
||||
++ data $|(term [n=@ l=noun r=data])
|
||||
:: improper list of possible entry points
|
||||
++ grove $|(term [gap=@ sealed=noun pending=grove])
|
||||
++ apex ;~(plug sym (star ;~(plug delim sym)))
|
||||
++ delim ;~(pose (cold 0 dot) (cook lent (plus cab)))
|
||||
++ to-noun |=(a=data ?@(a a [l.a $(a r.a)]))
|
||||
++ to-tree
|
||||
|= [acc=data a=(list ,[p=@u q=term])]
|
||||
%+ roll a =< .(acc ^acc)
|
||||
|= [[n=@u v=term] acc=data]
|
||||
?@ acc [n acc v]
|
||||
?: (gth n n.acc) [n (to-noun acc) v]
|
||||
acc(r $(acc r.acc))
|
||||
++ to-noun |=(a=grove ?@(a a [sealed.a $(a pending.a)]))
|
||||
++ build-grove
|
||||
|= [a=grove b=(list ,[p=@u q=term])] ^- grove
|
||||
%+ roll b =< .(acc a)
|
||||
|= [[gap=@u v=term] acc=grove] ^- grove
|
||||
?@ acc [gap acc v]
|
||||
?: (gth gap gap.acc) [gap (to-noun acc) v]
|
||||
acc(pending $(acc pending.acc))
|
||||
--
|
||||
--
|
||||
|
||||
|
8
mar/tree/elem.hoon
Normal file
8
mar/tree/elem.hoon
Normal file
@ -0,0 +1,8 @@
|
||||
::
|
||||
:::: /hoon/core/elem/mar
|
||||
::
|
||||
/? 314
|
||||
|_ own=manx
|
||||
::
|
||||
++ grow |% ++ elem own :: alias
|
||||
-- --
|
@ -1,3 +1,3 @@
|
||||
/= all /; flop /^ (list (pair time ,*)) /& /mime/
|
||||
/= all /; flop /^ (list (pair time ,*)) /@ /mime/
|
||||
^- json
|
||||
?~(all ~ (joba %u s/(scot %da p.i.all)))
|
||||
|
@ -6,7 +6,7 @@
|
||||
/= mez
|
||||
/; pojo
|
||||
/; |=(a=(list ,[@ p=json]) =.(a (flop a) ?~(a [%a ~] p.i.a)))
|
||||
/& /json/
|
||||
/@ /json/
|
||||
|%
|
||||
++ cdnj |=(a=tape ;script(src "//cdnjs.cloudflare.com/ajax/libs/{a}");)
|
||||
--
|
||||
|
@ -1,9 +1,9 @@
|
||||
/+ tree, react
|
||||
/= mime /mime/
|
||||
/= body /elem/
|
||||
/= snip /snip/
|
||||
/= meta /front/
|
||||
/= sect /index/
|
||||
/= body /tree-elem/
|
||||
/= sect /tree-index/
|
||||
/= snip /&snip&elem&/tree-elem/
|
||||
/= meta /&front&elem&/tree-elem/
|
||||
!:
|
||||
^- tree-include
|
||||
=+ rj=react-to-json:react
|
||||
|
5
ren/tree/elem.hoon
Normal file
5
ren/tree/elem.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
/% /,
|
||||
/web /|(/!elem/ /elem/)
|
||||
/ /elem/
|
||||
==
|
||||
`manx`-.-
|
@ -1,5 +1,5 @@
|
||||
/- tree-include
|
||||
/| /tree-combine/
|
||||
/:/===/web/404:/tree-combine/
|
||||
/:/===/web/404:/tree-combine/ :: XX merge into tree-elem?
|
||||
==
|
||||
`tree-include`-<
|
||||
|
@ -1,12 +1,12 @@
|
||||
/+ tree
|
||||
/, /
|
||||
/; (getall:tree /h1/h2/h3/h4/h5/h6) /elem/
|
||||
/; (getall:tree /h1/h2/h3/h4/h5/h6) /tree-elem/
|
||||
::
|
||||
/pub/docs/dev/hoon/runes
|
||||
/; |= [tip=marl sub=(map span marl) ~]
|
||||
(zing `(list marl)`[tip (turn (~(tap by sub)) tail)])
|
||||
/. /; (getall:tree %h1 ~) /elem/
|
||||
/_ /; (getall:tree %h1 ~) /elem/
|
||||
/. /; (getall:tree %h1 ~) /tree-elem/
|
||||
/_ /; (getall:tree %h1 ~) /tree-elem/
|
||||
== ==
|
||||
::
|
||||
::::
|
@ -1,6 +1,6 @@
|
||||
/% /,
|
||||
/talk /talklog-hymn/
|
||||
/web /|(/!hymn/ /tree-hymn/)
|
||||
/talk/log /talklog-hymn/
|
||||
/web/app /|(/!hymn/ /tree-hymn/)
|
||||
/ /tree-hymn/
|
||||
==
|
||||
`manx`-.-
|
||||
|
@ -16,7 +16,7 @@
|
||||
;script: urb.appl = 'cloud'
|
||||
;script@"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js";
|
||||
;script@"https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js";
|
||||
::;link/"/cloud/main.css"(rel "stylesheet");
|
||||
::;link/"cloud/main.css"(rel "stylesheet");
|
||||
;title: DO & GCE Manager
|
||||
==
|
||||
;body
|
||||
@ -25,6 +25,6 @@
|
||||
authcode.do='{?~(do ~ (trip u.do))}'
|
||||
"""
|
||||
;div#container;
|
||||
;script@"/cloud/main.js";
|
||||
;script@"cloud/main.js";
|
||||
==
|
||||
==
|
@ -24,7 +24,7 @@
|
||||
;link
|
||||
=type "text/css"
|
||||
=rel "stylesheet"
|
||||
=href "/oct3/main.css"
|
||||
=href "oct3/main.css"
|
||||
;
|
||||
==
|
||||
;title: :oct3
|
||||
@ -43,6 +43,6 @@
|
||||
==
|
||||
;div#bord;
|
||||
;div#audi;
|
||||
;script(type "text/javascript", src "/oct3/main.js");
|
||||
;script(type "text/javascript", src "oct3/main.js");
|
||||
==
|
||||
==
|
@ -1,9 +1,9 @@
|
||||
/= all /; flop /^ (list (pair time ,*)) /& /mime/
|
||||
/= all /; flop /^ (list (pair time ,*)) /@ /mime/
|
||||
;html
|
||||
;head:title:"Pastebin"
|
||||
;body
|
||||
;link(rel "stylesheet", href "/lib/base.css");
|
||||
;link(rel "stylesheet", href "/paste/main.css");
|
||||
;link(rel "stylesheet", href "paste/main.css");
|
||||
;script@"//code.jquery.com/jquery-2.1.4.min.js";
|
||||
;script@"/~/as/own/~/at/lib/js/urb.js";
|
||||
;script:'''
|
@ -10,30 +10,25 @@
|
||||
::::
|
||||
::
|
||||
^- manx
|
||||
;html
|
||||
;head
|
||||
;title: Sole
|
||||
;* %- turn :_ cdnj ^- wall
|
||||
:~ "jquery/2.1.1/jquery.min.js"
|
||||
"mousetrap/1.4.6/mousetrap.js"
|
||||
"react/0.11.0/react.js"
|
||||
==
|
||||
;script@"/~~/~/at/lib/js/urb.js";
|
||||
;script: urb.appl = 'dojo'
|
||||
;style:'''
|
||||
#term {
|
||||
width: 100%;
|
||||
}
|
||||
#term * {
|
||||
margin: 0px;
|
||||
}
|
||||
'''
|
||||
==
|
||||
;body
|
||||
;div#err;
|
||||
;div#term:""
|
||||
;script@"dojo/share.coffee"(type "text/coffeescript");
|
||||
;script@"dojo/main.coffee"(type "text/coffeescript");
|
||||
;+ (cdnj "coffee-script/1.7.1/coffee-script.min.js")
|
||||
==
|
||||
;module
|
||||
=nav_title "Sole"
|
||||
=nav_subnav "div"
|
||||
;* %- turn :_ cdnj ^- wall
|
||||
:~ :: "jquery/2.1.1/jquery.min.js"
|
||||
"mousetrap/1.4.6/mousetrap.js"
|
||||
:: "react/0.11.0/react.js"
|
||||
==
|
||||
::;script@"/~~/~/at/lib/js/urb.js";
|
||||
;style:'''
|
||||
#term {
|
||||
width: 100%;
|
||||
}
|
||||
#term * {
|
||||
margin: 0px;
|
||||
}
|
||||
'''
|
||||
;div#err;
|
||||
;div#term:""
|
||||
;script@"/lib/js/sole.js";
|
||||
;sole(appl "dojo");
|
||||
==
|
||||
|
@ -1,306 +0,0 @@
|
||||
[DOM,recl,rend] = [React.DOM, React.createClass, React.renderComponent]
|
||||
[div, pre, span] = [DOM.div, DOM.pre, DOM.span]
|
||||
str = JSON.stringify
|
||||
|
||||
Prompt = recl render: ->
|
||||
[pro,cur,buf] = [@props.prompt[@props.appl] ? "X", @props.cursor, @props.input + " "]
|
||||
pre {}, @props.appl+pro,
|
||||
span {style: background: 'lightgray'}, buf.slice(0,cur), "\u0332", buf.slice(cur)
|
||||
|
||||
Matr = recl render: ->
|
||||
lines = @props.rows.map (lin)-> pre {}, lin, " "
|
||||
lines.push Prompt
|
||||
appl: @props.appl,
|
||||
prompt: @props.prompt,
|
||||
input: @props.input,
|
||||
cursor: @props.cursor
|
||||
div {}, lines
|
||||
|
||||
$ ->
|
||||
|
||||
met = $('<pre>').text('m').css(display: 'none').appendTo(term).width()
|
||||
subs = ""
|
||||
# $(window).resize ->
|
||||
# window.termWif = ($(term).width() / met).toFixed()
|
||||
# path = "/new/#{termWif}"
|
||||
# if path is subs
|
||||
# return
|
||||
# if subs
|
||||
# urb.unsubscribe path: subs
|
||||
# subs = path
|
||||
# urb.subscribe {path}, (err,dat)->
|
||||
# if err or dat.data.ok
|
||||
# return;
|
||||
# syncRev = dat.data.rev
|
||||
# unless termRev > syncRev
|
||||
# termRev = syncRev
|
||||
# matr.setProps rows: dat.data.stak
|
||||
# document.title = "Matrix" # XX debug
|
||||
# $(window).resize()
|
||||
|
||||
flash = ($el, background)->
|
||||
$el.css {background}
|
||||
if background
|
||||
setTimeout (-> flash $el,''), 50
|
||||
bell = -> flash ($ 'body'), 'black'
|
||||
|
||||
matr = rend (Matr
|
||||
rows:[]
|
||||
appl:""
|
||||
prompt:{"": "# "}
|
||||
input:""
|
||||
cursor:0
|
||||
history:[]
|
||||
offset:0 ), term
|
||||
window.matr = matr
|
||||
update = (a) -> matr.setProps a
|
||||
buffer = "": new Share ""
|
||||
window.buffer = buffer
|
||||
choose = (appl)->
|
||||
urb.appl = appl
|
||||
buffer[appl] ?= new Share ""
|
||||
updPrompt '', null
|
||||
update {appl, cursor: 0, input: buffer[appl].buf}
|
||||
print = (txt)-> update rows: [matr.props.rows..., txt]
|
||||
sync = (ted,app)->
|
||||
app ?= matr.props.appl
|
||||
if app isnt matr.props.appl then return
|
||||
b = buffer[app]
|
||||
update input: b.buf, cursor: b.transpose ted, matr.props.cursor
|
||||
updPrompt = (app,pro) ->
|
||||
prompt = $.extend {}, matr.props.prompt
|
||||
if pro? then prompt[app] = pro else delete prompt[app]
|
||||
update {prompt}
|
||||
sysStatus = ()-> updPrompt '', (
|
||||
[app,pro] = [matr.props.appl, (k for k,v of matr.props.prompt when k isnt '')]
|
||||
if app is '' then (pro.join ', ')+'# ' else null
|
||||
)
|
||||
|
||||
peer = (ruh,app) ->
|
||||
app ?= urb.appl
|
||||
if ruh.map then return ruh.map (rul)-> peer rul, app
|
||||
mapr = matr.props
|
||||
switch Object.keys(ruh)[0]
|
||||
when 'txt' then print ruh.txt
|
||||
when 'tan' then ruh.tan.split("\n").map print
|
||||
when 'pro' then updPrompt app, ruh.pro.cad
|
||||
when 'hop' then update cursor: ruh.hop; bell() # XX buffer.transpose?
|
||||
when 'blk' then console.log "Stub #{str ruh}"
|
||||
when 'det' then buffer[app].receive ruh.det; sync ruh.det.ted, app
|
||||
when 'act' then switch ruh.act
|
||||
when 'clr' then update rows:[]
|
||||
when 'bel' then bell()
|
||||
when 'nex' then update
|
||||
input: ""
|
||||
cursor: 0
|
||||
history:
|
||||
if !mapr.input then mapr.history
|
||||
else [mapr.input, mapr.history...]
|
||||
offset: 0
|
||||
# else throw "Unknown "+(JSON.stringify ruh)
|
||||
else v = Object.keys(ruh); console.log v, ruh[v[0]]
|
||||
|
||||
join = (app)->
|
||||
if matr.props.prompt[app]?
|
||||
return print '# already-joined: '+app
|
||||
choose app
|
||||
urb.bind "/sole", {wire:"/"}, (err,d)->
|
||||
if err then console.log err
|
||||
else if d.data then peer d.data, app
|
||||
cycle = ()->
|
||||
apps = Object.keys matr.props.prompt
|
||||
if apps.length < 2 then return
|
||||
choose apps[1 + apps.indexOf urb.appl] ? apps[0]
|
||||
part = (appl)->
|
||||
mapr = matr.props
|
||||
unless mapr.prompt[appl]?
|
||||
return print '# not-joined: '+appl
|
||||
urb.drop "/sole", {appl, wire: "/"}
|
||||
if appl is mapr.appl then cycle()
|
||||
updPrompt appl, null
|
||||
sysStatus()
|
||||
join urb.appl
|
||||
window.join = join; window.part = part
|
||||
|
||||
pressed = []
|
||||
deltim = null
|
||||
#later = (data)->
|
||||
# if data
|
||||
# pressed.push data
|
||||
# clearTimeout deltim
|
||||
# setTimeout (->
|
||||
# if urb.reqq.length > 0
|
||||
# return deltim = later()
|
||||
# urb.send data: pressed
|
||||
# pressed = []
|
||||
# ), 500
|
||||
|
||||
urb.send.mark = 'sole-action'
|
||||
sendAction = (data)->
|
||||
if matr.props.appl then urb.send data, (e,res)->
|
||||
if res.status isnt 200 then $('#err')[0].innerText = res.data.mess
|
||||
else if data is 'ret'
|
||||
app = /^[a-z-]+$/.exec(buffer[""].buf.slice(1))
|
||||
unless app? and app[0]?
|
||||
return bell()
|
||||
else switch buffer[""].buf[0]
|
||||
when '+' then doEdit set: ""; join app[0]
|
||||
when '-' then doEdit set: ""; part app[0]
|
||||
else bell()
|
||||
|
||||
doEdit = (ted)->
|
||||
det = buffer[matr.props.appl].transmit ted
|
||||
sync ted
|
||||
sendAction {det}
|
||||
|
||||
yank = ''
|
||||
eatKyev= (mod, key)->
|
||||
mapr = matr.props
|
||||
switch mod.sort().join '-'
|
||||
when '', 'shift'
|
||||
if key.str
|
||||
doEdit ins: cha: key.str, at: mapr.cursor
|
||||
update cursor: mapr.cursor+1
|
||||
switch key.act
|
||||
when 'entr' then sendAction 'ret'
|
||||
when 'up'
|
||||
history = mapr.history.slice(); offset = mapr.offset
|
||||
if history[offset] == undefined
|
||||
return
|
||||
[input, history[offset]] = [history[offset], mapr.input]
|
||||
offset++
|
||||
doEdit set: input
|
||||
update {offset, history, cursor: input.length}
|
||||
when 'down'
|
||||
history = mapr.history.slice(); offset = mapr.offset
|
||||
offset--
|
||||
if history[offset] == undefined
|
||||
return
|
||||
[input, history[offset]] = [history[offset], mapr.input]
|
||||
doEdit set: input
|
||||
update {offset, history, cursor: input.length}
|
||||
when 'left' then if mapr.cursor > 0
|
||||
update cursor: mapr.cursor-1
|
||||
when 'right' then if mapr.cursor < mapr.input.length
|
||||
update cursor: mapr.cursor+1
|
||||
when 'baxp' then if mapr.cursor > 0
|
||||
doEdit del: mapr.cursor-1
|
||||
#else (if key.act then console.log key.act)
|
||||
when 'ctrl' then switch key.str || key.act
|
||||
when 'a','left' then update cursor: 0
|
||||
when 'e','right' then update cursor: mapr.input.length
|
||||
when 'l' then update rows: []
|
||||
when 'entr' then bell()
|
||||
when 'w' then eatKyev ['alt'], act:'baxp'
|
||||
when 'p' then eatKyev [], act: 'up'
|
||||
when 'n' then eatKyev [], act: 'down'
|
||||
when 'b' then eatKyev [], act: 'left'
|
||||
when 'f' then eatKyev [], act: 'right'
|
||||
when 'g' then bell()
|
||||
when 'x' then cycle()
|
||||
when 'v'
|
||||
appl = if mapr.appl isnt '' then '' else urb.appl
|
||||
update {appl, cursor:0, input:buffer[appl].buf}
|
||||
sysStatus()
|
||||
when 't'
|
||||
if mapr.cursor is 0 or mapr.input.length < 2
|
||||
return bell()
|
||||
cursor = mapr.cursor
|
||||
if cursor < mapr.input.length
|
||||
cursor++
|
||||
doEdit [{del:cursor-1},ins:{at:cursor-2,cha:mapr.input[cursor-1]}]
|
||||
update {cursor}
|
||||
when 'u'
|
||||
yank = mapr.input.slice(0,mapr.cursor)
|
||||
doEdit (del:mapr.cursor - n for n in [1..mapr.cursor])
|
||||
when 'k'
|
||||
yank = mapr.input.slice(mapr.cursor)
|
||||
doEdit (del:mapr.cursor for _ in [mapr.cursor...mapr.input.length])
|
||||
when 'y'
|
||||
doEdit (ins: {cha, at: mapr.cursor + n} for cha,n in yank)
|
||||
else console.log mod, str key
|
||||
when 'alt' then switch key.str || key.act
|
||||
when 'f','right'
|
||||
rest = mapr.input.slice(mapr.cursor)
|
||||
rest = rest.match(/\W*\w*/)[0] # XX unicode
|
||||
update cursor: mapr.cursor + rest.length
|
||||
when 'b','left'
|
||||
prev = mapr.input.slice(0,mapr.cursor)
|
||||
prev = prev.split('').reverse().join('') # XX
|
||||
prev = prev.match(/\W*\w*/)[0] # XX unicode
|
||||
update cursor: mapr.cursor - prev.length
|
||||
when 'baxp'
|
||||
prev = mapr.input.slice(0,mapr.cursor)
|
||||
prev = prev.split('').reverse().join('') # XX
|
||||
prev = prev.match(/\W*\w*/)[0] # XX unicode
|
||||
yank = prev
|
||||
doEdit (del: mapr.cursor-1 - n for _,n in prev)
|
||||
else console.log mod, str key
|
||||
|
||||
Mousetrap.handleKey = (char, mod, e)->
|
||||
norm = {
|
||||
capslock: 'caps'
|
||||
pageup: 'pgup'
|
||||
pagedown: 'pgdn'
|
||||
backspace: 'baxp'
|
||||
enter: 'entr'
|
||||
}
|
||||
|
||||
key = switch
|
||||
when char.length is 1
|
||||
if e.type is 'keypress'
|
||||
chac = char.charCodeAt(0)
|
||||
if chac < 32 # normalize ctrl keys
|
||||
char = String.fromCharCode chac | 96
|
||||
str: char
|
||||
when e.type is 'keydown'
|
||||
if char isnt 'space'
|
||||
act: norm[char] ? char
|
||||
when e.type is 'keyup' and norm[key] is 'caps'
|
||||
act: 'uncap'
|
||||
if !key then return
|
||||
if key.act and key.act in mod
|
||||
return
|
||||
e.preventDefault()
|
||||
#[fore, aft] = (
|
||||
# [sli,cur] = [mapr.input.slice, mapr.cursor]
|
||||
# [sli(0, cur), sli(cur)]
|
||||
#)
|
||||
eatKyev mod, key
|
||||
|
||||
#amod = (arr)->
|
||||
# for i in arr
|
||||
# unless mod.indexOf(i) < 0
|
||||
# return yes
|
||||
# no
|
||||
# if key.str or key.act is 'baxp' or key.act is 'entr'
|
||||
# termRev++
|
||||
# [bot, rest...] = old = matr.props.rows
|
||||
# matr.setProps rows:(
|
||||
# switch key.act
|
||||
# when 'baxp'
|
||||
# if amod ['ctrl', 'meta']
|
||||
# ['', rest...]
|
||||
# else if amod ['alt']
|
||||
# [(bot.replace /\ *[^ ]*$/, ''), rest...]
|
||||
# else if bot and bot.length
|
||||
# [bot.slice(0, -1), rest...]
|
||||
# else if rest[0] and rest[0].length
|
||||
# res = rest.slice()
|
||||
# res[0] = res[0].slice(0, -1)
|
||||
# res
|
||||
# else rest
|
||||
# when 'entr'
|
||||
# ['', old...]
|
||||
# when undefined
|
||||
# if mod.length > 1 or (mod.length and !amod ['shift'])
|
||||
# old
|
||||
# else unless old and bot isnt null
|
||||
# [key.str]
|
||||
# #else if bot.length is termWif
|
||||
# # [key.str, old...]
|
||||
# else [bot + key.str, rest...]
|
||||
# )
|
||||
# document.title = "Matri" # XX debug
|
||||
# later {mod, key}
|
||||
|
@ -1,83 +0,0 @@
|
||||
# See /hook/core/sole/lib
|
||||
str = JSON.stringify
|
||||
clog = (a)-> console.log a
|
||||
class window.Share
|
||||
constructor: (@buf = "", @ven = [0, 0], @leg = []) ->
|
||||
#
|
||||
abet: -> buf:@buf, leg:@leg.slice(), ven:@ven.slice()
|
||||
apply: (ted)->
|
||||
switch
|
||||
when 'nop' == ted then return
|
||||
when ted.map then ted.map @apply, @
|
||||
else switch Object.keys(ted)[0]
|
||||
when 'set' then @buf = ted.set
|
||||
when 'del' then @buf = @buf.slice(0,ted.del) + @buf.slice(ted.del + 1)
|
||||
when 'ins'
|
||||
{at,cha} = ted.ins
|
||||
@buf = @buf.slice(0,at) + cha + @buf.slice(at)
|
||||
else throw "%sole-edit -lost.#{str ted}"
|
||||
#
|
||||
transmute: (sin,dex)->
|
||||
switch
|
||||
when sin == 'nop' or dex == 'nop' then dex
|
||||
when sin.reduce
|
||||
sin.reduce ((dex,syn) => @transmute(syn,dex)), dex
|
||||
when dex.map then dex.map (dax) => @transmute(sin,dax)
|
||||
when dex.set != undefined then dex
|
||||
else switch Object.keys(sin)[0]
|
||||
when 'set' then 'nop'
|
||||
when 'del'
|
||||
if sin.del is dex.del then return 'nop'
|
||||
dex = $.extend true, {}, dex # clone
|
||||
switch Object.keys(dex)[0]
|
||||
when 'del' then if sin.del < dex.del then dex.del--
|
||||
when 'ins' then if sin.del < dex.ins.at then dex.ins.at--
|
||||
return dex
|
||||
when 'ins'
|
||||
dex = $.extend true, {}, dex # clone
|
||||
{at,cha} = sin.ins
|
||||
switch Object.keys(dex)[0]
|
||||
when 'del' then if at < dex.del then dex.del++
|
||||
when 'ins' then if at < dex.ins.at or
|
||||
(at == dex.ins.at and !(cha <= dex.ins.cha))
|
||||
dex.ins.at++
|
||||
return dex
|
||||
else throw "%sole-edit -lost.#{str sin}"
|
||||
#
|
||||
commit: (ted)->
|
||||
@ven[0]++
|
||||
@leg.push ted
|
||||
@apply ted
|
||||
#
|
||||
inverse: (ted)->
|
||||
switch
|
||||
when 'nop' == ted then ted
|
||||
when ted.map
|
||||
ted.map( (tad)=> res=@inverse tad; @apply tad; res).reverse()
|
||||
else switch Object.keys(ted)[0]
|
||||
when 'set' then set: @buf
|
||||
when 'ins' then del: ted.ins
|
||||
when 'del' then ins: at: ted.del, cha: @buf[ted.del]
|
||||
else throw "%sole-edit -lost.#{str ted}"
|
||||
#
|
||||
receive: ({ler,ted})->
|
||||
if !(ler[1] is @ven[1])
|
||||
throw "-out-of-sync.[#{str ler} #{str @ven}]"
|
||||
@leg = @leg.slice @leg.length + ler[0] - @ven[0]
|
||||
dat = @transmute @leg, ted
|
||||
@ven[1]++; @apply dat; dat
|
||||
#
|
||||
remit: -> throw 'stub'
|
||||
transmit: (ted)->
|
||||
act = {ted, ler:[@ven[1], @ven[0]]}
|
||||
@commit ted
|
||||
return act
|
||||
#
|
||||
transceive: ({ler,ted})->
|
||||
old = new Share @buf
|
||||
dat = @receive {ler, ted}
|
||||
old.inverse dat
|
||||
#
|
||||
transpose: (ted,pos)->
|
||||
if pos == undefined then @transpose @leg, ted
|
||||
else ((@transmute ted, ins: at: pos).ins ? at:0).at
|
787
web/lib/js/sole.js
Normal file
787
web/lib/js/sole.js
Normal file
@ -0,0 +1,787 @@
|
||||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
var Matr, Prompt, Share, TreeActions, buffer, div, pre, recl, ref, ref1, rele, span, str, u,
|
||||
slice = [].slice,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
ref = [React.createClass, React.createElement], recl = ref[0], rele = ref[1];
|
||||
|
||||
ref1 = React.DOM, div = ref1.div, u = ref1.u, pre = ref1.pre, span = ref1.span;
|
||||
|
||||
TreeActions = window.tree.actions;
|
||||
|
||||
str = JSON.stringify;
|
||||
|
||||
Share = require("./share.coffee");
|
||||
|
||||
buffer = {
|
||||
"": new Share("")
|
||||
};
|
||||
|
||||
Prompt = recl({
|
||||
displayName: "Prompt",
|
||||
render: function() {
|
||||
var buf, cur, pro, ref2, ref3;
|
||||
pro = (ref2 = this.props.prompt[this.props.appl]) != null ? ref2 : "X";
|
||||
cur = this.props.cursor;
|
||||
buf = this.props.input + " ";
|
||||
return pre({}, this.props.appl + pro, span({
|
||||
style: {
|
||||
background: 'lightgray'
|
||||
}
|
||||
}, buf.slice(0, cur), u({}, (ref3 = buf[cur]) != null ? ref3 : " "), buf.slice(cur + 1)));
|
||||
}
|
||||
});
|
||||
|
||||
Matr = recl({
|
||||
displayName: "Matr",
|
||||
render: function() {
|
||||
var lines;
|
||||
lines = this.props.rows.map(function(lin, key) {
|
||||
return pre({
|
||||
key: key
|
||||
}, lin, " ");
|
||||
});
|
||||
lines.push(rele(Prompt, {
|
||||
key: "prompt",
|
||||
appl: this.props.appl,
|
||||
prompt: this.props.prompt,
|
||||
input: this.props.input,
|
||||
cursor: this.props.cursor
|
||||
}));
|
||||
return div({}, lines);
|
||||
}
|
||||
});
|
||||
|
||||
TreeActions.registerComponent("sole", recl({
|
||||
displayName: "Sole",
|
||||
getInitialState: function() {
|
||||
return {
|
||||
rows: [],
|
||||
appl: this.props.appl,
|
||||
prompt: {
|
||||
"": "# "
|
||||
},
|
||||
input: "",
|
||||
cursor: 0,
|
||||
history: [],
|
||||
offset: 0,
|
||||
error: ""
|
||||
};
|
||||
},
|
||||
render: function() {
|
||||
return div({}, div({
|
||||
id: "err"
|
||||
}, this.state.error), rele(Matr, this.state));
|
||||
},
|
||||
flash: function($el, background) {
|
||||
$el.css({
|
||||
background: background
|
||||
});
|
||||
if (background) {
|
||||
return setTimeout(((function(_this) {
|
||||
return function() {
|
||||
return _this.flash($el, '');
|
||||
};
|
||||
})(this)), 50);
|
||||
}
|
||||
},
|
||||
bell: function() {
|
||||
return this.flash($('body'), 'black');
|
||||
},
|
||||
choose: function(appl) {
|
||||
if (buffer[appl] == null) {
|
||||
buffer[appl] = new Share("");
|
||||
}
|
||||
this.updPrompt('', null);
|
||||
return this.setState({
|
||||
appl: appl,
|
||||
cursor: 0,
|
||||
input: buffer[appl].buf
|
||||
});
|
||||
},
|
||||
print: function(txt) {
|
||||
return this.setState({
|
||||
rows: slice.call(this.state.rows).concat([txt])
|
||||
});
|
||||
},
|
||||
sync: function(ted, app) {
|
||||
var b;
|
||||
if (app == null) {
|
||||
app = this.state.appl;
|
||||
}
|
||||
if (app === this.state.appl) {
|
||||
b = buffer[app];
|
||||
return this.setState({
|
||||
input: b.buf,
|
||||
cursor: b.transpose(ted, this.state.cursor)
|
||||
});
|
||||
}
|
||||
},
|
||||
updPrompt: function(app, pro) {
|
||||
var prompt;
|
||||
prompt = $.extend({}, this.state.prompt);
|
||||
if (pro != null) {
|
||||
prompt[app] = pro;
|
||||
} else {
|
||||
delete prompt[app];
|
||||
}
|
||||
return this.setState({
|
||||
prompt: prompt
|
||||
});
|
||||
},
|
||||
sysStatus: function() {
|
||||
var app, k, pro, ref2, v;
|
||||
return this.updPrompt('', ((ref2 = [
|
||||
this.state.appl, (function() {
|
||||
var ref2, results;
|
||||
ref2 = this.state.prompt;
|
||||
results = [];
|
||||
for (k in ref2) {
|
||||
v = ref2[k];
|
||||
if (k !== '') {
|
||||
results.push(k);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}).call(this)
|
||||
], app = ref2[0], pro = ref2[1], ref2), app === '' ? (pro.join(', ')) + '# ' : null));
|
||||
},
|
||||
peer: function(ruh, app) {
|
||||
var mapr, v;
|
||||
if (app == null) {
|
||||
app = this.state.appl;
|
||||
}
|
||||
if (ruh.map) {
|
||||
return ruh.map((function(_this) {
|
||||
return function(rul) {
|
||||
return _this.peer(rul, app);
|
||||
};
|
||||
})(this));
|
||||
}
|
||||
mapr = this.state;
|
||||
switch (Object.keys(ruh)[0]) {
|
||||
case 'txt':
|
||||
return this.print(ruh.txt);
|
||||
case 'tan':
|
||||
return ruh.tan.split("\n").map(this.print);
|
||||
case 'pro':
|
||||
return this.updPrompt(app, ruh.pro.cad);
|
||||
case 'hop':
|
||||
this.setState({
|
||||
cursor: ruh.hop
|
||||
});
|
||||
return this.bell();
|
||||
case 'blk':
|
||||
return console.log("Stub " + (str(ruh)));
|
||||
case 'det':
|
||||
buffer[app].receive(ruh.det);
|
||||
return this.sync(ruh.det.ted, app);
|
||||
case 'act':
|
||||
switch (ruh.act) {
|
||||
case 'clr':
|
||||
return this.setState({
|
||||
rows: []
|
||||
});
|
||||
case 'bel':
|
||||
return this.bell();
|
||||
case 'nex':
|
||||
return this.setState({
|
||||
input: "",
|
||||
cursor: 0,
|
||||
history: !mapr.input ? mapr.history : [mapr.input].concat(slice.call(mapr.history)),
|
||||
offset: 0
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
v = Object.keys(ruh);
|
||||
return console.log(v, ruh[v[0]]);
|
||||
}
|
||||
},
|
||||
join: function(app) {
|
||||
if (this.state.prompt[app] != null) {
|
||||
return this.print('# already-joined: ' + app);
|
||||
}
|
||||
this.choose(app);
|
||||
return urb.bind("/sole", {
|
||||
appl: this.state.appl,
|
||||
wire: "/"
|
||||
}, (function(_this) {
|
||||
return function(err, d) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
} else if (d.data) {
|
||||
return _this.peer(d.data, app);
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
},
|
||||
cycle: function() {
|
||||
var apps, ref2;
|
||||
apps = Object.keys(this.state.prompt);
|
||||
if (apps.length < 2) {
|
||||
return;
|
||||
}
|
||||
return this.choose((ref2 = apps[1 + apps.indexOf(this.state.appl)]) != null ? ref2 : apps[0]);
|
||||
},
|
||||
part: function(appl) {
|
||||
var mapr;
|
||||
mapr = this.state;
|
||||
if (mapr.prompt[appl] == null) {
|
||||
return this.print('# not-joined: ' + appl);
|
||||
}
|
||||
urb.drop("/sole", {
|
||||
appl: appl,
|
||||
wire: "/"
|
||||
});
|
||||
if (appl === mapr.appl) {
|
||||
this.cycle();
|
||||
}
|
||||
this.updPrompt(appl, null);
|
||||
return this.sysStatus();
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
return this.mousetrapStop();
|
||||
},
|
||||
componentDidMount: function() {
|
||||
this.mousetrapInit();
|
||||
return this.join(this.state.appl);
|
||||
},
|
||||
sendAction: function(data) {
|
||||
var app, appl;
|
||||
appl = this.state.appl;
|
||||
if (appl) {
|
||||
return urb.send(data, {
|
||||
appl: appl,
|
||||
mark: 'sole-action'
|
||||
}, (function(_this) {
|
||||
return function(e, res) {
|
||||
if (res.status !== 200) {
|
||||
return _this.setState({
|
||||
error: res.data.mess
|
||||
});
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
} else if (data === 'ret') {
|
||||
app = /^[a-z-]+$/.exec(buffer[""].buf.slice(1));
|
||||
if (!((app != null) && (app[0] != null))) {
|
||||
return this.bell();
|
||||
} else {
|
||||
switch (buffer[""].buf[0]) {
|
||||
case '+':
|
||||
this.doEdit({
|
||||
set: ""
|
||||
});
|
||||
return this.join(app[0]);
|
||||
case '-':
|
||||
this.doEdit({
|
||||
set: ""
|
||||
});
|
||||
return this.part(app[0]);
|
||||
default:
|
||||
return this.bell();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
doEdit: function(ted) {
|
||||
var det;
|
||||
det = buffer[this.state.appl].transmit(ted);
|
||||
this.sync(ted);
|
||||
return this.sendAction({
|
||||
det: det
|
||||
});
|
||||
},
|
||||
eatKyev: function(mod, key) {
|
||||
var _, appl, cha, cursor, history, input, mapr, n, offset, prev, ref2, ref3, rest;
|
||||
mapr = this.state;
|
||||
switch (mod.sort().join('-')) {
|
||||
case '':
|
||||
case 'shift':
|
||||
if (key.str) {
|
||||
this.doEdit({
|
||||
ins: {
|
||||
cha: key.str,
|
||||
at: mapr.cursor
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
cursor: mapr.cursor + 1
|
||||
});
|
||||
}
|
||||
switch (key.act) {
|
||||
case 'entr':
|
||||
return this.sendAction('ret');
|
||||
case 'up':
|
||||
history = mapr.history.slice();
|
||||
offset = mapr.offset;
|
||||
if (history[offset] === void 0) {
|
||||
return;
|
||||
}
|
||||
ref2 = [history[offset], mapr.input], input = ref2[0], history[offset] = ref2[1];
|
||||
offset++;
|
||||
this.doEdit({
|
||||
set: input
|
||||
});
|
||||
return this.setState({
|
||||
offset: offset,
|
||||
history: history,
|
||||
cursor: input.length
|
||||
});
|
||||
case 'down':
|
||||
history = mapr.history.slice();
|
||||
offset = mapr.offset;
|
||||
offset--;
|
||||
if (history[offset] === void 0) {
|
||||
return;
|
||||
}
|
||||
ref3 = [history[offset], mapr.input], input = ref3[0], history[offset] = ref3[1];
|
||||
this.doEdit({
|
||||
set: input
|
||||
});
|
||||
return this.setState({
|
||||
offset: offset,
|
||||
history: history,
|
||||
cursor: input.length
|
||||
});
|
||||
case 'left':
|
||||
if (mapr.cursor > 0) {
|
||||
return this.setState({
|
||||
cursor: mapr.cursor - 1
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'right':
|
||||
if (mapr.cursor < mapr.input.length) {
|
||||
return this.setState({
|
||||
cursor: mapr.cursor + 1
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'baxp':
|
||||
if (mapr.cursor > 0) {
|
||||
return this.doEdit({
|
||||
del: mapr.cursor - 1
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'ctrl':
|
||||
switch (key.str || key.act) {
|
||||
case 'a':
|
||||
case 'left':
|
||||
return this.setState({
|
||||
cursor: 0
|
||||
});
|
||||
case 'e':
|
||||
case 'right':
|
||||
return this.setState({
|
||||
cursor: mapr.input.length
|
||||
});
|
||||
case 'l':
|
||||
return this.setState({
|
||||
rows: []
|
||||
});
|
||||
case 'entr':
|
||||
return this.bell();
|
||||
case 'w':
|
||||
return this.eatKyev(['alt'], {
|
||||
act: 'baxp'
|
||||
});
|
||||
case 'p':
|
||||
return this.eatKyev([], {
|
||||
act: 'up'
|
||||
});
|
||||
case 'n':
|
||||
return this.eatKyev([], {
|
||||
act: 'down'
|
||||
});
|
||||
case 'b':
|
||||
return this.eatKyev([], {
|
||||
act: 'left'
|
||||
});
|
||||
case 'f':
|
||||
return this.eatKyev([], {
|
||||
act: 'right'
|
||||
});
|
||||
case 'g':
|
||||
return this.bell();
|
||||
case 'x':
|
||||
return this.cycle();
|
||||
case 'v':
|
||||
appl = mapr.appl !== '' ? '' : this.state.appl;
|
||||
this.setState({
|
||||
appl: appl,
|
||||
cursor: 0,
|
||||
input: buffer[appl].buf
|
||||
});
|
||||
return this.sysStatus();
|
||||
case 't':
|
||||
if (mapr.cursor === 0 || mapr.input.length < 2) {
|
||||
return this.bell();
|
||||
}
|
||||
cursor = mapr.cursor;
|
||||
if (cursor < mapr.input.length) {
|
||||
cursor++;
|
||||
}
|
||||
this.doEdit([
|
||||
{
|
||||
del: cursor - 1
|
||||
}, {
|
||||
ins: {
|
||||
at: cursor - 2,
|
||||
cha: mapr.input[cursor - 1]
|
||||
}
|
||||
}
|
||||
]);
|
||||
return this.setState({
|
||||
cursor: cursor
|
||||
});
|
||||
case 'u':
|
||||
this.yank = mapr.input.slice(0, mapr.cursor);
|
||||
return this.doEdit((function() {
|
||||
var i, ref4, results;
|
||||
results = [];
|
||||
for (n = i = 1, ref4 = mapr.cursor; 1 <= ref4 ? i <= ref4 : i >= ref4; n = 1 <= ref4 ? ++i : --i) {
|
||||
results.push({
|
||||
del: mapr.cursor - n
|
||||
});
|
||||
}
|
||||
return results;
|
||||
})());
|
||||
case 'k':
|
||||
this.yank = mapr.input.slice(mapr.cursor);
|
||||
return this.doEdit((function() {
|
||||
var i, ref4, ref5, results;
|
||||
results = [];
|
||||
for (_ = i = ref4 = mapr.cursor, ref5 = mapr.input.length; ref4 <= ref5 ? i < ref5 : i > ref5; _ = ref4 <= ref5 ? ++i : --i) {
|
||||
results.push({
|
||||
del: mapr.cursor
|
||||
});
|
||||
}
|
||||
return results;
|
||||
})());
|
||||
case 'y':
|
||||
return this.doEdit((function() {
|
||||
var i, len, ref4, ref5, results;
|
||||
ref5 = (ref4 = this.yank) != null ? ref4 : '';
|
||||
results = [];
|
||||
for (n = i = 0, len = ref5.length; i < len; n = ++i) {
|
||||
cha = ref5[n];
|
||||
results.push({
|
||||
ins: {
|
||||
cha: cha,
|
||||
at: mapr.cursor + n
|
||||
}
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}).call(this));
|
||||
default:
|
||||
return console.log(mod, str(key));
|
||||
}
|
||||
break;
|
||||
case 'alt':
|
||||
switch (key.str || key.act) {
|
||||
case 'f':
|
||||
case 'right':
|
||||
rest = mapr.input.slice(mapr.cursor);
|
||||
rest = rest.match(/\W*\w*/)[0];
|
||||
return this.setState({
|
||||
cursor: mapr.cursor + rest.length
|
||||
});
|
||||
case 'b':
|
||||
case 'left':
|
||||
prev = mapr.input.slice(0, mapr.cursor);
|
||||
prev = prev.split('').reverse().join('');
|
||||
prev = prev.match(/\W*\w*/)[0];
|
||||
return this.setState({
|
||||
cursor: mapr.cursor - prev.length
|
||||
});
|
||||
case 'baxp':
|
||||
prev = mapr.input.slice(0, mapr.cursor);
|
||||
prev = prev.split('').reverse().join('');
|
||||
prev = prev.match(/\W*\w*/)[0];
|
||||
this.yank = prev;
|
||||
return this.doEdit((function() {
|
||||
var i, len, results;
|
||||
results = [];
|
||||
for (n = i = 0, len = prev.length; i < len; n = ++i) {
|
||||
_ = prev[n];
|
||||
results.push({
|
||||
del: mapr.cursor - 1 - n
|
||||
});
|
||||
}
|
||||
return results;
|
||||
})());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return console.log(mod, str(key));
|
||||
}
|
||||
},
|
||||
mousetrapStop: function() {
|
||||
return Mousetrap.handleKey = this._defaultHandleKey;
|
||||
},
|
||||
mousetrapInit: function() {
|
||||
this._defaultHandleKey = Mousetrap.handleKey;
|
||||
return Mousetrap.handleKey = (function(_this) {
|
||||
return function(char, mod, e) {
|
||||
var chac, key, norm, ref2;
|
||||
norm = {
|
||||
capslock: 'caps',
|
||||
pageup: 'pgup',
|
||||
pagedown: 'pgdn',
|
||||
backspace: 'baxp',
|
||||
enter: 'entr'
|
||||
};
|
||||
key = (function() {
|
||||
var ref2;
|
||||
switch (false) {
|
||||
case char.length !== 1:
|
||||
if (e.type === 'keypress') {
|
||||
chac = char.charCodeAt(0);
|
||||
if (chac < 32) {
|
||||
char = String.fromCharCode(chac | 96);
|
||||
}
|
||||
return {
|
||||
str: char
|
||||
};
|
||||
}
|
||||
break;
|
||||
case e.type !== 'keydown':
|
||||
if (char !== 'space') {
|
||||
return {
|
||||
act: (ref2 = norm[char]) != null ? ref2 : char
|
||||
};
|
||||
}
|
||||
break;
|
||||
case !(e.type === 'keyup' && norm[key] === 'caps'):
|
||||
return {
|
||||
act: 'uncap'
|
||||
};
|
||||
}
|
||||
})();
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
if (key.act && (ref2 = key.act, indexOf.call(mod, ref2) >= 0)) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
return _this.eatKyev(mod, key);
|
||||
};
|
||||
})(this);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
},{"./share.coffee":2}],2:[function(require,module,exports){
|
||||
var clog, str;
|
||||
|
||||
str = JSON.stringify;
|
||||
|
||||
clog = function(a) {
|
||||
return console.log(a);
|
||||
};
|
||||
|
||||
module.exports = (function() {
|
||||
function exports(buf, ven, leg) {
|
||||
this.buf = buf != null ? buf : "";
|
||||
this.ven = ven != null ? ven : [0, 0];
|
||||
this.leg = leg != null ? leg : [];
|
||||
}
|
||||
|
||||
exports.prototype.abet = function() {
|
||||
return {
|
||||
buf: this.buf,
|
||||
leg: this.leg.slice(),
|
||||
ven: this.ven.slice()
|
||||
};
|
||||
};
|
||||
|
||||
exports.prototype.apply = function(ted) {
|
||||
var at, cha, ref;
|
||||
switch (false) {
|
||||
case 'nop' !== ted:
|
||||
break;
|
||||
case !ted.map:
|
||||
return ted.map(this.apply, this);
|
||||
default:
|
||||
switch (Object.keys(ted)[0]) {
|
||||
case 'set':
|
||||
return this.buf = ted.set;
|
||||
case 'del':
|
||||
return this.buf = this.buf.slice(0, ted.del) + this.buf.slice(ted.del + 1);
|
||||
case 'ins':
|
||||
ref = ted.ins, at = ref.at, cha = ref.cha;
|
||||
return this.buf = this.buf.slice(0, at) + cha + this.buf.slice(at);
|
||||
default:
|
||||
throw "%sole-edit -lost." + (str(ted));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.prototype.transmute = function(sin, dex) {
|
||||
var at, cha, ref;
|
||||
switch (false) {
|
||||
case !(sin === 'nop' || dex === 'nop'):
|
||||
return dex;
|
||||
case !sin.reduce:
|
||||
return sin.reduce(((function(_this) {
|
||||
return function(dex, syn) {
|
||||
return _this.transmute(syn, dex);
|
||||
};
|
||||
})(this)), dex);
|
||||
case !dex.map:
|
||||
return dex.map((function(_this) {
|
||||
return function(dax) {
|
||||
return _this.transmute(sin, dax);
|
||||
};
|
||||
})(this));
|
||||
case dex.set === void 0:
|
||||
return dex;
|
||||
default:
|
||||
switch (Object.keys(sin)[0]) {
|
||||
case 'set':
|
||||
return 'nop';
|
||||
case 'del':
|
||||
if (sin.del === dex.del) {
|
||||
return 'nop';
|
||||
}
|
||||
dex = $.extend(true, {}, dex);
|
||||
switch (Object.keys(dex)[0]) {
|
||||
case 'del':
|
||||
if (sin.del < dex.del) {
|
||||
dex.del--;
|
||||
}
|
||||
break;
|
||||
case 'ins':
|
||||
if (sin.del < dex.ins.at) {
|
||||
dex.ins.at--;
|
||||
}
|
||||
}
|
||||
return dex;
|
||||
case 'ins':
|
||||
dex = $.extend(true, {}, dex);
|
||||
ref = sin.ins, at = ref.at, cha = ref.cha;
|
||||
switch (Object.keys(dex)[0]) {
|
||||
case 'del':
|
||||
if (at < dex.del) {
|
||||
dex.del++;
|
||||
}
|
||||
break;
|
||||
case 'ins':
|
||||
if (at < dex.ins.at || (at === dex.ins.at && !(cha <= dex.ins.cha))) {
|
||||
dex.ins.at++;
|
||||
}
|
||||
}
|
||||
return dex;
|
||||
default:
|
||||
throw "%sole-edit -lost." + (str(sin));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.prototype.commit = function(ted) {
|
||||
this.ven[0]++;
|
||||
this.leg.push(ted);
|
||||
return this.apply(ted);
|
||||
};
|
||||
|
||||
exports.prototype.inverse = function(ted) {
|
||||
switch (false) {
|
||||
case 'nop' !== ted:
|
||||
return ted;
|
||||
case !ted.map:
|
||||
return ted.map((function(_this) {
|
||||
return function(tad) {
|
||||
var res;
|
||||
res = _this.inverse(tad);
|
||||
_this.apply(tad);
|
||||
return res;
|
||||
};
|
||||
})(this)).reverse();
|
||||
default:
|
||||
switch (Object.keys(ted)[0]) {
|
||||
case 'set':
|
||||
return {
|
||||
set: this.buf
|
||||
};
|
||||
case 'ins':
|
||||
return {
|
||||
del: ted.ins
|
||||
};
|
||||
case 'del':
|
||||
return {
|
||||
ins: {
|
||||
at: ted.del,
|
||||
cha: this.buf[ted.del]
|
||||
}
|
||||
};
|
||||
default:
|
||||
throw "%sole-edit -lost." + (str(ted));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.prototype.receive = function(arg) {
|
||||
var dat, ler, ted;
|
||||
ler = arg.ler, ted = arg.ted;
|
||||
if (!(ler[1] === this.ven[1])) {
|
||||
throw "-out-of-sync.[" + (str(ler)) + " " + (str(this.ven)) + "]";
|
||||
}
|
||||
this.leg = this.leg.slice(this.leg.length + ler[0] - this.ven[0]);
|
||||
dat = this.transmute(this.leg, ted);
|
||||
this.ven[1]++;
|
||||
this.apply(dat);
|
||||
return dat;
|
||||
};
|
||||
|
||||
exports.prototype.remit = function() {
|
||||
throw 'stub';
|
||||
};
|
||||
|
||||
exports.prototype.transmit = function(ted) {
|
||||
var act;
|
||||
act = {
|
||||
ted: ted,
|
||||
ler: [this.ven[1], this.ven[0]]
|
||||
};
|
||||
this.commit(ted);
|
||||
return act;
|
||||
};
|
||||
|
||||
exports.prototype.transceive = function(arg) {
|
||||
var dat, ler, old, ted;
|
||||
ler = arg.ler, ted = arg.ted;
|
||||
old = new Share(this.buf);
|
||||
dat = this.receive({
|
||||
ler: ler,
|
||||
ted: ted
|
||||
});
|
||||
return old.inverse(dat);
|
||||
};
|
||||
|
||||
exports.prototype.transpose = function(ted, pos) {
|
||||
var ref;
|
||||
if (pos === void 0) {
|
||||
return this.transpose(this.leg, ted);
|
||||
} else {
|
||||
return ((ref = (this.transmute(ted, {
|
||||
ins: {
|
||||
at: pos
|
||||
}
|
||||
})).ins) != null ? ref : {
|
||||
at: 0
|
||||
}).at;
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
||||
})();
|
||||
|
||||
|
||||
},{}]},{},[1]);
|
@ -1 +1,6 @@
|
||||
;module(js "/talk/main.js", css "/talk/main.css", component "talk");
|
||||
;module(nav_title "Talk", nav_no-dpad "", nav_no-sibs "", nav_subnav "talk-station")
|
||||
;script@"/~~/~/at/lib/urb.js";
|
||||
;script@"/talk/main.js";
|
||||
;link/"/talk/main.css"(rel "stylesheet");
|
||||
;talk;
|
||||
==
|
||||
|
@ -1208,7 +1208,7 @@ setInterval((function() {
|
||||
}
|
||||
}), 300);
|
||||
|
||||
StationComponent = React.createFactory(require('./components/StationComponent.coffee'));
|
||||
StationComponent = require('./components/StationComponent.coffee');
|
||||
|
||||
MessagesComponent = React.createFactory(require('./components/MessagesComponent.coffee'));
|
||||
|
||||
@ -1222,13 +1222,7 @@ TreeActions.registerComponent("talk", React.createClass({
|
||||
require('./utils/util.coffee');
|
||||
require('./utils/move.coffee');
|
||||
StationActions.listen();
|
||||
StationActions.listenStation(window.util.mainStation());
|
||||
return TreeActions.setNav({
|
||||
title: "Talk",
|
||||
dpad: false,
|
||||
sibs: false,
|
||||
subnav: StationComponent
|
||||
});
|
||||
return StationActions.listenStation(window.util.mainStation());
|
||||
},
|
||||
render: function() {
|
||||
return div({
|
||||
@ -1247,6 +1241,8 @@ TreeActions.registerComponent("talk", React.createClass({
|
||||
}
|
||||
}));
|
||||
|
||||
TreeActions.registerComponent("talk-station", StationComponent);
|
||||
|
||||
|
||||
},{"./actions/StationActions.coffee":2,"./components/MessagesComponent.coffee":6,"./components/StationComponent.coffee":7,"./components/WritingComponent.coffee":8,"./utils/move.coffee":15,"./utils/util.coffee":16}],11:[function(require,module,exports){
|
||||
var send;
|
||||
@ -15889,7 +15885,10 @@ var ReactDOMOption = {
|
||||
}
|
||||
});
|
||||
|
||||
nativeProps.children = content;
|
||||
if (content) {
|
||||
nativeProps.children = content;
|
||||
}
|
||||
|
||||
return nativeProps;
|
||||
}
|
||||
|
||||
@ -22058,7 +22057,7 @@ module.exports = ReactUpdates;
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = '0.14.6';
|
||||
module.exports = '0.14.7';
|
||||
},{}],121:[function(require,module,exports){
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
@ -23153,6 +23152,7 @@ var warning = require('fbjs/lib/warning');
|
||||
*/
|
||||
var EventInterface = {
|
||||
type: null,
|
||||
target: null,
|
||||
// currentTarget is set when dispatching; no use in copying it here
|
||||
currentTarget: emptyFunction.thatReturnsNull,
|
||||
eventPhase: null,
|
||||
@ -23186,8 +23186,6 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent
|
||||
this.dispatchConfig = dispatchConfig;
|
||||
this.dispatchMarker = dispatchMarker;
|
||||
this.nativeEvent = nativeEvent;
|
||||
this.target = nativeEventTarget;
|
||||
this.currentTarget = nativeEventTarget;
|
||||
|
||||
var Interface = this.constructor.Interface;
|
||||
for (var propName in Interface) {
|
||||
@ -23198,7 +23196,11 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEvent
|
||||
if (normalize) {
|
||||
this[propName] = normalize(nativeEvent);
|
||||
} else {
|
||||
this[propName] = nativeEvent[propName];
|
||||
if (propName === 'target') {
|
||||
this.target = nativeEventTarget;
|
||||
} else {
|
||||
this[propName] = nativeEvent[propName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user