shrub/main/app/terminal/core.hook
2014-09-22 18:00:25 -07:00

157 lines
4.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:'''
body, body * {
background-color: black;
color: greenyellow;
border-color: #0f2;
}
'''
==
;body
;button(onclick "jpok('new', 'shell')"): Boot
;button(onclick "jpok('del', 'shell')"): unBoot
;pre#cont;
;span#prem:">" ;input#prom;
;script:'''
$(prom).keydown(function(e){
if(e.which != 13) return;
prem.textContent += prom.value
jpok('line', prom.value)
$(this).val('')
})
$(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]
(turn (~(tap in (~(get ju pus.hid) /lines))) jell)
::
%new
~& poke-sire/jof
=. q.hiz :_(q.hiz leaf/"+ {(trip +.jof)}")
:_ +>.$
:+ [ost %give %nice ~]
[ost %pass /hi %g %sire [+ +]:jof]
(turn (~(tap in (~(get ju pus.hid) /lines))) jell)
::
%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)])
++ 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)
`+>.$
:_ +>.$
[ost %give +.sih]~
::
++ 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))
==
--