shrub/arvo/dill.hoon

557 lines
18 KiB
Plaintext
Raw Normal View History

2014-06-06 03:48:13 +04:00
::
2013-09-29 00:21:18 +04:00
:: dill (4d), terminal handling
::
2013-12-15 09:42:27 +04:00
|= pit=vase
2014-06-03 09:07:32 +04:00
=> |%
++ gift :: out result <-$
2014-06-06 03:48:13 +04:00
$% [%bbye ~] :: reset prompt
[%blit p=(list blit)] :: terminal output
[%init p=@p] :: report install
[%logo p=@] :: logout
[%send p=lane q=@] :: transmit packet
[%veer p=@ta q=path r=@t] :: install vane
[%vega p=path] :: reboot by path
==
2014-06-03 09:07:32 +04:00
++ kiss :: in request ->$
2014-06-06 02:14:49 +04:00
$% [%belt p=belt] :: terminal input
[%blew p=blew] :: terminal config
[%boot p=note] :: weird %dill boot
[%crud p=@tas q=(list tank)] :: error with trace
[%flog p=flog] :: wrapped error
[%hail ~] :: terminal refresh
[%noop ~] :: no operation
2014-06-06 05:48:53 +04:00
[%talk p=tank] ::
[%text p=tape] ::
2014-06-06 02:14:49 +04:00
[%wipe ~] :: clear terminal
== ::
++ flog :: sent to %dill
$% [%crud p=@tas q=(list tank)] ::
[%text p=tape] ::
== ::
2014-06-03 09:07:32 +04:00
++ move ,[p=duct q=(mold note gift)] :: local move
++ note :: out request $->
2014-06-06 03:00:19 +04:00
$% [%crud p=@tas q=(list tank)] :: to %dill
[%hail ~] :: to %batz
[%kill p=~] :: to %batz
[%line p=@t] :: to %batz
[%ling ~] :: to %batz
[%make p=(unit ,@t) q=@ud r=@ s=?] :: to %batz
[%sith p=@p q=@uw r=?] :: to %batz
[%text p=tape] :: to %dill
2014-06-06 02:14:49 +04:00
== ::
2014-06-06 03:00:19 +04:00
++ sign :: in result $-<
$% [%crud p=@tas q=(list tank)] :: by any
[%hail ~] :: by %batz
[%helo p=path q=prod] :: by %batz
[%init p=@p] :: by %ames
[%logo p=@] :: by %batz
[%note p=@tD q=tank] :: by any
[%save p=path q=@] :: by %batz
[%send p=lane q=@] :: by %ames
[%talk p=tank] :: by %batz
[%tell p=(list ,@t)] :: by %batz
[%text p=tape] :: by %batz
[%veer p=@ta q=path r=@t] :: by %batz
[%vega p=path] :: by %batz
[%warn p=tape] :: by %batz
==
2014-06-06 02:14:49 +04:00
-- =>
|%
++ dy
|= [hen=duct dug=(map duct yard)]
=+ wip=|
2013-09-29 00:21:18 +04:00
=+ ^= yar ^- yard
2014-06-06 02:14:49 +04:00
=+ yur=(~(get by dug) hen)
?^ yur u.yur
[& [80 ~ *blot] ~]
2013-09-29 00:21:18 +04:00
=| mos=(list move)
|%
++ beep (curb [[%bel ~] ~]) :: send beep
++ curb :: send blits
2013-12-15 09:42:27 +04:00
|= wab=(list blit)
2013-09-29 00:21:18 +04:00
^+ +>
?~ wab +>
2014-05-24 00:46:43 +04:00
+>(mos [[hen [%give %blit (flop wab)]] mos])
2013-09-29 00:21:18 +04:00
::
2014-01-07 01:43:44 +04:00
++ wod :: word forward
2014-06-02 01:07:13 +04:00
|= bed=bein
2014-01-07 01:43:44 +04:00
^- @ud
?: =(bul.bed bus.bed)
bus.bed
?: =(' ' (snag bus.bed but.bed))
$(bus.bed +(bus.bed))
|-
^- @ud
?: =(bul.bed bus.bed)
bus.bed
?: =(' ' (snag bus.bed but.bed))
bus.bed
$(bus.bed +(bus.bed))
::
++ wob :: word backward
2014-06-02 01:07:13 +04:00
|= bed=bein
2014-01-07 01:43:44 +04:00
^- @ud
?: =(0 bus.bed)
bus.bed
?: =(' ' (snag (dec bus.bed) but.bed))
$(bus.bed (dec bus.bed))
|-
^- @ud
?: =(0 bus.bed)
bus.bed
?: =(' ' (snag (dec bus.bed) but.bed))
bus.bed
$(bus.bed (dec bus.bed))
::
2013-09-29 00:21:18 +04:00
++ edit :: change the bed
2014-06-02 01:07:13 +04:00
|= bed=bein
2013-09-29 00:21:18 +04:00
^+ +>
=. q.q.yar [~ bed]
2013-12-24 00:49:15 +04:00
?> ?=(^ q.q.yar)
2013-09-29 00:21:18 +04:00
%- curb
|- ^- (list blit)
?^ hyr.u.q.q.yar
=+ ris=:(weld "(reverse-i-search)'" (tufa u.hyr.u.q.q.yar) "': ")
%= $
pot.bed ris
pol.bed (lent ris)
hyr.u.q.q.yar ~
==
2013-09-29 00:21:18 +04:00
:~ [%hop (add pol.bed bus.bed)]
:- %lin
%+ weld pot.bed
?- buy.bed
%none but.bed
%text but.bed
%pass `(list ,@)`(runt [(lent but.bed) '*'] ~)
==
==
::
++ fume :: print tank, prefix
2013-12-15 09:42:27 +04:00
|= [pef=@tD tac=tank]
2013-09-29 00:21:18 +04:00
^+ +>
=+ wol=(~(win re tac) 2 p.q.yar)
%- furl
%+ turn wol
2013-12-15 09:42:27 +04:00
|= a=tape ^- tape
2013-09-29 00:21:18 +04:00
?> ?=([@ @ *] a)
[pef ' ' t.t.a]
::
++ furl :: print wall
2013-12-15 09:42:27 +04:00
|= wol=(list tape)
2013-09-29 00:21:18 +04:00
^+ +>
=. +>
%- curb
%- flop
|- ^- (list blit)
?~ wol ~
[[%lin (tuba i.wol)] [%mor ~] $(wol t.wol)]
?~ q.q.yar +>
(edit(q.q.yar ~) u.q.q.yar)
::
++ gore :: move in history
2013-12-15 09:42:27 +04:00
|= hup=@ud
2013-09-29 00:21:18 +04:00
^+ +>
=+ but=(goth hup)
2013-09-29 00:21:18 +04:00
=+ bul=(lent but)
%- edit
2013-12-24 00:49:15 +04:00
?> ?=(^ q.q.yar)
2013-09-29 00:21:18 +04:00
%= u.q.q.yar
hiz hup
hym %+ ~(put by hym.u.q.q.yar)
hiz.u.q.q.yar
but.u.q.q.yar
bus bul
bul bul
2013-09-29 00:21:18 +04:00
but but
==
::
++ goth :: extract history
2013-12-15 09:42:27 +04:00
|= hup=@ud
2013-12-24 00:49:15 +04:00
?> ?=(^ q.q.yar)
=+ byt=(~(get by hym.u.q.q.yar) hup)
?^ byt u.byt
(tuba (rip 3 (snag hup q.hyt.u.q.q.yar)))
::
2013-09-29 00:21:18 +04:00
++ kill :: add to kill ring
2013-12-15 09:42:27 +04:00
|= txt=(list ,@c)
2013-09-29 00:21:18 +04:00
^+ +>
=> ?. =(16 p.r.q.yar) .
.(p.r.q.yar 15, r.r.q.yar (scag 15 r.r.q.yar))
%= +>
p.r.q.yar +(p.r.q.yar)
q.r.q.yar 0
r.r.q.yar [txt r.r.q.yar]
==
::
++ look :: search in history
2013-12-15 09:42:27 +04:00
|= [hup=@ud txt=(list ,@c)]
^+ +>
=+ ^= beg
2013-12-15 09:42:27 +04:00
|= [a=(list ,@c) b=(list ,@c)] ^- ?
?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b))))
=+ ^= mid
2013-12-15 09:42:27 +04:00
|= [a=(list ,@c) b=(list ,@c)] ^- ?
?~(a & ?~(b | |((beg a b) $(b t.b))))
2013-12-24 00:49:15 +04:00
?> ?=(^ q.q.yar)
?: =(hup p.hyt.u.q.q.yar)
beep
=+ but=(goth hup)
?: (mid txt but)
(gore(hyr.u.q.q.yar [~ txt]) hup)
$(hup +(hup))
::
2014-06-06 02:14:49 +04:00
++ leap :: accept response
|= [tea=wire sin=sign]
^+ +>
2014-06-06 03:00:19 +04:00
?- -.sin
2014-06-06 02:14:49 +04:00
%crud :: error trace
=. q.sin [[%leaf (trip p.sin)] q.sin]
|- ^+ +>.^$
?~ q.sin +>.^$
(fume:$(q.sin t.q.sin) '!' `tank`i.q.sin)
::
%helo :: trigger prompt
%- edit
=| bed=bein
=+ ^= hyt ^- hist
=+ hyt=(~(get by r.yar) p.sin)
?~(hyt *hist u.hyt)
?: &(?=(^ q.q.yar) =(p.sin hux.u.q.q.yar))
%= u.q.q.yar
hyt [+(p.hyt) [%$ q.hyt]]
pot q.q.sin
pol (lent q.q.sin)
buy p.q.sin
==
=+ zon=(tuba r.q.sin)
=+ zow=(lent zon)
%= bed
bul zow
bus zow
but zon
buy p.q.sin
hux p.sin
hiz 0
hyt [+(p.hyt) [%$ q.hyt]]
pot q.q.sin
pol (lent q.q.sin)
==
::
2014-06-06 03:00:19 +04:00
?(%hail %make %sith)
2014-06-06 02:14:49 +04:00
+>.$(mos :_(mos [hen %toss %b ~ sin]))
::
%note ?.(p.yar +>.$ (fume p.sin q.sin)) :: debug message
%save :: write a file
%= +>.$
mos :_(mos [hen [%give %blit [%sav p.sin q.sin] ~]])
==
::
%tell (furl (turn p.sin |=(a=@t (trip a)))) :: wall of text
%talk (furl (~(win re p.sin) 0 p.q.yar)) :: program output
2014-06-06 05:48:53 +04:00
%text $(sin [%talk %leaf p.sin]) :: simple message
2014-06-06 02:14:49 +04:00
%warn (fume '~' [%leaf p.sin]) :: system message
2014-06-06 03:00:19 +04:00
?(%init %logo %send %veer %vega)
+>(mos :_(mos [hen %give sin]))
2014-06-06 02:14:49 +04:00
==
::
++ lear :: handle request
|= kyz=kiss
^+ +>
?- -.kyz
%flog !!
%noop +>
2013-09-29 00:21:18 +04:00
%belt :: terminal input
?~ q.q.yar
beep
?^ hyr.u.q.q.yar :: live search
2014-06-06 02:14:49 +04:00
?+ p.kyz $(hiz.u.q.q.yar 0, hyr.u.q.q.yar ~)
[%bac *]
?: =(~ u.hyr.u.q.q.yar)
(curb [[%bel ~] ~])
%- edit
%= u.q.q.yar
hyr [~ (scag (dec (lent u.hyr.u.q.q.yar)) u.hyr.u.q.q.yar)]
==
::
2014-06-06 02:14:49 +04:00
[%txt *] (look hiz.u.q.q.yar (weld u.hyr.u.q.q.yar p.p.kyz))
[%ctl %g] (edit u.q.q.yar(bul 0, bus 0, but ~, hiz 0, hyr ~))
[%ctl %r]
?: =(p.hyt.u.q.q.yar hiz.u.q.q.yar)
beep
(look +(hiz.u.q.q.yar) u.hyr.u.q.q.yar)
==
2014-06-06 02:14:49 +04:00
?- -.p.kyz
2013-09-29 00:21:18 +04:00
%aro :: arrow
2014-06-06 02:14:49 +04:00
?- p.p.kyz
2013-09-29 00:21:18 +04:00
%d :: down
?: =(0 hiz.u.q.q.yar)
beep
(gore (dec hiz.u.q.q.yar))
::
%l :: left
?: =(0 bus.u.q.q.yar)
beep
(edit u.q.q.yar(bus (dec bus.u.q.q.yar)))
::
%r :: right
?: =(bul.u.q.q.yar bus.u.q.q.yar)
beep
(edit u.q.q.yar(bus +(bus.u.q.q.yar)))
::
%u
=+ hup=+(hiz.u.q.q.yar)
?: =(hup p.hyt.u.q.q.yar)
beep
(gore hup)
==
::
%bac :: backspace
2014-06-06 02:14:49 +04:00
^+ +>.$
2013-09-29 00:21:18 +04:00
?: =(0 bus.u.q.q.yar)
(curb `(list blit)`[[%bel ~] ~])
%- edit
%= u.q.q.yar
bus (dec bus.u.q.q.yar)
bul (dec bul.u.q.q.yar)
but
%+ weld
2013-09-29 00:21:18 +04:00
(scag (dec bus.u.q.q.yar) but.u.q.q.yar)
(slag bus.u.q.q.yar but.u.q.q.yar)
==
::
%ctl :: control
2014-06-06 02:14:49 +04:00
?+ p.p.kyz
2013-09-29 00:21:18 +04:00
beep
%a (edit u.q.q.yar(bus 0))
2014-06-06 02:14:49 +04:00
%b $(kyz [%belt %aro %l])
2013-09-29 00:21:18 +04:00
%d ?: ?& =(0 bul.u.q.q.yar)
=(0 bus.u.q.q.yar)
==
2014-06-06 02:14:49 +04:00
+>.$(mos :_(mos [hen %toss %b ~ [%kill ~]]))
$(kyz [%belt %del ~])
2013-09-29 00:21:18 +04:00
%e (edit u.q.q.yar(bus bul.u.q.q.yar))
2014-06-06 02:14:49 +04:00
%f $(kyz [%belt %aro %r])
2013-09-29 00:21:18 +04:00
%k ?: =(bul.u.q.q.yar bus.u.q.q.yar)
beep
2014-06-06 02:14:49 +04:00
=> .(+>.$ (kill (slag bus.u.q.q.yar but.u.q.q.yar)))
2013-09-29 00:21:18 +04:00
%- edit
2013-12-24 00:49:15 +04:00
?> ?=(^ q.q.yar)
2013-09-29 00:21:18 +04:00
%= u.q.q.yar
bul bus.u.q.q.yar
but (scag bus.u.q.q.yar but.u.q.q.yar)
==
%t ?: (lth bul.u.q.q.yar 2)
beep
=+ ^= pos
2014-01-24 13:16:31 +04:00
?: =(bul.u.q.q.yar bus.u.q.q.yar)
(sub bus.u.q.q.yar 2)
?: =(0 bus.u.q.q.yar)
bus.u.q.q.yar
(dec bus.u.q.q.yar)
%- edit
%= u.q.q.yar
bus (add 2 pos)
but %+ weld
%+ weld
(scag pos but.u.q.q.yar)
^- (list ,@c) :+
(snag +(pos) but.u.q.q.yar)
(snag pos but.u.q.q.yar)
~
(slag (add 2 pos) but.u.q.q.yar)
==
2014-06-06 02:14:49 +04:00
%l +>.$(mos :_(mos [hen %give %blit [[%clr ~] ~]]))
%n $(kyz [%belt %aro %d])
%p $(kyz [%belt %aro %u])
2013-09-29 00:21:18 +04:00
%u ?: =(0 bus.u.q.q.yar)
beep
2014-06-06 02:14:49 +04:00
=> .(+>.$ (kill (scag bus.u.q.q.yar but.u.q.q.yar)))
2013-09-29 00:21:18 +04:00
%- edit
2013-12-24 00:49:15 +04:00
?> ?=(^ q.q.yar)
2013-09-29 00:21:18 +04:00
%= u.q.q.yar
bus 0
bul (sub bul.u.q.q.yar bus.u.q.q.yar)
but (slag bus.u.q.q.yar but.u.q.q.yar)
==
%r (edit u.q.q.yar(hyr [~ ~]))
2014-03-12 00:34:06 +04:00
:: TODO
2014-06-06 02:14:49 +04:00
:: %w +>.$(mos :_(mos [hen %toss %b ~ [%limn ~]]))
%x +>.$(mos :_(mos [hen %toss %b ~ [%ling ~]]))
2013-09-29 00:21:18 +04:00
%y ?: =(0 p.r.q.yar)
beep
2014-06-06 02:14:49 +04:00
$(kyz [%belt %txt (snag q.r.q.yar r.r.q.yar)])
2013-09-29 00:21:18 +04:00
==
::
%del :: delete
?: =(bul.u.q.q.yar bus.u.q.q.yar)
beep
%- edit
%= u.q.q.yar
bul (dec bul.u.q.q.yar)
but
%+ weld
2013-09-29 00:21:18 +04:00
(scag bus.u.q.q.yar but.u.q.q.yar)
(slag +(bus.u.q.q.yar) but.u.q.q.yar)
==
::
%met :: meta
2014-06-06 02:14:49 +04:00
?+ p.p.kyz
2013-09-29 00:21:18 +04:00
beep
2014-01-07 01:43:44 +04:00
%f
?: =(bul.u.q.q.yar bus.u.q.q.yar)
beep
(edit u.q.q.yar(bus (wod u.q.q.yar)))
::
%b
?: =(0 bus.u.q.q.yar)
beep
(edit u.q.q.yar(bus (wob u.q.q.yar)))
::
%y
2013-09-29 00:21:18 +04:00
?: =(0 p.r.q.yar)
beep
=+ dol=(snag q.r.q.yar r.r.q.yar)
=+ leo=(lent dol)
?. (gte bus.u.q.q.yar leo)
beep
=+ pey=(sub bus.u.q.q.yar leo)
?. =(dol (swag [pey leo] but.u.q.q.yar))
beep
=. q.r.q.yar ?:(=(p.r.q.yar +(q.r.q.yar)) 0 +(q.r.q.yar))
=+ ney=(snag q.r.q.yar r.r.q.yar)
=+ lye=(lent ney)
%- edit
%= u.q.q.yar
bus (sub (add bus.u.q.q.yar lye) leo)
bul (sub (add bul.u.q.q.yar lye) leo)
but %+ weld
(scag pey but.u.q.q.yar)
%+ weld
`(list ,@c)`ney :: XX weird fuse-loop
(slag bus.u.q.q.yar but.u.q.q.yar)
==
==
::
%ret :: return
2013-11-16 01:51:58 +04:00
?: =(%none buy.u.q.q.yar) beep
2013-09-29 00:21:18 +04:00
=+ jab=(rap 3 (tufa but.u.q.q.yar))
2014-06-06 02:14:49 +04:00
%= +>.$
2013-09-29 00:21:18 +04:00
q.q.yar ~
r.yar
?: |(=(%$ jab) =(%pass buy.u.q.q.yar))
r.yar
2013-09-29 00:21:18 +04:00
%+ ~(put by r.yar)
hux.u.q.q.yar
2013-11-14 02:38:04 +04:00
[p.hyt.u.q.q.yar [jab ?~(q.hyt.u.q.q.yar ~ +.q.hyt.u.q.q.yar)]]
2013-09-29 00:21:18 +04:00
::
mos
:* [hen %toss %b ~ [%hail ~]]
2014-05-24 00:46:43 +04:00
[hen %give [%bbye ~]]
[hen %toss %b ~ [%line jab]]
2014-05-24 00:46:43 +04:00
[hen %give [%blit [[%mor ~] ~]]]
2013-09-29 00:21:18 +04:00
mos
==
==
::
%txt :: text keys
2013-11-16 01:51:58 +04:00
?: =(%none buy.u.q.q.yar) beep
2014-06-06 02:14:49 +04:00
=+ let=(lent p.p.kyz)
2013-09-29 00:21:18 +04:00
%- edit
%= u.q.q.yar
bus (add let bus.u.q.q.yar)
bul (add let bul.u.q.q.yar)
but
2013-09-29 00:21:18 +04:00
;: weld
(scag bus.u.q.q.yar but.u.q.q.yar)
2014-06-06 02:14:49 +04:00
p.p.kyz
2013-09-29 00:21:18 +04:00
(slag bus.u.q.q.yar but.u.q.q.yar)
==
==
==
::
2014-06-06 02:14:49 +04:00
%blew +>.$(p.q.yar p.p.kyz) :: window size
2013-09-29 00:21:18 +04:00
%boot
2014-06-06 02:14:49 +04:00
%= +>.$
2013-09-29 00:21:18 +04:00
mos
2014-06-06 02:14:49 +04:00
:_(mos [hen %toss %b ~ p.kyz])
2013-09-29 00:21:18 +04:00
==
::
%crud :: error trace
2014-06-06 02:14:49 +04:00
=. q.kyz [[%leaf (trip p.kyz)] q.kyz]
|- ^+ +>.^$
?~ q.kyz +>.^$
(fume:$(q.kyz t.q.kyz) '!' `tank`i.q.kyz)
2013-09-29 00:21:18 +04:00
::
2014-06-06 02:14:49 +04:00
%hail :: refresh
+>.$(mos :_(mos [hen %toss %b ~ kyz]))
2014-06-06 05:48:53 +04:00
::
%talk (furl (~(win re p.kyz) 0 p.q.yar)) :: program output
%text $(kyz [%talk %leaf p.kyz]) :: simple message
2013-09-29 00:21:18 +04:00
::
2014-06-06 02:14:49 +04:00
%wipe +>.$(wip &) :: delete old
2013-09-29 00:21:18 +04:00
==
::
++ yerk :: complete core
2014-06-06 02:14:49 +04:00
^- [p=(list move) q=(map duct yard)]
2013-09-29 00:21:18 +04:00
:- (flop mos)
2014-06-06 02:14:49 +04:00
?.(wip (~(put by dug) hen yar) (~(del by dug) hen))
2013-09-29 00:21:18 +04:00
--
2014-06-06 02:14:49 +04:00
--
=| $: %0 ::
dug=(map duct yard) ::
== ::
|= [now=@da eny=@ ski=sled] :: current invocation
|% :: poke/peek pattern
++ call :: handle request
|= $: hen=duct
hic=(hypo (hobo kiss))
==
^- [p=(list move) q=_..^$]
=> %= . :: XX temporary
q.hic
^- kiss
?: ?=(%soft -.q.hic)
:: ~& [%dill-call-soft (,@tas `*`-.p.q.hic)]
((hard kiss) p.q.hic)
?: (~(nest ut -:!>(*kiss)) | p.hic) q.hic
~& [%dill-call-flub (,@tas `*`-.q.hic)]
((hard kiss) q.hic)
==
?: ?=(%flog -.q.hic)
:_ ..^$
%+ turn (~(tap by dug) *(list ,[p=duct q=yard]))
|=([a=duct b=yard] [a %slip %d p.q.hic])
=^ moz dug yerk:(lear:(dy hen dug) q.hic)
[moz ..^$]
2014-05-22 21:39:51 +04:00
::
2013-09-29 00:21:18 +04:00
++ doze
2013-12-15 09:42:27 +04:00
|= [now=@da hen=duct]
2013-09-29 00:21:18 +04:00
^- (unit ,@da)
~
::
++ load
2014-05-31 23:40:02 +04:00
|= old=[%0 dug=(map duct yard)]
2014-05-31 03:51:35 +04:00
^+ ..^$
2014-05-31 23:40:02 +04:00
..^$(dug dug.old)
2013-09-29 00:21:18 +04:00
::
++ scry
2014-05-27 00:43:40 +04:00
|= [fur=(unit (set monk)) ren=@tas his=ship syd=desk lot=coin tyl=path]
2014-06-01 00:22:49 +04:00
^- (unit (unit (pair lode ,*)))
2013-09-29 00:21:18 +04:00
~
::
2014-05-31 23:40:02 +04:00
++ stay [%0 dug]
2014-06-06 02:14:49 +04:00
++ take :: process move
|= [tea=wire hen=duct hin=(hypo sign)]
^- [p=(list move) q=_..^$]
=> %= . :: XX temporary
q.hin
^- sign
?: (~(nest ut -:!>(*sign)) | p.hin) q.hin
~& [%dill-take-flub (,@tas `*`-.q.hin)]
((hard sign) q.hin)
==
=^ moz dug yerk:(leap:(dy hen dug) tea q.hin)
[moz ..^$]
2013-09-29 00:21:18 +04:00
--