mirror of
https://github.com/urbit/shrub.git
synced 2024-12-04 14:58:10 +03:00
Merge branch 'nobreach' into test
This commit is contained in:
commit
39108ab80e
@ -1055,6 +1055,7 @@
|
||||
|= [max=@ud nul=@u fin=@ud] ^- @ud
|
||||
=+ dog=|-(?:(=(0 fin) 1 (mul 10 $(fin (div fin 10)))))
|
||||
=. dog (mul dog (pow 10 nul))
|
||||
=- ?:((lte - max) - (sub - dog))
|
||||
(add fin (sub max (mod max dog)))
|
||||
::
|
||||
++ probe :: inquire
|
||||
|
@ -288,6 +288,7 @@
|
||||
?> ?=(~ saw)
|
||||
[~ +>.$]
|
||||
::
|
||||
++ quit-peering |=(way=wire ?>(?=(~ way) initialize(connected |)))
|
||||
++ reap-peering
|
||||
|= [way=wire saw=(unit tang)]
|
||||
^- [(list move) _+>.$]
|
||||
|
34
ape/write.hoon
Normal file
34
ape/write.hoon
Normal file
@ -0,0 +1,34 @@
|
||||
:: File writer
|
||||
::
|
||||
:::: /hoon/write/app
|
||||
::
|
||||
|_ [bowl ~]
|
||||
++ beak-now byk(r [%da now])
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
=- (poke--data (need (- jon.+)))
|
||||
=> jo
|
||||
%- ot :~
|
||||
pax/(cu deft (su fel:stab))
|
||||
dat/(of json/some mime/(pe / (cu taco so)) ~) :: XX mite
|
||||
==
|
||||
::
|
||||
++ poke-write-paste
|
||||
|= [typ=?(%hoon %md %txt) txt=@t]
|
||||
(poke--data [`typ /pub/paste/(scot %da now)] %mime / (taco txt))
|
||||
::
|
||||
++ poke--data
|
||||
|= [[ext=(unit ,@t) pax=path] dat=$%([%json json] [%mime mime])]
|
||||
?~ ext $(ext [~ -.dat])
|
||||
=+ cay=?-(-.dat %json [-.dat !>(+.dat)], %mime [-.dat !>(+.dat)])
|
||||
?: =(u.ext -.dat) (made pax ~ `cay)
|
||||
[[ost %exec pax our ~ beak-now %cast u.ext `cay]~ +>.$] :: XX defer %nice
|
||||
::
|
||||
++ made
|
||||
|= [pax=wire @ res=gage]
|
||||
?+ -.res ~|(gage/-.res !!)
|
||||
%| (mean p.res)
|
||||
%& =- [[ost %info / our -]~ +>.$]
|
||||
(foal :(welp (tope beak-now ~) pax /[-.p.res]) p.res)
|
||||
==
|
||||
--
|
@ -1025,10 +1025,15 @@
|
||||
++ lamp :: normalize version
|
||||
|= [cof=cafe bem=beam]
|
||||
^- (bolt beam)
|
||||
?: ?=(%ud -.r.bem) (fine cof bem)
|
||||
=+ von=(save ~ %cw bem(s ~))
|
||||
?~ von [p=cof q=[%1 [%w bem ~] ~ ~]]
|
||||
(fine cof bem(r [%ud ((hard ,@) +.+:(need u.von))]))
|
||||
%+ cope
|
||||
?: ?=(%ud -.r.bem) (fine cof bem)
|
||||
=+ von=(save ~ %cw bem(s ~))
|
||||
?~ von [p=cof q=[%1 [%w bem ~] ~ ~]]
|
||||
(fine cof bem(r [%ud ((hard ,@) +.+:(need u.von))]))
|
||||
|= [cof=cafe bem=[[ship desk %ud r=@u] s=spur]]
|
||||
?: =(0 r.bem)
|
||||
(flaw cof [leaf/"ford: no data: {(tope bem(s ~))}"]~)
|
||||
(fine cof bem)
|
||||
::
|
||||
++ lave :: validate
|
||||
|= [cof=cafe for=mark som=*]
|
||||
|
@ -3,12 +3,21 @@ CodeMirror.defineMode("hoon", function() {
|
||||
term = /^[$&|]|^[a-z]([a-z0-9\-]*[a-z0-9])?/
|
||||
num = /-?-?^[0-9]([0-9.]*|[xwbv]?[0-9a-zA-Z.-~]*)/
|
||||
res = {}
|
||||
res.startState = function(){return {soblock: false, doqblock:false, sail:false, space:true}}
|
||||
res.startState = function(){return {soblock: false, doqblock:false, inter:[], sail:false, space:true}}
|
||||
var propOrVar = function(c){
|
||||
if(c == '.')
|
||||
return 'property'
|
||||
return 'variable'
|
||||
}
|
||||
var nomQuote = function(stream,state){
|
||||
reg = new RegExp('^[^'+state.inter[0]+'{\\\\]')
|
||||
while(stream.match(reg) || stream.match(/\\./));
|
||||
if(!stream.eat("{")) {
|
||||
if(state.inter[0]){stream.eat(state.inter[0])}
|
||||
state.inter.shift()
|
||||
}
|
||||
return 'string'
|
||||
}
|
||||
res.token = function(stream, state){
|
||||
if(state.soqblock && stream.sol()){
|
||||
if(stream.match(/\s*'''/)){
|
||||
@ -28,6 +37,9 @@ CodeMirror.defineMode("hoon", function() {
|
||||
}
|
||||
return "string"
|
||||
}
|
||||
if((state.inter.length) && stream.eat('}')){
|
||||
return nomQuote(stream,state)
|
||||
}
|
||||
|
||||
if(stream.sol())
|
||||
state.space = true
|
||||
@ -36,6 +48,7 @@ CodeMirror.defineMode("hoon", function() {
|
||||
if(stream.peek().match(/[^#./() ]/)||stream.eol()){
|
||||
state.sail = false
|
||||
if(stream.match(/:? /)){
|
||||
// state.inter = ''
|
||||
stream.skipToEnd()
|
||||
return 'string'
|
||||
}
|
||||
@ -62,9 +75,8 @@ CodeMirror.defineMode("hoon", function() {
|
||||
stream.skipToEnd()
|
||||
return 'string'
|
||||
}
|
||||
while(stream.match(/^[^"\\]/) || stream.match(/\\./));
|
||||
stream.eat('"')
|
||||
return 'string'
|
||||
state.inter.unshift('"')
|
||||
return nomQuote(stream,state)
|
||||
}
|
||||
if(stream.match(' ;')){
|
||||
if(stream.eat(' ')){
|
||||
@ -149,7 +161,11 @@ CodeMirror.defineMode("hoon", function() {
|
||||
state.space = true
|
||||
return
|
||||
}
|
||||
if(stream.eat(')') || stream.eat(']')){ // XX paren match
|
||||
return
|
||||
}
|
||||
stream.next()
|
||||
return "error"
|
||||
}
|
||||
res.lineComment = '::'
|
||||
res.fold = "indent"
|
||||
|
12
mar/write-paste.hoon
Normal file
12
mar/write-paste.hoon
Normal file
@ -0,0 +1,12 @@
|
||||
::
|
||||
:::: /hoon/core/save/mar
|
||||
::
|
||||
!:
|
||||
|_ [typ=?(%hoon %md %txt) txt=@t]
|
||||
++ grab
|
||||
|%
|
||||
++ noun ,[?(%hoon %md %txt) @t]
|
||||
++ json
|
||||
(corl need =>(jo (ot typ/(ci (soft ?(%hoon %md %txt)) so) txt/so ~)))
|
||||
--
|
||||
--
|
30
pub/paste/elem.hook
Normal file
30
pub/paste/elem.hook
Normal file
@ -0,0 +1,30 @@
|
||||
/= all /; flop /^ (list (pair time ,*)) /: /%%/ /& /mime/
|
||||
;div
|
||||
;script@"//code.jquery.com/jquery-2.1.4.min.js";
|
||||
;script@"/~/at/home/lib/urb.js";
|
||||
;script:'''
|
||||
urb.appl = 'write'
|
||||
urb.send.mark = 'write-paste'
|
||||
submit = function(){
|
||||
urb.send({
|
||||
txt:$("textarea").val(),
|
||||
typ:$("select :selected").val()
|
||||
}, function(){
|
||||
$.getJSON('paste/new.json',null,function(resp){
|
||||
if(!resp) throw "No paste"
|
||||
window.location = "paste/"+resp.u
|
||||
})})
|
||||
}
|
||||
'''
|
||||
::
|
||||
;p:textarea;
|
||||
;button(onclick "submit()"):"Submit"
|
||||
;select
|
||||
;option(value "md"): Markdown
|
||||
;option(value "txt"): Text
|
||||
;option(value "hoon"): Hoon
|
||||
==
|
||||
;hr;
|
||||
; recent:
|
||||
;* (turn all |=([a=time *] ;p:a/"paste/{<a>}":"{<a>}"))
|
||||
==
|
2
pub/paste/new/json.hook
Normal file
2
pub/paste/new/json.hook
Normal file
@ -0,0 +1,2 @@
|
||||
/= all /^ (list (pair time ,*)) /: /%%%/ /& /mime/
|
||||
?~(all ~ (joba %u |-(?~(t.all s/(scot %da p.i.all) $(all t.all)))))
|
@ -82,7 +82,7 @@ $ ->
|
||||
mapr = matr.props
|
||||
switch Object.keys(ruh)[0]
|
||||
when 'txt' then print ruh.txt
|
||||
when 'tan' then ruh.tan.split("\n").reverse().map print
|
||||
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}"
|
||||
|
Loading…
Reference in New Issue
Block a user