urbit/pkg/arvo/app/launch.hoon

235 lines
5.8 KiB
Plaintext
Raw Normal View History

:: launch [landscape]:
::
:: registers Landscape (and third party) applications, tiles
::
2020-05-20 22:12:53 +03:00
/+ store=launch-store, default-agent, dbug
2019-11-21 02:39:46 +03:00
|%
+$ card card:agent:gall
2019-11-21 02:39:46 +03:00
+$ versioned-state
2020-05-05 20:10:58 +03:00
$% [%0 *]
[%1 *]
[%2 *]
[%3 *]
[%4 state-zero]
2020-09-25 03:44:24 +03:00
[%5 state-zero]
[%6 state-zero]
2021-04-26 23:12:11 +03:00
[%7 state-7]
2019-11-21 02:39:46 +03:00
==
::
2019-11-21 02:39:46 +03:00
+$ state-zero
2021-04-26 23:12:11 +03:00
$: tiles=tiles-0:store
=tile-ordering:store
first-time=?
==
::
+$ state-7
2020-05-20 22:12:53 +03:00
$: =tiles:store
=tile-ordering:store
first-time=?
2020-03-20 22:06:10 +03:00
==
2019-11-21 02:39:46 +03:00
--
::
2021-04-26 23:12:11 +03:00
=| [%7 state-7]
2019-11-21 02:39:46 +03:00
=* state -
2020-03-12 03:33:48 +03:00
%- agent:dbug
2019-11-21 02:39:46 +03:00
^- agent:gall
|_ =bowl:gall
2019-11-21 02:39:46 +03:00
+* this .
def ~(. (default-agent this %|) bowl)
2020-05-05 20:10:58 +03:00
::
2019-11-21 02:39:46 +03:00
++ on-init
^- (quip card _this)
2021-04-26 23:12:11 +03:00
=/ new-state *state-7
=. new-state
%_ new-state
tiles
2020-05-20 22:12:53 +03:00
%- ~(gas by *tiles:store)
%+ turn `(list term)`[%weather %clock %term ~]
|= =term
:- term
2020-05-20 22:12:53 +03:00
^- tile:store
2021-04-26 23:12:11 +03:00
?+ term [[%custom ~ ~] %.y]
%term [[%basic 'Terminal' '/~landscape/img/term.png' '/~term'] %.y]
==
tile-ordering [%weather %clock %term ~]
==
2021-04-26 23:12:11 +03:00
[~ this(state [%7 new-state])]
2019-11-21 02:39:46 +03:00
::
++ on-save !>(state)
++ on-load
|= old=vase
2020-03-20 22:06:10 +03:00
^- (quip card _this)
=/ old-state !<(versioned-state old)
=| cards=(list card)
|- ^- (quip card _this)
2021-04-26 23:12:11 +03:00
?: ?=(%7 -.old-state)
[cards this(state old-state)]
2021-04-26 23:12:11 +03:00
::
?: ?=(%6 -.old-state)
=/ new-tiles=tiles:store
%- ~(gas by *tiles:store)
%+ turn ~(tap by tiles.old-state)
|= [=term =tile-0:store]
:- term
:_ is-shown.tile-0
?- -.type.tile-0
%basic type.tile-0
%custom [%custom ~ ~]
==
$(old-state [%7 new-tiles tile-ordering.old-state first-time.old-state])
::
2020-09-30 16:48:33 +03:00
?: ?=(%5 -.old-state)
:: replace %dojo with %term
::
=. tiles.old-state
%+ ~(put by (~(del by tiles.old-state) %dojo))
%term
:_ is-shown:(~(gut by tiles.old-state) %dojo *tile:store)
[%basic 'Terminal' '/~landscape/img/term.png' '/~term']
=. tile-ordering.old-state
%+ turn tile-ordering.old-state
|=(t=term ?:(=(%dojo t) %term t))
$(old-state [%6 +.old-state])
2020-09-30 16:48:33 +03:00
?: ?=(%4 -.old-state)
=. cards
%+ snoc cards
[%pass / %arvo %e %disconnect [~ /]]
2020-09-25 03:44:24 +03:00
=. tiles.old-state
(~(del by tiles.old-state) %chat)
=. tiles.old-state
(~(del by tiles.old-state) %publish)
=. tiles.old-state
(~(del by tiles.old-state) %links)
=. tile-ordering.old-state
(skip tile-ordering.old-state |=(=term ?=(?(%links %chat %publish) term)))
$(old-state [%5 +.old-state])
=/ new-state *state-zero
=. new-state
%_ new-state
tiles
2021-04-26 23:12:11 +03:00
%- ~(gas by *tiles-0:store)
2020-09-25 03:44:24 +03:00
%+ turn `(list term)`[%weather %clock %dojo ~]
|= =term
:- term
2021-04-26 23:12:11 +03:00
^- tile-0:store
?+ term [[%custom ~] %.y]
%dojo [[%basic 'Dojo' '/~landscape/img/Dojo.png' '/~dojo'] %.y]
==
2020-09-25 03:44:24 +03:00
tile-ordering [%weather %clock %dojo ~]
==
%_ $
old-state [%5 new-state]
::
cards
%+ welp
:~ [%pass / %arvo %e %disconnect [~ /]]
:* %pass /srv %agent [our.bowl %file-server]
%poke %file-server-action
!>([%serve-dir / /app/landscape %.n %.y])
==
==
%+ turn ~(tap by wex.bowl)
|= [[=wire =ship =term] *]
^- card
[%pass wire %agent [ship term] %leave ~]
==
2019-11-21 02:39:46 +03:00
::
++ on-poke
|= [=mark =vase]
2019-11-21 02:39:46 +03:00
^- (quip card _this)
|^
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
2020-05-20 22:12:53 +03:00
%launch-action (poke-action !<(action:store vase))
==
[cards this]
::
++ poke-action
2020-05-20 22:12:53 +03:00
|= =action:store
^- (quip card _state)
?- -.action
%add
?< (~(has by tiles) name.action)
:- (give [/all /keys ~] action)
%_ state
tiles (~(put by tiles) name.action tile.action)
tile-ordering (snoc tile-ordering name.action)
==
::
%remove
:- (give [/all /keys ~] action)
%_ state
tiles (~(del by tiles) name.action)
tile-ordering
%+ skip tile-ordering
|=(=term =(term name.action))
==
::
%change-order
?> =(~(key by tiles) (silt tile-ordering.action))
:- (give [/all]~ action)
state(tile-ordering tile-ordering.action)
::
%change-is-shown
2020-05-20 22:12:53 +03:00
=/ =tile:store (~(got by tiles) name.action)
?. =(is-shown.tile is-shown.action) [~ state]
=. is-shown.tile is-shown.action
:- (give [/all]~ action)
state(tiles (~(put by tiles) name.action tile))
2020-05-20 22:12:53 +03:00
::
%change-first-time
:- (give [/all]~ action)
state(first-time first-time.action)
==
::
++ give
2020-05-20 22:12:53 +03:00
|= [paths=(list path) =update:store]
^- (list card)
[%give %fact paths [%launch-update !>(update)]]~
--
2019-11-21 02:39:46 +03:00
::
++ on-watch
2020-05-05 20:10:58 +03:00
|= =path
2019-11-21 02:39:46 +03:00
^- (quip card _this)
|^
?> (team:title our.bowl src.bowl)
=/ cards=(list card)
2020-05-20 22:12:53 +03:00
?+ path (on-watch:def path)
[%all ~] (give [%initial tiles tile-ordering first-time])
[%keys ~] (give [%keys ~(key by tiles)])
==
[cards this]
::
++ give
2020-05-20 22:12:53 +03:00
|= =update:store
^- (list card)
[%give %fact ~ [%launch-update !>(update)]]~
--
::
2020-05-20 22:12:53 +03:00
++ on-peek
|= =path
^- (unit (unit cage))
2020-08-19 21:46:52 +03:00
?. (team:title our.bowl src.bowl) ~
?+ path [~ ~]
[%x %tiles ~] ``noun+!>([tiles tile-ordering])
[%x %first-time ~] ``noun+!>(first-time)
[%x %keys ~] ``noun+!>(~(key by tiles))
::
[%x %runtime-lag ~]
:^ ~ ~ %json
!> ^- json
b+.^(? //(scot %p our.bowl)//(scot %da now.bowl)/zen/lag)
2020-05-20 22:12:53 +03:00
==
2019-11-21 02:39:46 +03:00
::
++ on-arvo
|= [wir=wire sin=sign-arvo]
^- (quip card:agent:gall _this)
2020-05-05 20:10:58 +03:00
?: ?=(%bound +<.sin) [~ this]
(on-arvo:def wir sin)
::
2020-05-05 20:10:58 +03:00
++ on-agent on-agent:def
++ on-leave on-leave:def
++ on-fail on-fail:def
2019-11-21 02:39:46 +03:00
--