shrub/main/app/terminal/core.hook
2014-10-01 00:29:32 +00:00

197 lines
5.7 KiB
Plaintext

:: Terminal
::
:::: /hook/core/terminal/app
::
/? 314 :: need urbit 314
/- term-line
::
:::: structures
::
|% ::
++ axle $: %0 ::
hiz=term-line ::
== ::
++ gilt ::
$% [%term-line p=term-line] ::
[%hymn p=manx] ::
[%json p=json] ::
== ::
++ gift ::
$% [%rush gilt] ::
[%rust gilt] ::
[%mean p=ares] ::
[%nice ~] ::
== ::
++ hapt ,[p=ship q=path] ::
++ move ,[p=bone q=(mold note gift)] ::
++ note ::
$% $: %g ::
$% [%cide p=span] ::
[%show p=hapt q=ship r=path] ::
[%sire p=term q=span] ::
[%mess p=hapt q=ship r=[%txt vase]] ::
== == == ::
++ sign ::
$% $: %g ::
$% [%gone p=hapt] ::
[%mean p=ares] ::
[%nice ~] ::
== == ==
--
!:
:::: program
::
|_ [hid=hide axle]
++ page
^- manx
;html
;head
;title: Hi
;script(src "/gen/main/lib/urb.js");
;script(src "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js");
;script: urb.appl = "{(trip app.hid)}"
;script:'''
jpok = function(a,b){
var dat = {}
dat[a] = b
urb.send({data:dat})
}
'''
;style:'''
html {
font-size: 14px;
}
body {
margin: 2rem;
}
body,
span,
input {
font-family: monospace;
font-size: 1rem;
background-color: #000;
color: #fff;
}
button {
border: none;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 600;
font-size: .8rem;
text-transform: uppercase;
letter-spacing: 1px;
color: #000;
background-color: #fff;
padding: 1rem;
}
input {
border: 0;
outline: none;
width: 90%;
}
'''
==
;body
;pre#cont;
;span#prem:">" ;input#prom;
;br;
;button(onclick "jpok('new', 'shell')"): Boot
;button(onclick "jpok('del', 'shell')"): unBoot
;script:'''
$(prom).keydown(function(e){
if(e.which != 13) return;
prem.textContent += prom.value
jpok('line', prom.value)
$(this).val('')
})
$(prom).focus()
$(prem).on('click', function() { $(prom).focus(); })
urb.subscribe({path: '/lines'}, function(e, dat){
if(dat.data.ok) return;
cont.textContent = dat.data.lines.join('\n')
prem.textContent = dat.data.prompt + '> '
})
'''
==
==
::
++ peer
|= [ost=bone you=ship pax=path]
^- [(list move) _+>]
:_ +>.$ :_ ~
?~ pax
[ost %give %rust %hymn page]
?+ -.pax !!
%lines (jell ost)
==
::
++ poke-json
|= [ost=bone you=ship jon=json]
^- [(list move) _+>]
=+ jof=(need ((of line/so new/so del/so ~):jo jon))
?- -.jof
%del
=. q.hiz :_(q.hiz leaf/"- {(trip +.jof)}")
:_ +>.$
:+ [ost %give %mean ~ %hey ~]
[ost %pass /hi %g %cide +.jof]
spam
::
%new
~& poke-sire/jof
=. q.hiz :_(q.hiz leaf/"+ {(trip +.jof)}")
:_ +>.$
:+ [ost %give %nice ~]
[ost %pass /hi %g %sire [+ +]:jof]
spam
::
%line
=. q.hiz :_(q.hiz leaf/"{(trip p.hiz)}> {(trip +.jof)}")
:_ +>.$
%+ turn (~(tap by cub.hid))
|= [p=span q=term]
[ost %pass /txt/[p] %g %mess [our.hid p imp.hid] you %txt !>(+.jof)]
==
::
++ jell |=(a=bone [a %give %rust %json (tel-to-jon hiz)])
++ spam (turn (~(tap in (~(get ju pus.hid) /lines))) jell)
++ poke-term-line
|= [ost=bone you=ship tel=term-line]
^- [(list move) _+>]
=. hiz [p.tel (weld q.tel q.hiz)]
:_ +>.$
:- [ost %give %nice ~]
(turn (~(tap in (~(get ju pus.hid) /lines))) jell)
::
++ pour
|= [ost=bone pax=path sih=sign]
^- [(list move) _+>]
?: ?=(%gone +<.sih)
`+>.$
=+ old=q.hiz
=. q.hiz
?. ?=(%mean &2.sih) q.hiz
=- %- welp :_ q.hiz
%+ turn
(flop -)
|=(a=tank rose/[~ "! " ~]^[a]~)
^- (list tank)
?~ p.sih ~
:- leaf/(trip p.u.p.sih)
(flop q.u.p.sih)
:_ +>.$
:- [ost %give +.sih]
?:(=(old q.hiz) ~ spam)
::
++ tel-to-jon
|= tel=term-line
%- jobe
:~ [%prompt %s p.tel]
:+ %lines %a
%- turn :_ jape
^- wall %- zing
^- (list wall)
%- flop
(turn q.tel (cury wash 0 80))
==
--