urbit/arvo/dill.hoon

459 lines
14 KiB
Plaintext
Raw Normal View History

!:
2013-09-29 00:21:18 +04:00
:: dill (4d), terminal handling
::
2013-12-15 09:42:27 +04:00
|= pit=vase
2014-05-31 02:10:39 +04:00
=| $: %0 ::
dug=(map duct yard) ::
2013-09-29 00:21:18 +04:00
== ::
2014-05-31 23:40:02 +04:00
|= [now=@da eny=@ ski=sled] :: current invocation
2013-09-29 00:21:18 +04:00
^? :: opaque core
|% :: poke/peek pattern
++ take :: process move
2014-05-26 22:59:21 +04:00
|= [tea=wire hen=duct typ=type fav=card]
2014-05-31 03:51:35 +04:00
^- [p=(list move) q=_..^$]
2013-09-29 00:21:18 +04:00
?: ?=(%flog -.fav)
:_ ..^$
%+ turn (~(tap by dug) *(list ,[p=duct q=yard]))
2014-05-26 00:35:07 +04:00
|=([a=duct b=yard] [a %slip %d p.fav])
?: ?=(%soft -.fav)
$(fav ((hard card) p.fav))
2013-09-29 00:21:18 +04:00
=+ ^= yar ^- yard
=+ yar=(~(get by dug) hen)
?^ yar u.yar
[& [80 ~ *blot] ~]
=| mos=(list move)
=+ wip=|
=< yerk:leap
|%
++ 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-05-27 13:47:19 +04:00
|= bed=bean
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-05-27 13:47:19 +04:00
|= bed=bean
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-05-27 13:47:19 +04:00
|= bed=bean
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))
::
2013-09-29 00:21:18 +04:00
++ leap :: terminal event
|- ^+ +
2014-05-24 00:46:43 +04:00
?+ -.fav +(mos :_(mos [hen %give fav]))
2013-09-29 00:21:18 +04:00
%noop +
%belt :: terminal input
?~ q.q.yar
beep
?^ hyr.u.q.q.yar :: live search
?+ p.fav $(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)]
==
::
[%txt *] (look hiz.u.q.q.yar (weld u.hyr.u.q.q.yar p.p.fav))
[%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)
==
2013-09-29 00:21:18 +04:00
?- -.p.fav
%aro :: arrow
?- p.p.fav
%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
^+ +.$
?: =(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
?+ p.p.fav
beep
%a (edit u.q.q.yar(bus 0))
%b $(fav [%belt %aro %l])
%d ?: ?& =(0 bul.u.q.q.yar)
=(0 bus.u.q.q.yar)
==
+.$(mos :_(mos [hen %toss %b ~ [%kill ~]]))
2013-09-29 00:21:18 +04:00
$(fav [%belt %del ~])
%e (edit u.q.q.yar(bus bul.u.q.q.yar))
%f $(fav [%belt %aro %r])
%k ?: =(bul.u.q.q.yar bus.u.q.q.yar)
beep
=> .(+.$ (kill (slag bus.u.q.q.yar but.u.q.q.yar)))
%- 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-05-24 00:46:43 +04:00
%l +.$(mos :_(mos [hen %give %blit [[%clr ~] ~]]))
2013-09-29 00:21:18 +04:00
%n $(fav [%belt %aro %d])
%p $(fav [%belt %aro %u])
%u ?: =(0 bus.u.q.q.yar)
beep
=> .(+.$ (kill (scag bus.u.q.q.yar but.u.q.q.yar)))
%- 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
:: %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
$(fav [%belt %txt (snag q.r.q.yar r.r.q.yar)])
==
::
%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
?+ p.p.fav
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))
%= +.$
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
2013-09-29 00:21:18 +04:00
=+ let=(lent p.p.fav)
%- 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)
p.p.fav
(slag bus.u.q.q.yar but.u.q.q.yar)
==
==
==
::
%blew +.$(p.q.yar p.p.fav) :: window size
%boot
%= +.$
mos
:_(mos [hen %toss %b tea p.fav])
2013-09-29 00:21:18 +04:00
==
::
%crud :: error trace
=. q.fav [[%leaf (trip p.fav)] q.fav]
|- ^+ +.^$
?~ q.fav +.^$
(fume:$(q.fav t.q.fav) '!' i.q.fav)
::
%helo :: trigger prompt
%- edit
2014-05-27 13:47:19 +04:00
=| bed=bean
2013-09-29 00:21:18 +04:00
=+ ^= hyt ^- hist
=+ hyt=(~(get by r.yar) p.fav)
?~(hyt *hist u.hyt)
2013-11-14 02:38:04 +04:00
?: &(?=(^ q.q.yar) =(p.fav hux.u.q.q.yar))
%= u.q.q.yar
hyt [+(p.hyt) [%$ q.hyt]]
pot q.q.fav
pol (lent q.q.fav)
2013-11-19 02:54:48 +04:00
buy p.q.fav
2013-11-14 02:38:04 +04:00
==
2013-09-29 00:21:18 +04:00
=+ zon=(tuba r.q.fav)
=+ zow=(lent zon)
%= bed
bul zow
bus zow
but zon
buy p.q.fav
hux p.fav
hiz 0
hyt [+(p.hyt) [%$ q.hyt]]
pot q.q.fav
pol (lent q.q.fav)
==
::
?(%hail %make %loin %sith)
+.$(mos :_(mos [hen %toss %b ~ fav]))
2013-09-29 00:21:18 +04:00
::
%note ?.(p.yar +.$ (fume p.fav q.fav)) :: debug message
%save :: write a file
%= +.$
2014-05-24 00:46:43 +04:00
mos :_(mos [hen [%give %blit [%sav p.fav q.fav] ~]])
2013-09-29 00:21:18 +04:00
==
::
2013-12-15 09:42:27 +04:00
%tell (furl (turn p.fav |=(a=@t (trip a)))) :: wall of text
2013-09-29 00:21:18 +04:00
%text $(fav [%talk %leaf p.fav]) :: simple message
%talk (furl (~(win re p.fav) 0 p.q.yar)) :: program output
%warn (fume '~' [%leaf p.fav]) :: system message
%wipe +.$(wip &) :: delete old
==
::
++ yerk :: complete core
^- [p=(list move) q=_..^$]
:- (flop mos)
..^$(dug ?.(wip (~(put by dug) hen yar) (~(del by dug) hen)))
--
::
2014-05-22 21:39:51 +04:00
++ call :: process move
2014-05-26 22:59:21 +04:00
|= [hen=duct typ=type fav=card]
(take ~ hen typ fav)
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]
2013-09-29 00:21:18 +04:00
--