Merge branch 'test' of github.com:urbit/urbit into test

This commit is contained in:
Galen Wolfe-Pauly 2015-05-14 14:05:30 -07:00
commit 4a13e03bd9
4 changed files with 63 additions and 20 deletions

View File

@ -200,7 +200,7 @@
%pass %pass
/ /
%c %c
[%warp [our our] %home `[%sing %y [%ud 1] /]] [%warp [our our] %base `[%sing %y [%ud 1] /]]
== ==
== ==
:: ::

View File

@ -64,7 +64,7 @@
?- -.dex ?- -.dex
%del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex) %del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
%ins ?: =(p.sin p.dex) %ins ?: =(p.sin p.dex)
?:((gth q.sin q.dex) dex dex(p +(p.dex))) ?:((lth q.sin q.dex) dex dex(p +(p.dex)))
?:((lte p.sin p.dex) dex(p +(p.dex)) dex) ?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
== ==
== ==

View File

@ -18,7 +18,7 @@
"mousetrap/1.4.6/mousetrap.js" "mousetrap/1.4.6/mousetrap.js"
"react/0.11.0/react.js" "react/0.11.0/react.js"
== ==
;script(src "/~/at/base/lib/urb.js"); ;script(src "{(spud /~~/~/at/[&2:%]/lib/'urb.js')}");
;script: urb.appl = 'dojo' ;script: urb.appl = 'dojo'
;style:''' ;style:'''
#term { #term {

View File

@ -3,13 +3,17 @@
str = JSON.stringify str = JSON.stringify
Prompt = recl render: -> Prompt = recl render: ->
[pro,cur,buf] = [@props.prompt, @props.cursor, @props.input + " "] [pro,cur,buf] = [@props.appl+@props.prompt[@props.appl], @props.cursor, @props.input + " "]
pre {}, pro, pre {}, pro,
span {style: background: 'lightgray'}, buf.slice(0,cur), "\u0332", buf.slice(cur) span {style: background: 'lightgray'}, buf.slice(0,cur), "\u0332", buf.slice(cur)
Matr = recl render: -> Matr = recl render: ->
lines = @props.rows.map (lin)-> pre {}, lin, " " lines = @props.rows.map (lin)-> pre {}, lin, " "
lines.push Prompt {prompt:@props.prompt, input:@props.input, cursor:@props.cursor} lines.push Prompt
appl: @props.appl,
prompt: @props.prompt,
input: @props.input,
cursor: @props.cursor
div {}, lines div {}, lines
$ -> $ ->
@ -42,7 +46,8 @@ $ ->
matr = rend (Matr matr = rend (Matr
rows:[] rows:[]
prompt:"" appl:""
prompt:{"": "# "}
input:"" input:""
cursor:0 cursor:0
history:[] history:[]
@ -51,17 +56,24 @@ $ ->
update = (a) -> matr.setProps a update = (a) -> matr.setProps a
buffer = new Share "" buffer = new Share ""
window.buffer = buffer window.buffer = buffer
choose = (appl)-> urb.appl = appl; update {appl}
print = (txt)-> update rows: [matr.props.rows..., txt]
sync = (ted)-> sync = (ted)->
update input: buffer.buf, cursor: buffer.transpose ted, matr.props.cursor update input: buffer.buf, cursor: buffer.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}
peer = (ruh) -> peer = (ruh,app) ->
if ruh.map then return ruh.map peer app ?= urb.appl
if ruh.map then return ruh.map (rul)-> peer rul, app
mapr = matr.props mapr = matr.props
switch Object.keys(ruh)[0] switch Object.keys(ruh)[0]
when 'txt' then update rows: [mapr.rows..., ruh.txt] when 'txt' then print ruh.txt
when 'tan' then ruh.tan.split("\n").reverse().map (txt)-> peer {txt} when 'tan' then ruh.tan.split("\n").reverse().map print
when 'pro' then updPrompt app, ruh.pro.cad
when 'hop' then update cursor: ruh.hop; bell() # XX buffer.transpose? when 'hop' then update cursor: ruh.hop; bell() # XX buffer.transpose?
when 'pro' then update prompt: ruh.pro.cad
when 'blk' then console.log "Stub #{str ruh}" when 'blk' then console.log "Stub #{str ruh}"
when 'det' then buffer.receive ruh.det; sync ruh.det.ted when 'det' then buffer.receive ruh.det; sync ruh.det.ted
when 'act' then switch ruh.act when 'act' then switch ruh.act
@ -77,10 +89,25 @@ $ ->
# else throw "Unknown "+(JSON.stringify ruh) # else throw "Unknown "+(JSON.stringify ruh)
else v = Object.keys(ruh); console.log v, ruh[v[0]] else v = Object.keys(ruh); console.log v, ruh[v[0]]
urb.bind "/sole", {wire:"/"}, (err,d)-> join = (app)->
if err then console.log err if matr.props.prompt[app]?
else if d.data then peer d.data return print '# already-joined: '+app
choose app
updPrompt "", null
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
update appl: apps[1 + apps.indexOf matr.props.appl] ? apps[0]
part = (appl)->
unless matr.props.prompt[app]?
return print '# not-joined: '+app
urb.unsubscribe {appl, path: "/sole", wire: "/"}
if appl is matr.props.appl then cycle()
updPrompt appl, null
join urb.appl
window.join = join; window.part = part
pressed = [] pressed = []
deltim = null deltim = null
@ -96,8 +123,16 @@ $ ->
# ), 500 # ), 500
sendAction = (data)-> sendAction = (data)->
urb.send {mark: 'sole-action', data}, (e,res)-> if urb.appl then urb.send {mark: 'sole-action', data}, (e,res)->
if res.status isnt 200 then $('#err')[0].innerText = res.data.mess 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?
return bell()
else switch buffer.buf[0]
when '+' then join app
when '-' then part app
else bell()
doEdit = (ted)-> doEdit = (ted)->
det = buffer.transmit ted det = buffer.transmit ted
@ -141,13 +176,21 @@ $ ->
when 'a','left' then update cursor: 0 when 'a','left' then update cursor: 0
when 'e','right' then update cursor: mapr.input.length when 'e','right' then update cursor: mapr.input.length
when 'l' then update rows: [] when 'l' then update rows: []
when 'entr' then peer act: 'bel' when 'entr' then bell()
when 'w' then eatKyev ['alt'], act:'baxp' when 'w' then eatKyev ['alt'], act:'baxp'
when 'p' then eatKyev [], act: 'up' when 'p' then eatKyev [], act: 'up'
when 'n' then eatKyev [], act: 'down' when 'n' then eatKyev [], act: 'down'
when 'b' then eatKyev [], act: 'left' when 'b' then eatKyev [], act: 'left'
when 'f' then eatKyev [], act: 'right' when 'f' then eatKyev [], act: 'right'
when 'g' then bell() when 'g' then bell()
when 'x' then cycle()
when 'v'
if mapr.appl = ""
updPrompt "", null
cycle()
apps = Object.keys mapr.prompt
updPrompt "", (apps.join ", ")+'# '
choose ''
when 't' when 't'
if mapr.cursor is 0 or mapr.input.length < 2 if mapr.cursor is 0 or mapr.input.length < 2
return bell() return bell()