urbit/main/app/terminal/core.hook

221 lines
6.7 KiB
Plaintext
Raw Normal View History

2014-09-12 06:11:03 +04:00
:: Terminal
::
:::: /hook/core/terminal/app
::
/? 314 :: need urbit 314
2014-10-10 01:58:47 +04:00
/- term-line, kyev
2014-10-14 00:00:28 +04:00
/= stat /:/%%/:/hymn/
2014-09-12 06:11:03 +04:00
::
:::: structures
::
|% ::
++ axle $: %1 ::
hiz=(map path term-line) ::
2014-09-12 06:11:03 +04:00
== ::
++ gilt ::
$% [%term-line p=term-line] ::
[%hymn p=manx] ::
[%json p=json] ::
== ::
++ gift ::
$% [%rush gilt] ::
[%rust gilt] ::
[%mean p=ares] ::
[%nice ~] ::
2014-10-04 02:31:16 +04:00
[%veer p=@ta q=path r=@t] ::
[%vega p=path] ::
2014-09-12 06:11:03 +04:00
== ::
++ 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] ::
2014-10-10 01:58:47 +04:00
[%mess p=hapt q=ship r=[?(%txt %kyev) vase]] ::
2014-09-12 06:11:03 +04:00
== == == ::
++ 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-10-03 02:21:23 +04:00
[%rust p=%term-line q=term-line] ::
[%rush p=%term-line q=term-line] ::
2014-10-04 02:31:16 +04:00
[%veer p=@ta q=path r=@t] ::
[%vega p=path] ::
2014-09-12 06:11:03 +04:00
== == ==
--
::
2014-10-14 00:00:28 +04:00
:::: helpers
::
|%
++ encode
|= [a=term b=path] ^- span
(rap 3 a (turn b |=(c=span (cat 3 '_' c))))
::
++ decode |=(a=span `[p=term q=path]`(rash a (most cab sym)))
2014-10-14 00:00:28 +04:00
++ inject
|= [a=[i=mane t=(list mane)] b=marl]
|= man=manx
?. =(i.a n.g.man)
man
?~ t.a
man(c (weld c.man b))
man(c (turn c.man ^$(a t.a)))
--
2014-09-12 06:11:03 +04:00
!:
:::: program
::
|_ [hid=hide axle]
++ page
|= pax=path
2014-10-14 00:00:28 +04:00
%. stat
%+ inject
~[%html %head]
;= ;script: urb.appl = "{(trip app.hid)}"
;script: urb.term = \{pax: "{(spud pax)}"}
2014-09-12 06:11:03 +04:00
==
::
++ peer
|= [ost=bone you=ship pax=path]
^- [(list move) _+>]
?~ pax
$(pax /term)
2014-09-12 06:11:03 +04:00
?+ -.pax !!
%lines
:_ +>.$
:_ ~
(jell ost t.pax)
%term
=+ tel=(fall (~(get by hiz) t.pax) *term-line)
2014-10-03 03:00:57 +04:00
=^ mof r.tel
=+ aut=%shell
2014-10-11 03:34:29 +04:00
=+ auc=(encode aut t.pax)
?: (~(has by cub.hid) auc)
2014-10-03 03:00:57 +04:00
[~ r.tel]
:_ :_(r.tel leaf/"+ {(trip aut)}")
2014-10-11 03:34:29 +04:00
:_ [ost %pass [%hi auc mar/[t.pax]] %g %sire [aut auc]]~
:^ ost %pass [%hi auc in/[t.pax]]
:+ %g %show
2014-10-11 03:34:29 +04:00
[[our.hid [auc imp.hid]] you /out]
2014-10-02 23:56:53 +04:00
=. hiz (~(put by hiz) t.pax tel)
2014-10-02 23:46:00 +04:00
:_ +>.$
[[ost %give %rust %hymn (page t.pax)] mof]
2014-09-12 06:11:03 +04:00
==
::
++ poke-json
|= [ost=bone you=ship jon=json]
^- [(list move) _+>]
2014-10-08 23:29:21 +04:00
::~& tem-poke/jon
2014-10-10 02:33:00 +04:00
=+ ^- [pax=path jof=$%([%line p=span] [%res p=span] [%cmd p=char])]
%- need
2014-10-10 01:58:47 +04:00
%. jon => jo
%^ ot
pax/(su ;~(pfix fas (more fas sym)))
act/(of line/so res/so cmd/so ~)
~
2014-10-10 02:33:00 +04:00
|-
=+ tel=(fall (~(get by hiz) pax) *term-line)
2014-09-12 06:11:03 +04:00
?- -.jof
%res
2014-10-11 03:34:29 +04:00
=+ joc=(encode p.jof pax)
2014-10-03 03:00:57 +04:00
=^ mof r.tel
2014-10-11 03:34:29 +04:00
?. (~(has by cub.hid) joc)
2014-10-03 03:00:57 +04:00
[~ r.tel]
:_ :_(r.tel leaf/"- {(trip p.jof)}")
2014-10-11 03:34:29 +04:00
[ost %pass [%hi joc mar/pax] %g %cide joc]~
2014-10-02 23:46:00 +04:00
::~& poke-sire/[jof cub.hid]
2014-10-11 03:34:29 +04:00
=. r.tel :_(r.tel leaf/"+ {(trip joc)}")
2014-10-02 23:46:00 +04:00
=. hiz (~(put by hiz) pax tel)
2014-10-10 02:33:00 +04:00
:_ +>.^$
%+ welp mof
2014-10-03 02:21:23 +04:00
:^ [ost %give %nice ~]
2014-10-11 03:34:29 +04:00
:^ ost %pass [%hi joc in/[pax]]
:^ %g %show [our.hid joc imp.hid]
2014-10-03 02:21:23 +04:00
:- you /out
2014-10-11 03:34:29 +04:00
[ost %pass [%hi joc mar/pax] %g %sire [p.jof joc]]
(spam pax)
2014-09-23 02:20:47 +04:00
::
2014-09-12 06:11:03 +04:00
%line
2014-10-11 01:16:19 +04:00
=. r.tel :_(r.tel rose/["> " ~ ~]^~[leaf/(trip p.tel) leaf/(trip p.jof)])
2014-10-02 23:46:00 +04:00
=. hiz (~(put by hiz) pax tel)
2014-10-10 02:40:45 +04:00
?: =('\\' (end 3 1 p.jof))
$(jof [%cmd (rsh 3 1 p.jof)])
2014-10-10 02:33:00 +04:00
:_ +>.^$
2014-10-10 01:58:47 +04:00
(send ost you pax %txt !>(p.jof))
%cmd
2014-10-10 02:33:00 +04:00
?+ p.jof :_(+>.^$ (send ost you pax %kyev !>(`kyev`[[%ctrl ~ ~] p.jof])))
%r $(jof [%res 'shell'])
==
2014-09-12 06:11:03 +04:00
==
2014-10-10 01:58:47 +04:00
++ send
|= [ost=bone you=ship pax=path mez=[?(%txt %kyev) vase]]
%+ murn (~(tap by cub.hid))
|= [p=span q=term]
?. =(pax q:(decode p)) ~
%- some ^- move
2014-10-11 03:34:29 +04:00
:^ ost %pass [-.mez p (scot %da lat.hid) pax]
[%g %mess [our.hid p imp.hid] you mez]
2014-09-12 06:11:03 +04:00
::
++ jell
|= [a=bone b=path]
[a %give %rust %json (tel-to-jon (fall (~(get by hiz) b) *term-line))]
2014-10-02 23:46:00 +04:00
::
++ spam
|= pax=path
2014-10-08 23:29:21 +04:00
::~& tem-spam/(~(run by hiz) |=(term-line p))
%+ murn
(~(tap by sup.hid))
|= [ost=bone @ paf=path]
?. =([%lines pax] paf) ~
(some (jell ost pax))
2014-10-02 23:46:00 +04:00
::
2014-09-12 06:11:03 +04:00
++ pour
2014-10-08 03:05:44 +04:00
|= [ost=bone pax=path sih=*]
2014-09-12 06:11:03 +04:00
^- [(list move) _+>]
2014-10-08 03:05:44 +04:00
=+ sih=((hard sign) sih)
2014-10-11 03:34:29 +04:00
?: ?=(?(%veer %vega) &2.sih) :: vomit
2014-10-04 02:31:16 +04:00
[[ost %give +.sih]~ +>.$]
2014-10-11 03:34:29 +04:00
?: ?=(%gone &2.sih)
`+>.$
=* paf |3.pax
?: ?=([%hi @ %in *] pax)
?+ &2.sih !!
2014-10-03 02:21:23 +04:00
%nice `+>.$
?(%rust %rush)
=+ tol=(fall (~(get by hiz) paf) *term-line)
2014-10-08 23:29:21 +04:00
=. tol ?^ q.q.sih :: XX prompt hack
[p.tol (weld q.q.sih q.tol) (weld r.q.sih r.tol)]
[p.q.sih (weld q.q.sih q.tol) (weld r.q.sih r.tol)]
=. hiz (~(put by hiz) paf tol)
[(spam paf) +>.$]
2014-10-03 02:21:23 +04:00
==
2014-10-02 23:56:53 +04:00
=+ tel=(fall (~(get by hiz) paf) *term-line)
=+ old=tel
2014-10-03 03:00:57 +04:00
=. r.tel
?. ?=(%mean &2.sih) r.tel
%- welp :_ r.tel
=- (turn - |=(a=tank rose/[~ "! " ~]^[a]~))
2014-10-01 01:07:40 +04:00
^- (list tank)
?~ p.sih ~
2014-10-03 03:00:57 +04:00
(welp q.u.p.sih leaf/(trip p.u.p.sih) ~)
2014-10-02 23:56:53 +04:00
=. hiz (~(put by hiz) paf tel)
2014-10-02 23:46:00 +04:00
:_ +>.$
2014-09-25 04:37:29 +04:00
:- [ost %give +.sih]
2014-10-14 03:21:20 +04:00
::?: =(old tel) ~
(spam paf)
2014-09-12 06:11:03 +04:00
::
++ tel-to-jon
|= tel=term-line
%- jobe
:~ [%prompt %s p.tel]
2014-10-03 03:00:57 +04:00
[%history %a (turn q.tel |=(a=cord [%s a]))]
2014-09-12 06:11:03 +04:00
:+ %lines %a
2014-10-11 01:16:19 +04:00
%- zing ^- (list (list json))
2014-10-11 03:34:29 +04:00
%+ turn (flop r.tel) |= a=tank
2014-10-11 01:16:19 +04:00
?. ?=([%rose [[%'>' %' ' ~] ~ ~] [%leaf *] [%leaf *] ~] a)
(turn (wash 0^80 a) jape)
[(jobe prompt/(jape p.i.q.a) task/(jape p.i.t.q.a) ~)]~
2014-09-12 06:11:03 +04:00
==
--