shrub/lib/drum.hoon

798 lines
26 KiB
Plaintext
Raw Normal View History

2015-05-17 04:05:56 +03:00
:: :: ::
2015-06-08 22:48:35 +03:00
:::: /hoon/drum/lib :: ::
2015-05-17 04:05:56 +03:00
:: :: ::
/? 310 :: version
2015-09-02 03:24:18 +03:00
/- sole
2015-09-02 01:20:17 +03:00
/+ sole
2015-09-02 03:24:18 +03:00
[. ^sole]
2015-05-17 04:05:56 +03:00
!: :: ::
:::: :: ::
:: :: ::
|% :: ::
2015-12-09 04:54:26 +03:00
++ drum-part {$drum $0 drum-pith} ::
2015-05-17 04:05:56 +03:00
++ drum-pith ::
2015-12-20 23:50:45 +03:00
$: eel/(set gill) :: connect to
ray/(set well) ::
fur/(map dude (unit server)) :: servers
bin/(map bone source) :: terminals
2015-05-17 04:05:56 +03:00
== ::
++ drum-start well :: start (local) server
:: :: ::
:::: :: ::
:: :: ::
++ server :: running server
2015-12-20 23:50:45 +03:00
$: syd/desk :: app identity
cas/case :: boot case
2015-05-17 04:05:56 +03:00
== ::
++ source :: input device
2015-12-20 23:50:45 +03:00
$: edg/_80 :: terminal columns
off/@ud :: window offset
kil/(unit (list @c)) :: kill buffer
inx/@ud :: ring index
fug/(map gill (unit target)) :: connections
mir/(pair @ud (list @c)) :: mirrored terminal
2015-05-17 04:05:56 +03:00
== ::
++ master :: master buffer
2015-12-20 23:50:45 +03:00
$: liv/? :: master is live
tar/target :: master target
2015-05-17 04:05:56 +03:00
== ::
++ history :: past input
2015-12-20 23:50:45 +03:00
$: pos/@ud :: input position
num/@ud :: number of entries
lay/(map @ud (list @c)) :: editing overlay
old/(list (list @c)) :: entries proper
2015-05-17 04:05:56 +03:00
== ::
++ search :: reverse-i-search
2015-12-20 23:50:45 +03:00
$: pos/@ud :: search position
str/(list @c) :: search string
2015-05-17 04:05:56 +03:00
== ::
++ target :: application target
2015-12-20 23:50:45 +03:00
$: ris/(unit search) :: reverse-i-search
hit/history :: all past input
pom/sole-prompt :: static prompt
inp/sole-command :: input state
2015-05-17 04:05:56 +03:00
== ::
++ ukase :: master command
2015-12-20 23:50:45 +03:00
$% {$add p/(list gill)} :: attach to
{$del p/(list gill)} :: detach from
{$new p/(list well)} :: create
2015-05-17 04:05:56 +03:00
== ::
2015-09-02 01:20:17 +03:00
--
:: :: ::
2015-05-17 04:05:56 +03:00
:::: :: ::
:: :: ::
2015-09-02 01:20:17 +03:00
|%
2015-05-17 04:05:56 +03:00
++ deft-apes :: default servers
2015-12-20 23:50:45 +03:00
|= our/ship
2015-05-17 04:05:56 +03:00
%- ~(gas in *(set well))
=+ myr=(clan our)
?: =(%pawn myr)
2015-07-14 03:46:37 +03:00
[[%base %talk] [%base %dojo] ~]
2015-10-08 01:42:19 +03:00
?: =(%earl myr)
[[%home %dojo] ~]
2015-06-09 18:23:40 +03:00
[[%home %talk] [%home %dojo] ~]
2015-05-17 04:05:56 +03:00
::
++ deft-fish :: default connects
2015-12-20 23:50:45 +03:00
|= our/ship
2015-05-17 04:05:56 +03:00
%- ~(gas in *(set gill))
^- (list gill)
=+ myr=(clan our)
?: =(%earl myr)
2015-10-08 01:42:19 +03:00
[[(sein our) %talk] [our %dojo] ~]
2015-06-09 18:23:40 +03:00
[[our %talk] [our %dojo] ~]
2015-05-17 04:05:56 +03:00
::
++ deft-mast :: default master
2015-12-20 23:50:45 +03:00
|= our/ship
2015-05-17 04:05:56 +03:00
^- master
:* %&
*(unit search)
*history
2015-12-20 14:48:17 +03:00
[%& %sole "{(scow %p our)}/ "]
2015-05-17 04:05:56 +03:00
*sole-command
==
::
++ deft-pipe :: default source
2015-12-20 23:50:45 +03:00
|= our/ship ::
2015-05-17 04:05:56 +03:00
^- source ::
:* 80 :: edg
0 :: off
~ :: kil
0 :: inx
~ :: fug
[0 ~] :: mir
==
::
++ deft-tart *target :: default target
++ drum-port :: initial part
2015-12-20 23:50:45 +03:00
|= our/ship
2015-05-17 04:05:56 +03:00
^- drum-part
:* %drum
%0
(deft-fish our) :: eel
(deft-apes our) :: ray
~ :: fur
~ :: bin
== ::
::
++ drum-path :: encode path
2015-12-20 23:50:45 +03:00
|= gyl/gill
[%drum %phat (scot %p p.gyl) q.gyl ~]
2015-05-17 04:05:56 +03:00
::
++ drum-phat :: decode path
2015-12-20 23:50:45 +03:00
|= way/wire ^- gill
2015-12-09 04:54:26 +03:00
?>(?=({@ @ $~} way) [(slav %p i.way) i.t.way])
2015-09-02 01:20:17 +03:00
--
!:
::::
::
2015-12-09 04:54:26 +03:00
|= {bowl drum-part} :: main drum work
2015-09-02 01:20:17 +03:00
=+ (fall (~(get by bin) ost) (deft-pipe our))
2015-10-23 01:45:48 +03:00
=* dev -
2015-09-02 01:20:17 +03:00
=> |% :: arvo structures
++ pear :: request
2015-12-20 23:50:45 +03:00
$% {$sole-action p/sole-action} ::
2015-12-09 04:54:26 +03:00
{$talk-command command:talk} ::
2015-09-02 01:20:17 +03:00
== ::
++ lime :: update
2015-12-14 10:58:14 +03:00
$% {$dill-blit dill-blit} ::
2015-09-02 01:20:17 +03:00
== ::
++ card :: general card
2015-12-14 10:58:14 +03:00
$% {$conf wire dock $load ship term} ::
2015-12-09 04:54:26 +03:00
{$diff lime} ::
{$peer wire dock path} ::
{$poke wire dock pear} ::
{$pull wire dock $~} ::
2015-09-02 01:20:17 +03:00
== ::
++ move (pair bone card) :: user-level move
--
2015-12-20 23:50:45 +03:00
|_ {moz/(list move) biz/(list dill-blit)}
2015-09-02 01:20:17 +03:00
++ diff-sole-effect-phat ::
2015-12-20 23:50:45 +03:00
|= {way/wire fec/sole-effect}
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
=+ gyl=(drum-phat way)
?: (se-aint gyl) +>.$
(se-diff gyl fec)
::
++ peer ::
2015-12-20 23:50:45 +03:00
|= pax/path =< se-abet
2015-09-02 01:20:17 +03:00
^+ +>
?. ?| =(our src) :: ourself
&(=(%duke (clan our)) =(our (sein src))) :: or our own yacht
== ::
2015-12-21 00:16:39 +03:00
~| [%drum-unauthorized our+our src+src] :: very simplistic
2015-09-02 01:20:17 +03:00
!!
se-view:(se-text "[{<src>}, driving {<our>}]")
::
++ poke-dill-belt ::
2015-12-20 23:50:45 +03:00
|= bet/dill-belt
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
(se-belt bet)
::
++ poke-start ::
2015-12-20 23:50:45 +03:00
|= wel/well
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
(se-born wel)
::
++ poke-link ::
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
(se-link gyl)
::
2015-10-20 23:48:11 +03:00
++ poke-unlink ::
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-10-20 23:48:11 +03:00
=< se-abet =< se-view
(se-klin gyl)
::
2015-09-12 03:07:50 +03:00
:: ++ poke-exit ::
:: |=(~ se-abet:(se-blit `dill-blit`[%qit ~])) :: XX find bone
:: ::
2015-09-02 01:20:17 +03:00
++ reap-phat ::
2015-12-20 23:50:45 +03:00
|= {way/wire saw/(unit tang)}
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
=+ gyl=(drum-phat way)
?~ saw
(se-join gyl)
(se-dump:(se-drop & gyl) u.saw)
::
++ take-coup-phat ::
2015-12-20 23:50:45 +03:00
|= {way/wire saw/(unit tang)}
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
?~ saw +>
=+ gyl=(drum-phat way)
?: (se-aint gyl) +>.$
=. u.saw :_(u.saw >[%drum-coup-fail src ost gyl]<)
(se-dump:(se-drop & gyl) u.saw)
::
++ take-onto ::
2015-12-20 23:50:45 +03:00
|= {way/wire saw/(each suss tang)}
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
2015-12-09 04:54:26 +03:00
?> ?=({@ @ $~} way)
2015-09-02 01:20:17 +03:00
?> (~(has by fur) i.t.way)
=+ wel=`well`[i.way i.t.way]
?- -.saw
$| (se-dump p.saw)
$& ?> =(q.wel p.p.saw)
:: =. +>.$ (se-text "live {<p.saw>}")
+>.$(fur (~(put by fur) q.wel `[p.wel %da r.p.saw]))
2015-09-02 01:20:17 +03:00
==
::
++ quit-phat ::
2015-12-20 23:50:45 +03:00
|= way/wire
2015-09-02 01:20:17 +03:00
=< se-abet =< se-view
=+ gyl=(drum-phat way)
~& [%drum-quit src ost gyl]
(se-drop %| gyl)
:: :: ::
:::: :: ::
:: :: ::
++ se-abet :: resolve
^- (quip move *drum-part)
?. se-ably
=. . se-adit
[(flop moz) +>+>+<+]
2015-10-23 01:45:48 +03:00
=. . se-subze:se-adze:se-adit
2015-09-02 01:20:17 +03:00
:_ %_(+>+>+<+ bin (~(put by bin) ost `source`+>+<))
^- (list move)
%+ welp (flop moz)
^- (list move)
?~ biz ~
[ost %diff %dill-blit ?~(t.biz i.biz [%mor (flop biz)])]~
::
++ se-ably (~(has by sup) ost) :: caused by console
++ se-adit :: update servers
2015-10-23 01:45:48 +03:00
^+ .
%+ roll (~(tap in ray))
=< .(con +>)
2015-12-20 23:50:45 +03:00
|= {wel/well con/_..se-adit} ^+ con
2015-10-23 01:45:48 +03:00
=. +>.$ con
=+ hig=(~(get by fur) q.wel)
2015-12-10 12:17:19 +03:00
?: &(?=(^ hig) |(?=($~ u.hig) =(p.wel syd.u.u.hig))) +>.$
2015-10-23 01:45:48 +03:00
=. +>.$ (se-text "activated app {(trip p.wel)}/{(trip q.wel)}")
%- se-emit(fur (~(put by fur) q.wel ~))
[ost %conf [%drum p.wel q.wel ~] [our q.wel] %load our p.wel]
2015-09-02 01:20:17 +03:00
::
++ se-adze :: update connections
2015-10-23 01:45:48 +03:00
^+ .
%+ roll (~(tap in eel))
=< .(con +>)
2015-12-20 23:50:45 +03:00
|= {gil/gill con/_.} ^+ con
2015-10-23 01:45:48 +03:00
=. +>.$ con
?: (~(has by fug) gil)
+>.$
(se-peer gil)
::
++ se-subze :: downdate connections
=< .(dev (~(got by bin) ost))
=. bin (~(put by bin) ost dev)
^+ .
%- ~(rep by bin)
=< .(con +>)
2015-12-20 23:50:45 +03:00
|= {{ost/bone dev/source} con/_.} ^+ con
2015-10-23 01:45:48 +03:00
=+ xeno=se-subze-local:%_(con ost ost, dev dev)
xeno(ost ost.con, dev dev.con, bin (~(put by bin) ost dev.xeno))
::
++ se-subze-local
^+ .
%- ~(rep by fug)
=< .(con +>)
2015-12-20 23:50:45 +03:00
|= {{gil/gill *} con/_.} ^+ con
2015-10-23 01:45:48 +03:00
=. +>.$ con
?: (~(has in eel) gil)
+>.$
(se-nuke gil)
2015-09-02 01:20:17 +03:00
::
++ se-aint :: ignore result
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
^- ?
?. (~(has by bin) ost) &
=+ gyr=(~(get by fug) gyl)
2015-12-10 12:17:19 +03:00
|(?=($~ gyr) ?=({$~ $~} gyr))
2015-09-02 01:20:17 +03:00
::
++ se-alas :: recalculate index
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
^+ +>
=+ [xin=0 wag=se-amor]
?: =(~ wag) +>.$(inx 0)
|- ^+ +>.^$
?~ wag +>.^$(inx 0)
?: =(i.wag gyl) +>.^$(inx xin)
$(wag t.wag, xin +(xin))
::
++ se-amor :: live targets
^- (list gill)
2015-12-10 12:17:19 +03:00
(skim (~(tap in eel)) |=(gill ?=({$~ $~ *} (~(get by fug) +<))))
2015-09-02 01:20:17 +03:00
::
++ se-anon :: rotate index
=+ wag=se-amor
?~ wag +
2015-12-21 00:16:39 +03:00
:: ~& [%se-anon inx+inx wag+wag nex+(mod +(inx) (lent se-amor))]
2015-09-02 01:20:17 +03:00
+(inx (mod +(inx) (lent se-amor)))
::
++ se-agon :: current gill
^- (unit gill)
=+ wag=se-amor
?~ wag ~
`(snag inx se-amor)
::
++ se-belt :: handle input
2015-12-20 23:50:45 +03:00
|= bet/dill-belt
2015-09-02 01:20:17 +03:00
^+ +>
2015-12-09 04:54:26 +03:00
?: ?=($rez -.bet)
2015-09-02 01:20:17 +03:00
+>(edg (dec p.bet))
2015-12-09 04:54:26 +03:00
?: ?=($yow -.bet)
2015-09-02 01:20:17 +03:00
~& [%no-yow -.bet]
+>
=+ gul=se-agon
=+ tur=`(unit (unit target))`?~(gul ~ (~(get by fug) u.gul))
2015-10-08 01:42:19 +03:00
?: |(=(~ gul) =(~ tur) =([~ ~] tur)) (se-blit %bel ~)
=+ taz=~(. ta [& (need gul)] `target`(need (need tur)))
2015-09-02 01:20:17 +03:00
=< ta-abet
?- -.bet
2015-12-09 04:54:26 +03:00
$aro (ta-aro:taz p.bet)
$bac ta-bac:taz
$cru (ta-cru:taz p.bet q.bet)
$ctl (ta-ctl:taz p.bet)
$del ta-del:taz
$hey taz(mir [0 ~])
$met (ta-met:taz p.bet)
$ret ta-ret:taz
$txt (ta-txt:taz p.bet)
2015-09-02 01:20:17 +03:00
==
::
++ se-born :: new server
2015-12-20 23:50:45 +03:00
|= wel/well
2015-09-02 01:20:17 +03:00
^+ +>
?: (~(has in ray) wel)
(se-text "[already running {<p.wel>}/{<q.wel>}]")
+>(ray (~(put in ray) wel), eel (~(put in eel) [our q.wel]))
::
++ se-drop :: disconnect
2015-12-20 23:50:45 +03:00
|= {pej/? gyl/gill}
2015-09-02 01:20:17 +03:00
^+ +>
=+ lag=se-agon
?. (~(has by fug) gyl) +>.$
=. fug (~(del by fug) gyl)
=. eel ?.(pej eel (~(del in eel) gyl))
=. +>.$ ?. &(?=(^ lag) !=(gyl u.lag))
+>.$(inx 0)
(se-alas u.lag)
=. +>.$ (se-text "[unlinked from {<gyl>}]")
2015-09-08 23:26:31 +03:00
?: =(gyl [our %dojo]) :: undead dojo
2015-06-02 21:36:56 +03:00
(se-link gyl)
2015-10-08 01:42:19 +03:00
+>.$
2015-09-02 01:20:17 +03:00
::
++ se-dump :: print tanks
2015-12-20 23:50:45 +03:00
|= tac/(list tank)
2015-09-02 01:20:17 +03:00
^+ +>
?. se-ably (se-talk tac)
2015-12-20 23:50:45 +03:00
=+ wol=`wall`(zing (turn (flop tac) |=(a/tank (~(win re a) [0 edg]))))
2015-09-02 01:20:17 +03:00
|- ^+ +>.^$
?~ wol +>.^$
$(wol t.wol, +>.^$ (se-blit %out (tuba i.wol)))
::
++ se-joke :: prepare connection
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
^+ +>
=+ lag=se-agon
?~ lag +>.$
?: =(~ fug) +>.$
(se-alas(fug (~(put by fug) gyl ~)) u.lag)
::
++ se-join :: confirm connection
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
^+ +>
=. +> (se-text "[linked to {<gyl>}]")
?> =(~ (~(got by fug) gyl))
2015-10-08 01:42:19 +03:00
(se-alas(fug (~(put by fug) gyl `*target)) gyl)
2015-09-02 01:20:17 +03:00
::
++ se-nuke :: teardown
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
^+ +>
2015-10-08 01:42:19 +03:00
(se-drop:(se-pull gyl) & gyl)
2015-09-02 01:20:17 +03:00
::
++ se-like :: act in master
2015-12-20 23:50:45 +03:00
|= kus/ukase
2015-09-02 01:20:17 +03:00
?- -.kus
2015-12-09 04:54:26 +03:00
$add
2015-05-17 04:05:56 +03:00
|- ^+ +>.^$
2015-09-02 01:20:17 +03:00
?~ p.kus +>.^$
$(p.kus t.p.kus, +>.^$ (se-link i.p.kus))
2015-05-17 04:05:56 +03:00
::
2015-12-09 04:54:26 +03:00
$del
2015-09-02 01:20:17 +03:00
|- ^+ +>.^$
?~ p.kus +>.^$
$(p.kus t.p.kus, +>.^$ (se-nuke i.p.kus))
2015-05-17 04:05:56 +03:00
::
2015-12-09 04:54:26 +03:00
$new
2015-09-02 01:20:17 +03:00
|- ^+ +>.^$
?~ p.kus +>.^$
$(p.kus t.p.kus, +>.^$ (se-born i.p.kus))
==
::
++ se-plot :: status line
^- tape
=+ lag=se-agon
=+ ^= pry
|= gill ^- tape
=+((trip q.+<) ?:(=(our p.+>-) - :(welp (scow %p p.+>-) "/" -)))
=+ ^= yey
|= gill ^- tape
=+((pry +<) ?:(=(lag `+>-) ['*' -] -))
=+ ^= yal ^- (list tape)
%+ weld
^- (list tape)
%+ turn (~(tap by fug))
2015-12-20 23:50:45 +03:00
|= {a/gill b/(unit target)}
2015-09-02 01:20:17 +03:00
=+ c=(yey a)
?~(b ['?' c] c)
^- (list tape)
2015-12-10 12:17:19 +03:00
%+ turn (skip (~(tap by fur)) |=({term *} (~(has by fug) [our +<-])))
2015-12-09 04:54:26 +03:00
|=({term *} ['-' (pry our +<-)])
2015-09-02 01:20:17 +03:00
|- ^- tape
?~ yal ~
?~ t.yal i.yal
:(welp i.yal ", " $(yal t.yal))
::
2015-10-20 23:48:11 +03:00
++ se-klin :: disconnect app
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-10-20 23:48:11 +03:00
+>(eel (~(del in eel) gyl))
::
2015-09-02 01:20:17 +03:00
++ se-link :: connect to app
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
+>(eel (~(put in eel) gyl))
::
++ se-blit :: give output
2015-12-20 23:50:45 +03:00
|= bil/dill-blit
2015-09-02 01:20:17 +03:00
+>(biz [bil biz])
::
++ se-show :: show buffer, raw
2015-12-20 23:50:45 +03:00
|= lin/(pair @ud (list @c))
2015-09-02 01:20:17 +03:00
^+ +>
?: =(mir lin) +>
=. +> ?:(=(q.mir q.lin) +> (se-blit %pro q.lin))
=. +> ?:(=(p.mir p.lin) +> (se-blit %hop p.lin))
+>(mir lin)
::
++ se-just :: adjusted buffer
2015-12-20 23:50:45 +03:00
|= lin/(pair @ud (list @c))
2015-09-02 01:20:17 +03:00
^+ +>
=. off ?:((lth p.lin edg) 0 (sub p.lin edg))
(se-show (sub p.lin off) (scag edg (slag off q.lin)))
::
++ se-view :: flush buffer
=+ gul=se-agon
2015-10-08 01:42:19 +03:00
?~ gul +
2015-09-02 01:20:17 +03:00
=+ gyr=(~(get by fug) u.gul)
2015-10-08 01:42:19 +03:00
?~ gyr +>
?~ u.gyr +>
2015-09-02 01:20:17 +03:00
%- se-just
2015-10-08 01:42:19 +03:00
~(ta-vew ta [& u.gul] u.u.gyr)
2015-09-02 01:20:17 +03:00
::
++ se-emit :: emit move
2015-12-20 23:50:45 +03:00
|= mov/move
2015-09-02 01:20:17 +03:00
%_(+> moz [mov moz])
::
++ se-talk
2015-12-20 23:50:45 +03:00
|= tac/(list tank)
2015-09-02 01:20:17 +03:00
^+ +>
2015-09-02 03:24:18 +03:00
(se-emit 0 %poke /drum/talk [our %talk] (said:talk our %drum now eny tac))
2015-09-02 01:20:17 +03:00
::
++ se-text :: return text
2015-12-20 23:50:45 +03:00
|= txt/tape
2015-09-02 01:20:17 +03:00
^+ +>
?. se-ably (se-talk [%leaf txt]~)
(se-blit %out (tuba txt))
::
++ se-poke :: send a poke
2015-12-20 23:50:45 +03:00
|= {gyl/gill par/pear}
2015-09-02 01:20:17 +03:00
(se-emit ost %poke (drum-path gyl) gyl par)
::
++ se-peer :: send a peer
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
(se-emit(fug (~(put by fug) gyl ~)) ost %peer (drum-path gyl) gyl /sole)
::
++ se-pull :: cancel subscription
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
(se-emit ost %pull (drum-path gyl) gyl ~)
::
++ se-tame :: switch connection
2015-12-20 23:50:45 +03:00
|= gyl/gill
2015-09-02 01:20:17 +03:00
^+ ta
2015-10-08 01:42:19 +03:00
~(. ta [& gyl] (need (~(got by fug) gyl)))
2015-09-02 01:20:17 +03:00
::
++ se-diff :: receive results
2015-12-20 23:50:45 +03:00
|= {gyl/gill fec/sole-effect}
2015-09-02 01:20:17 +03:00
^+ +>
ta-abet:(ta-fec:(se-tame gyl) fec)
::
++ ta :: per target
2015-12-20 23:50:45 +03:00
|_ $: $: liv/? :: don't delete
gyl/gill :: target app
2015-09-02 01:20:17 +03:00
== ::
target :: target state
== ::
++ ta-abet :: resolve
^+ ..ta
?. liv
2015-10-08 01:42:19 +03:00
?: (~(has in (deft-fish our)) gyl)
2015-12-21 00:16:39 +03:00
(se-blit qit+~)
(se-nuke gyl)
2015-09-02 01:20:17 +03:00
..ta(fug (~(put by fug) gyl ``target`+<+))
::
2015-12-20 23:50:45 +03:00
++ ta-poke |=(a/pear +>(..ta (se-poke gyl a))) :: poke gyl
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-act :: send action
2015-12-20 23:50:45 +03:00
|= act/sole-action
2015-05-17 22:39:03 +03:00
^+ +>
(ta-poke %sole-action act)
::
2015-09-02 01:20:17 +03:00
++ ta-aro :: hear arrow
2015-12-20 23:50:45 +03:00
|= key/?($d $l $r $u)
2015-05-17 07:50:05 +03:00
^+ +>
2015-09-02 01:20:17 +03:00
?- key
2015-12-09 04:54:26 +03:00
$d =. ris ~
2015-09-02 01:20:17 +03:00
?. =(num.hit pos.hit)
(ta-mov +(pos.hit))
?: =(0 (lent buf.say.inp))
ta-bel
(ta-hom:ta-nex %set ~)
2015-12-09 04:54:26 +03:00
$l ?: =(0 pos.inp) ta-bel
+>(pos.inp (dec pos.inp), ris ~)
2015-12-09 04:54:26 +03:00
$r ?: =((lent buf.say.inp) pos.inp)
2015-09-02 01:20:17 +03:00
ta-bel
+>(pos.inp +(pos.inp), ris ~)
2015-12-09 04:54:26 +03:00
$u =. ris ~
2015-09-02 01:20:17 +03:00
?:(=(0 pos.hit) ta-bel (ta-mov (dec pos.hit)))
==
2015-05-17 07:50:05 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-bel .(+> (se-blit %bel ~)) :: beep
++ ta-cat :: mass insert
2015-12-20 23:50:45 +03:00
|= {pos/@ud txt/(list @c)}
2015-09-02 01:20:17 +03:00
^- sole-edit
:- %mor
|- ^- (list sole-edit)
?~ txt ~
[[%ins pos i.txt] $(pos +(pos), txt t.txt)]
::
++ ta-cut :: mass delete
2015-12-20 23:50:45 +03:00
|= {pos/@ud num/@ud}
2015-09-02 01:20:17 +03:00
^- sole-edit
:- %mor
|-(?:(=(0 num) ~ [[%del pos] $(num (dec num))]))
::
++ ta-det :: send edit
2015-12-20 23:50:45 +03:00
|= ted/sole-edit
2015-05-17 04:05:56 +03:00
^+ +>
2015-09-02 01:20:17 +03:00
(ta-act %det [[his.ven.say.inp own.ven.say.inp] (sham buf.say.inp) ted])
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-bac :: hear backspace
^+ .
?^ ris
?: =(~ str.u.ris)
ta-bel
.(str.u.ris (scag (dec (lent str.u.ris)) str.u.ris))
?: =(0 pos.inp)
2015-10-07 21:58:17 +03:00
(ta-act %clr ~)
:: .(+> (se-blit %bel ~))
2015-09-02 01:20:17 +03:00
=+ pre=(dec pos.inp)
(ta-hom %del pre)
2015-09-02 01:20:17 +03:00
::
++ ta-ctl :: hear control
2015-12-20 23:50:45 +03:00
|= key/@ud
2015-05-17 04:05:56 +03:00
^+ +>
2015-09-02 01:20:17 +03:00
?+ key ta-bel
2015-12-09 04:54:26 +03:00
$a +>(pos.inp 0, ris ~)
$b (ta-aro %l)
$c ta-bel(ris ~)
$d ?: &(=(0 pos.inp) =(0 (lent buf.say.inp)))
2015-09-02 01:20:17 +03:00
+>(liv |)
ta-del
2015-12-09 04:54:26 +03:00
$e +>(pos.inp (lent buf.say.inp))
$f (ta-aro %r)
$g ?~ ris ta-bel
(ta-hom(pos.hit num.hit, ris ~) [%set ~])
2015-12-09 04:54:26 +03:00
$k =+ len=(lent buf.say.inp)
2015-09-02 01:20:17 +03:00
?: =(pos.inp len)
ta-bel
%- ta-hom(kil `(slag pos.inp buf.say.inp), ris ~)
2015-09-02 01:20:17 +03:00
(ta-cut pos.inp (sub len pos.inp))
2015-12-09 04:54:26 +03:00
$l +>(+> (se-blit %clr ~))
$n (ta-aro %d)
$p (ta-aro %u)
$r ?~ ris
2015-09-02 01:20:17 +03:00
+>(ris `[pos.hit ~])
?: =(0 pos.u.ris)
ta-bel
(ta-ser ~)
2015-12-09 04:54:26 +03:00
$t =+ len=(lent buf.say.inp)
2015-09-02 01:20:17 +03:00
?: |(=(0 pos.inp) (lth len 2))
ta-bel
=+ sop=?:(=(len pos.inp) (dec pos.inp) pos.inp)
=. pos.inp +(sop)
=. ris ~
2015-09-02 01:20:17 +03:00
%- ta-hom
:~ %mor
[%del sop]
[%ins (dec sop) (snag sop buf.say.inp)]
==
2015-12-09 04:54:26 +03:00
$u ?: =(0 pos.inp)
2015-09-02 01:20:17 +03:00
ta-bel
%- ta-hom(kil `(scag pos.inp buf.say.inp), ris ~)
2015-09-02 01:20:17 +03:00
(ta-cut 0 pos.inp)
2015-12-09 04:54:26 +03:00
$v ta-bel
$x +>(+> se-anon)
$y ?~ kil ta-bel
(ta-hom(ris ~) (ta-cat pos.inp u.kil))
2015-05-17 04:05:56 +03:00
==
::
2015-09-02 01:20:17 +03:00
++ ta-cru :: hear crud
2015-12-20 23:50:45 +03:00
|= {lab/@tas tac/(list tank)}
2015-09-02 01:20:17 +03:00
=. +>+> (se-text (trip lab))
(ta-tan tac)
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-del :: hear delete
2015-05-17 04:05:56 +03:00
^+ .
2015-09-02 01:20:17 +03:00
?: =((lent buf.say.inp) pos.inp)
.(+> (se-blit %bel ~))
(ta-hom %del pos.inp)
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-erl :: hear local error
2015-12-20 23:50:45 +03:00
|= pos/@ud
2015-09-02 01:20:17 +03:00
ta-bel(pos.inp (min pos (lent buf.say.inp)))
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-err :: hear remote error
2015-12-20 23:50:45 +03:00
|= pos/@ud
2015-09-02 01:20:17 +03:00
(ta-erl (~(transpose sole say.inp) pos))
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-fec :: apply effect
2015-12-20 23:50:45 +03:00
|= fec/sole-effect
2015-05-17 04:05:56 +03:00
^+ +>
2015-09-02 01:20:17 +03:00
?- -.fec
2015-12-09 04:54:26 +03:00
$bel ta-bel
$blk +>
$clr +>(+> (se-blit fec))
$det (ta-got +.fec)
$err (ta-err +.fec)
$mor |- ^+ +>.^$
2015-09-02 01:20:17 +03:00
?~ p.fec +>.^$
$(p.fec t.p.fec, +>.^$ ^$(fec i.p.fec))
2015-12-09 04:54:26 +03:00
$nex ta-nex
$pro (ta-pro +.fec)
$tan (ta-tan p.fec)
$sag +>(+> (se-blit fec))
$sav +>(+> (se-blit fec))
$txt $(fec [%tan [%leaf p.fec]~])
$url +>(+> (se-blit fec))
2015-09-02 01:20:17 +03:00
==
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-dog :: change cursor
2015-12-20 23:50:45 +03:00
|= ted/sole-edit
2015-09-02 01:20:17 +03:00
%_ +>
pos.inp
=+ len=(lent buf.say.inp)
%+ min len
|- ^- @ud
?- -.ted
2015-12-09 04:54:26 +03:00
$del ?:((gth pos.inp p.ted) (dec pos.inp) pos.inp)
$ins ?:((gte pos.inp p.ted) +(pos.inp) pos.inp)
$mor |- ^- @ud
2015-09-02 01:20:17 +03:00
?~ p.ted pos.inp
$(p.ted t.p.ted, pos.inp ^$(ted i.p.ted))
2015-12-09 04:54:26 +03:00
$nop pos.inp
$set len
2015-09-02 01:20:17 +03:00
==
==
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-got :: apply change
2015-12-20 23:50:45 +03:00
|= cal/sole-change
2015-09-02 01:20:17 +03:00
=^ ted say.inp (~(receive sole say.inp) cal)
(ta-dog ted)
::
2015-09-02 01:20:17 +03:00
++ ta-hom :: local edit
2015-12-20 23:50:45 +03:00
|= ted/sole-edit
^+ +>
2015-09-02 01:20:17 +03:00
=. +> (ta-det ted)
=. +> (ta-dog(say.inp (~(commit sole say.inp) ted)) ted)
+>
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-met :: meta key
2015-12-20 23:50:45 +03:00
|= key/@ud
2015-09-02 01:20:17 +03:00
~& [%ta-met key]
+>
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-mov :: move in history
2015-12-20 23:50:45 +03:00
|= sop/@ud
2015-09-02 01:20:17 +03:00
^+ +>
?: =(sop pos.hit) +>
%+ %= ta-hom
pos.hit sop
lay.hit %+ ~(put by lay.hit)
pos.hit
buf.say.inp
==
%set
%- (bond |.((snag (sub num.hit +(sop)) old.hit)))
(~(get by lay.hit) sop)
::
++ ta-nex :: advance history
%_ .
num.hit +(num.hit)
pos.hit +(num.hit)
ris ~
lay.hit ~
old.hit [buf.say.inp old.hit]
==
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-pro :: set prompt
2015-12-20 23:50:45 +03:00
|= pom/sole-prompt
2015-09-02 01:20:17 +03:00
+>(pom pom(cad :(welp (scow %p p.gyl) ":" (trip q.gyl) cad.pom)))
::
++ ta-ret :: hear return
2015-10-08 01:42:19 +03:00
(ta-act %ret ~)
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-ser :: reverse search
2015-12-20 23:50:45 +03:00
|= ext/(list @c)
2015-05-17 04:05:56 +03:00
^+ +>
2015-12-10 12:17:19 +03:00
?: |(?=($~ ris) =(0 pos.u.ris)) ta-bel
=+ sop=?~(ext (dec pos.u.ris) pos.u.ris)
2015-09-02 01:20:17 +03:00
=+ tot=(weld str.u.ris ext)
=+ dol=(slag (sub num.hit sop) old.hit)
2015-09-02 01:20:17 +03:00
=+ ^= ser
=+ ^= beg
2015-12-20 23:50:45 +03:00
|= {a/(list @c) b/(list @c)} ^- ?
2015-09-02 01:20:17 +03:00
?~(a & ?~(b | &(=(i.a i.b) $(a t.a, b t.b))))
2015-12-20 23:50:45 +03:00
|= {a/(list @c) b/(list @c)} ^- ?
2015-09-02 01:20:17 +03:00
?~(a & ?~(b | |((beg a b) $(b t.b))))
=+ ^= sup
2015-12-09 04:54:26 +03:00
|- ^- (unit @ud)
2015-09-02 01:20:17 +03:00
?~ dol ~
?: (ser tot i.dol)
`sop
$(sop (dec sop), dol t.dol)
?~ sup ta-bel
(ta-mov(str.u.ris tot, pos.u.ris u.sup) (dec u.sup))
2015-09-02 01:20:17 +03:00
::
++ ta-tan :: print tanks
2015-12-20 23:50:45 +03:00
|= tac/(list tank)
=+ wol=`wall`(zing (turn (flop tac) |=(a/tank (~(win re a) [0 edg]))))
2015-09-02 01:20:17 +03:00
|- ^+ +>.^$
?~ wol +>.^$
$(wol t.wol, +>+>.^$ (se-text i.wol))
2015-05-17 04:05:56 +03:00
::
2015-09-02 01:20:17 +03:00
++ ta-txt :: hear text
2015-12-20 23:50:45 +03:00
|= txt/(list @c)
2015-09-02 01:20:17 +03:00
^+ +>
?^ ris
(ta-ser txt)
%- ta-hom
2015-09-02 01:20:17 +03:00
:- %mor
|- ^- (list sole-edit)
?~ txt ~
[[%ins pos.inp i.txt] $(pos.inp +(pos.inp), txt t.txt)]
::
++ ta-vew :: computed prompt
2015-12-09 04:54:26 +03:00
|- ^- (pair @ud (list @c))
2015-09-02 01:20:17 +03:00
?^ ris
%= $
ris ~
cad.pom
:(welp "(reverse-i-search)'" (tufa str.u.ris) "': ")
2015-05-17 04:05:56 +03:00
==
2015-09-02 01:20:17 +03:00
=- [(add pos.inp (lent p.vew)) (weld (tuba p.vew) q.vew)]
2015-12-09 04:54:26 +03:00
^= vew ^- (pair tape (list @c))
2015-09-02 01:20:17 +03:00
?: vis.pom [cad.pom buf.say.inp]
:- ;: welp
cad.pom
?~ buf.say.inp ~
;: welp
"<"
(scow %p (end 4 1 (sham buf.say.inp)))
"> "
2015-05-17 04:05:56 +03:00
==
==
2015-09-02 01:20:17 +03:00
=+ len=(lent buf.say.inp)
2015-12-09 04:54:26 +03:00
|- ^- (list @c)
2015-09-02 01:20:17 +03:00
?:(=(0 len) ~ [`@c`'*' $(len (dec len))])
2015-05-17 04:05:56 +03:00
--
--