urbit/main/app/terminal/core.hook

197 lines
5.8 KiB
Plaintext
Raw Normal View History

2014-09-12 06:11:03 +04:00
:: 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 ::
2014-09-23 02:20:47 +04:00
$% [%cide p=span] ::
[%show p=hapt q=ship r=path] ::
2014-09-12 06:11:03 +04:00
[%sire p=term q=span] ::
[%mess p=hapt q=ship r=[%txt vase]] ::
== == == ::
++ sign ::
$% $: %g ::
2014-09-23 02:20:47 +04:00
$% [%gone p=hapt] ::
2014-09-12 06:11:03 +04:00
[%mean p=ares] ::
2014-09-23 02:20:47 +04:00
[%nice ~] ::
2014-09-12 06:11:03 +04:00
== == ==
--
!:
:::: program
::
|_ [hid=hide axle]
++ page
^- manx
;html
;head
;title: Hi
2014-09-23 05:00:25 +04:00
;script(src "/gen/main/lib/urb.js");
2014-09-18 06:56:49 +04:00
;script(src "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js");
2014-09-12 06:11:03 +04:00
;script: urb.appl = "{(trip app.hid)}"
2014-09-18 06:56:49 +04:00
;script:'''
jpok = function(a,b){
var dat = {}
dat[a] = b
urb.send({data:dat})
}
'''
;style:'''
2014-09-27 05:34:28 +04:00
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;
2014-10-01 01:53:37 +04:00
width: 90%;
2014-09-18 06:56:49 +04:00
}
'''
2014-09-12 06:11:03 +04:00
==
;body
2014-09-18 06:56:49 +04:00
;pre#cont;
;span#prem:">" ;input#prom;
2014-09-27 05:34:28 +04:00
;br;
;button(onclick "jpok('new', 'shell')"): Boot
;button(onclick "jpok('del', 'shell')"): unBoot
2014-09-18 06:56:49 +04:00
;script:'''
$(prom).keydown(function(e){
if(e.which != 13) return;
prem.textContent += prom.value
jpok('line', prom.value)
$(this).val('')
})
2014-09-23 05:00:25 +04:00
$(prom).focus()
2014-09-27 05:34:28 +04:00
$(prem).on('click', function() { $(prom).focus(); })
2014-09-18 06:56:49 +04:00
urb.subscribe({path: '/lines'}, function(e, dat){
if(dat.data.ok) return;
cont.textContent = dat.data.lines.join('\n')
prem.textContent = dat.data.prompt + '> '
})
'''
2014-09-12 06:11:03 +04:00
==
==
::
++ peer
|= [ost=bone you=ship pax=path]
^- [(list move) _+>]
:_ +>.$ :_ ~
?~ pax
[ost %give %rust %hymn page]
?+ -.pax !!
2014-09-18 06:56:49 +04:00
%lines (jell ost)
2014-09-12 06:11:03 +04:00
==
::
++ poke-json
|= [ost=bone you=ship jon=json]
^- [(list move) _+>]
2014-09-23 02:20:47 +04:00
=+ jof=(need ((of line/so new/so del/so ~):jo jon))
2014-09-12 06:11:03 +04:00
?- -.jof
2014-09-23 02:20:47 +04:00
%del
=. q.hiz :_(q.hiz leaf/"- {(trip +.jof)}")
:_ +>.$
:+ [ost %give %mean ~ %hey ~]
[ost %pass /hi %g %cide +.jof]
2014-09-25 04:37:29 +04:00
spam
2014-09-23 02:20:47 +04:00
::
2014-09-12 06:11:03 +04:00
%new
~& poke-sire/jof
2014-09-18 06:56:49 +04:00
=. q.hiz :_(q.hiz leaf/"+ {(trip +.jof)}")
:_ +>.$
:+ [ost %give %nice ~]
2014-09-23 02:20:47 +04:00
[ost %pass /hi %g %sire [+ +]:jof]
2014-09-25 04:37:29 +04:00
spam
2014-09-23 02:20:47 +04:00
::
2014-09-12 06:11:03 +04:00
%line
2014-09-18 06:56:49 +04:00
=. q.hiz :_(q.hiz leaf/"{(trip p.hiz)}> {(trip +.jof)}")
:_ +>.$
2014-09-12 06:11:03 +04:00
%+ turn (~(tap by cub.hid))
|= [p=span q=term]
[ost %pass /txt/[p] %g %mess [our.hid p imp.hid] you %txt !>(+.jof)]
==
::
2014-09-18 06:56:49 +04:00
++ jell |=(a=bone [a %give %rust %json (tel-to-jon hiz)])
2014-09-25 04:37:29 +04:00
++ spam (turn (~(tap in (~(get ju pus.hid) /lines))) jell)
2014-09-12 06:11:03 +04:00
++ poke-term-line
|= [ost=bone you=ship tel=term-line]
^- [(list move) _+>]
=. hiz [p.tel (weld q.tel q.hiz)]
:_ +>.$
:- [ost %give %nice ~]
2014-09-18 06:56:49 +04:00
(turn (~(tap in (~(get ju pus.hid) /lines))) jell)
2014-09-12 06:11:03 +04:00
::
++ pour
2014-09-18 06:56:49 +04:00
|= [ost=bone pax=path sih=sign]
2014-09-12 06:11:03 +04:00
^- [(list move) _+>]
2014-09-23 02:20:47 +04:00
?: ?=(%gone +<.sih)
`+>.$
2014-09-25 04:37:29 +04:00
=+ old=q.hiz
=. q.hiz
?. ?=(%mean &2.sih) q.hiz
2014-10-01 01:07:40 +04:00
=- %- welp :_ q.hiz
%+ turn
`(list tank)`[leaf/"fail" (flop -)]
|=(a=tank rose/[~ "! " ~]^[a]~)
^- (list tank)
?~ p.sih ~
:- leaf/(trip p.u.p.sih)
2014-09-25 04:37:29 +04:00
(flop q.u.p.sih)
2014-09-12 06:11:03 +04:00
:_ +>.$
2014-09-25 04:37:29 +04:00
:- [ost %give +.sih]
?:(=(old q.hiz) ~ spam)
2014-09-12 06:11:03 +04:00
::
++ 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))
==
--