2019-10-03 02:30:07 +03:00
|
|
|
:: chat-cli: cli chat client using chat-store and friends
|
|
|
|
::
|
|
|
|
:: pulls all known messages into a single stream.
|
|
|
|
:: type ;help for usage instructions.
|
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
:: note that while the chat-store only cares about paths,
|
|
|
|
:: we mostly deal with [ship path] (aka target) here.
|
|
|
|
:: when sending messages (through the chat hook),
|
|
|
|
:: we concat the ship onto the head of the path,
|
|
|
|
:: and trust it to take care of the rest.
|
|
|
|
::
|
2020-04-30 02:04:29 +03:00
|
|
|
/- view=chat-view, hook=chat-hook,
|
2019-11-13 02:09:18 +03:00
|
|
|
*permission-store, *group-store, *invite-store,
|
2020-05-24 17:38:09 +03:00
|
|
|
*rw-security, sole
|
|
|
|
/+ shoe, default-agent, verb, dbug, store=chat-store
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
|
|
|
|%
|
2020-05-24 17:38:09 +03:00
|
|
|
+$ card card:shoe
|
2020-03-11 02:40:21 +03:00
|
|
|
::
|
2020-03-11 02:42:04 +03:00
|
|
|
+$ versioned-state
|
2020-05-15 02:46:18 +03:00
|
|
|
$% state-2
|
|
|
|
state-1
|
2020-03-11 02:40:21 +03:00
|
|
|
state-0
|
|
|
|
==
|
|
|
|
::
|
2020-05-15 02:46:18 +03:00
|
|
|
+$ state-2
|
|
|
|
$: %2
|
|
|
|
grams=(list mail) :: all messages
|
|
|
|
known=(set [target serial]) :: known message lookup
|
|
|
|
count=@ud :: (lent grams)
|
|
|
|
bound=(map target glyph) :: bound circle glyphs
|
|
|
|
binds=(jug glyph target) :: circle glyph lookup
|
|
|
|
audience=(set target) :: active targets
|
|
|
|
settings=(set term) :: frontend flags
|
|
|
|
width=@ud :: display width
|
|
|
|
timez=(pair ? @ud) :: timezone adjustment
|
|
|
|
==
|
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
+$ state-1
|
|
|
|
$: %1
|
|
|
|
grams=(list mail) :: all messages
|
2020-04-25 06:51:28 +03:00
|
|
|
known=(set [target serial:store]) :: known message lookup
|
2019-10-03 02:30:07 +03:00
|
|
|
count=@ud :: (lent grams)
|
2019-10-11 00:49:20 +03:00
|
|
|
bound=(map target glyph) :: bound circle glyphs
|
|
|
|
binds=(jug glyph target) :: circle glyph lookup
|
2019-10-03 02:30:07 +03:00
|
|
|
audience=(set target) :: active targets
|
|
|
|
settings=(set term) :: frontend flags
|
|
|
|
width=@ud :: display width
|
|
|
|
timez=(pair ? @ud) :: timezone adjustment
|
2020-05-24 17:38:09 +03:00
|
|
|
cli=state=sole-share:sole :: console state
|
2019-11-09 06:32:21 +03:00
|
|
|
eny=@uvJ :: entropy
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
+$ state-0
|
2020-04-25 06:51:28 +03:00
|
|
|
$: grams=(list [[=ship =path] envelope:store]) :: all messages
|
2020-03-11 02:40:21 +03:00
|
|
|
known=(set [[=ship =path] serial]) :: known message lookup
|
|
|
|
count=@ud :: (lent grams)
|
|
|
|
bound=(map [=ship =path] glyph) :: bound circle glyphs
|
|
|
|
binds=(jug glyph [=ship =path]) :: circle glyph lookup
|
|
|
|
audience=(set [=ship =path]) :: active targets
|
|
|
|
settings=(set term) :: frontend flags
|
|
|
|
width=@ud :: display width
|
|
|
|
timez=(pair ? @ud) :: timezone adjustment
|
2020-05-24 17:38:09 +03:00
|
|
|
cli=state=sole-share:sole :: console state
|
2020-03-11 02:40:21 +03:00
|
|
|
eny=@uvJ :: entropy
|
|
|
|
==
|
|
|
|
::
|
2020-04-25 06:51:28 +03:00
|
|
|
+$ mail [source=target envelope:store]
|
2020-03-11 02:40:21 +03:00
|
|
|
+$ target [in-group=? =ship =path]
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
+$ glyph char
|
2020-03-11 02:40:21 +03:00
|
|
|
++ glyphs "!@#$%^&()-=_+[]\{}'\\:\",.<>?"
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
+$ nu-security ?(%channel %village %village-with-group)
|
2020-02-11 22:39:14 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
+$ command
|
2019-10-07 17:02:03 +03:00
|
|
|
$% [%target (set target)] :: set messaging target
|
2020-04-25 06:51:28 +03:00
|
|
|
[%say letter:store] :: send message
|
2019-10-03 02:30:07 +03:00
|
|
|
[%eval cord hoon] :: send #-message
|
|
|
|
::
|
2019-11-14 03:53:47 +03:00
|
|
|
::
|
|
|
|
:: create chat
|
2020-03-11 02:40:21 +03:00
|
|
|
[%create nu-security path (unit glyph) (unit ?)]
|
2019-10-08 23:27:43 +03:00
|
|
|
[%delete path] :: delete chat
|
2020-03-11 02:40:21 +03:00
|
|
|
[%invite [? path] (set ship)] :: allow
|
|
|
|
[%banish [? path] (set ship)] :: disallow
|
2019-10-08 20:26:30 +03:00
|
|
|
::
|
2019-11-14 03:53:47 +03:00
|
|
|
[%join target (unit glyph) (unit ?)] :: join target
|
2019-10-04 23:38:22 +03:00
|
|
|
[%leave target] :: nuke target
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
[%bind glyph target] :: bind glyph
|
2019-10-11 00:40:08 +03:00
|
|
|
[%unbind glyph (unit target)] :: unbind glyph
|
2019-10-04 23:38:22 +03:00
|
|
|
[%what (unit $@(char target))] :: glyph lookup
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
[%settings ~] :: show active settings
|
|
|
|
[%set term] :: set settings flag
|
|
|
|
[%unset term] :: unset settings flag
|
|
|
|
[%width @ud] :: adjust display width
|
|
|
|
[%timezone ? @ud] :: adjust time printing
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
[%select $@(rel=@ud [zeros=@u abs=@ud])] :: rel/abs msg selection
|
2019-10-04 23:38:22 +03:00
|
|
|
[%chats ~] :: list available chats
|
2019-10-03 02:30:07 +03:00
|
|
|
[%help ~] :: print usage info
|
|
|
|
== ::
|
|
|
|
::
|
|
|
|
--
|
2020-05-15 02:46:18 +03:00
|
|
|
=| state-2
|
2020-03-11 02:42:04 +03:00
|
|
|
=* state -
|
2020-01-21 23:36:03 +03:00
|
|
|
::
|
|
|
|
%- agent:dbug
|
|
|
|
%+ verb |
|
2020-05-24 17:38:09 +03:00
|
|
|
%- (agent:shoe command)
|
|
|
|
^- (shoe:shoe command)
|
2019-11-09 06:32:21 +03:00
|
|
|
=<
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-09 06:32:21 +03:00
|
|
|
+* this .
|
|
|
|
talk-core +>
|
2020-05-15 15:13:38 +03:00
|
|
|
tc ~(. talk-core bowl)
|
2019-11-09 06:32:21 +03:00
|
|
|
def ~(. (default-agent this %|) bowl)
|
2020-05-24 17:38:09 +03:00
|
|
|
des ~(. (default:shoe this command) bowl)
|
2019-11-09 06:32:21 +03:00
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
2020-03-11 02:42:04 +03:00
|
|
|
=^ cards state (prep:tc ~)
|
2020-03-11 02:40:21 +03:00
|
|
|
[cards this]
|
2019-11-09 06:32:21 +03:00
|
|
|
::
|
2020-03-11 02:42:04 +03:00
|
|
|
++ on-save !>(state)
|
2019-11-09 06:32:21 +03:00
|
|
|
::
|
|
|
|
++ on-load
|
|
|
|
|= old-state=vase
|
|
|
|
^- (quip card _this)
|
2020-03-11 02:42:04 +03:00
|
|
|
=/ old !<(versioned-state old-state)
|
|
|
|
=^ cards state (prep:tc `old)
|
2019-11-09 06:32:21 +03:00
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
2020-03-11 02:42:04 +03:00
|
|
|
=^ cards state
|
2019-11-09 06:32:21 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
2019-12-21 14:58:22 +03:00
|
|
|
%noun (poke-noun:tc !<(* vase))
|
2019-11-09 06:32:21 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=wire =sign:agent:gall]
|
2019-11-09 06:32:21 +03:00
|
|
|
^- (quip card _this)
|
2020-03-11 02:42:04 +03:00
|
|
|
=^ cards state
|
2019-11-09 06:32:21 +03:00
|
|
|
?- -.sign
|
2020-03-11 23:52:04 +03:00
|
|
|
%poke-ack [- state]:(on-agent:def wire sign)
|
|
|
|
%watch-ack [- state]:(on-agent:def wire sign)
|
|
|
|
::
|
|
|
|
%kick
|
|
|
|
:_ state
|
|
|
|
?+ wire ~
|
|
|
|
[%chat-store ~] ~[connect:tc]
|
|
|
|
[%invites ~] ~[connect-invites:tc]
|
|
|
|
==
|
|
|
|
::
|
2019-11-09 06:32:21 +03:00
|
|
|
%fact
|
|
|
|
?+ p.cage.sign ~|([%chat-cli-bad-sub-mark wire p.cage.sign] !!)
|
2020-04-25 06:51:28 +03:00
|
|
|
%chat-update (diff-chat-update:tc wire !<(update:store q.cage.sign))
|
2020-03-11 23:52:04 +03:00
|
|
|
%invite-update (handle-invite-update:tc !<(invite-update q.cage.sign))
|
2019-11-09 06:32:21 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2020-05-24 17:38:09 +03:00
|
|
|
++ on-watch on-watch:def
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
2019-11-09 06:32:21 +03:00
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
2020-05-24 17:38:09 +03:00
|
|
|
::
|
|
|
|
++ command-parser
|
|
|
|
|= sole-id=@ta
|
|
|
|
parser:sh:tc
|
|
|
|
::
|
|
|
|
++ tab-list
|
|
|
|
|= sole-id=@ta
|
|
|
|
tab-list:sh:tc
|
|
|
|
::
|
|
|
|
++ on-command
|
|
|
|
|= [sole-id=@ta =command]
|
|
|
|
=^ cards state
|
|
|
|
(work:sh:tc command)
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-connect
|
|
|
|
|= sole-id=@ta
|
|
|
|
^- (quip card _this)
|
|
|
|
[[prompt:sh-out:tc ~] this]
|
|
|
|
::
|
|
|
|
++ can-connect can-connect:des
|
|
|
|
++ on-disconnect on-disconnect:des
|
2019-11-09 06:32:21 +03:00
|
|
|
--
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +prep: setup & state adapter
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
|
|
|
++ prep
|
2020-03-11 02:42:04 +03:00
|
|
|
|= old=(unit versioned-state)
|
|
|
|
^- (quip card _state)
|
2020-03-11 02:40:21 +03:00
|
|
|
?~ old
|
2020-03-11 02:42:04 +03:00
|
|
|
=^ cards state
|
2020-03-11 02:40:21 +03:00
|
|
|
%_ catch-up
|
|
|
|
audience [[| our-self /] ~ ~]
|
|
|
|
settings (sy %showtime %notify ~)
|
|
|
|
width 80
|
|
|
|
==
|
2020-03-11 23:52:04 +03:00
|
|
|
[[connect connect-invites cards] state]
|
|
|
|
:- %+ weld
|
|
|
|
?: (~(has by wex.bowl) [/invites our-self %invite-store]) ~
|
|
|
|
~[connect-invites]
|
|
|
|
?: (~(has by wex.bowl) [/chat-store our-self %chat-store]) ~
|
2020-03-11 02:40:21 +03:00
|
|
|
~[connect]
|
|
|
|
::
|
2020-05-15 02:46:18 +03:00
|
|
|
^- state-2
|
|
|
|
=? u.old ?=(?(~ ^) -.u.old)
|
|
|
|
^- state-1
|
2020-03-11 02:40:21 +03:00
|
|
|
:- %1
|
|
|
|
%= u.old
|
|
|
|
grams ~ ::NOTE this only impacts historic message lookup in chat-cli
|
|
|
|
::
|
|
|
|
known
|
|
|
|
^- (set [target serial])
|
|
|
|
%- ~(run in known.u.old)
|
|
|
|
|= [t=[ship path] s=serial]
|
|
|
|
[`target`[| t] s]
|
|
|
|
::
|
|
|
|
bound
|
|
|
|
^- (map target glyph)
|
2020-03-13 23:45:49 +03:00
|
|
|
%- ~(gas by *(map target glyph))
|
2020-03-11 02:40:21 +03:00
|
|
|
%+ turn ~(tap by bound.u.old)
|
|
|
|
|= [t=[ship path] g=glyph]
|
|
|
|
[`target`[| t] g]
|
|
|
|
::
|
|
|
|
binds
|
|
|
|
^- (jug glyph target)
|
|
|
|
%- ~(run by binds.u.old)
|
|
|
|
|= s=(set [ship path])
|
|
|
|
%- ~(run in s)
|
|
|
|
|= t=[ship path]
|
|
|
|
`target`[| t]
|
|
|
|
::
|
|
|
|
audience
|
|
|
|
^- (set target)
|
|
|
|
%- ~(run in audience.u.old)
|
|
|
|
|= t=[ship path]
|
|
|
|
`target`[| t]
|
2019-10-08 22:59:25 +03:00
|
|
|
==
|
2020-05-15 02:46:18 +03:00
|
|
|
::
|
|
|
|
=? u.old ?=(%1 -.u.old)
|
|
|
|
^- state-2
|
|
|
|
=, u.old
|
|
|
|
:* %2
|
|
|
|
grams known count
|
|
|
|
bound binds audience
|
|
|
|
settings width timez
|
|
|
|
==
|
|
|
|
::
|
|
|
|
?> ?=(%2 -.u.old)
|
|
|
|
u.old
|
2019-10-08 22:59:25 +03:00
|
|
|
:: +catch-up: process all chat-store state
|
|
|
|
::
|
|
|
|
++ catch-up
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2020-04-25 06:51:28 +03:00
|
|
|
=/ =inbox:store
|
|
|
|
(scry-for inbox:store %chat-store /all)
|
2020-03-11 02:42:04 +03:00
|
|
|
|- ^- (quip card _state)
|
|
|
|
?~ inbox [~ state]
|
2019-10-08 22:59:25 +03:00
|
|
|
=* path p.n.inbox
|
|
|
|
=* mailbox q.n.inbox
|
|
|
|
=/ =target (path-to-target path)
|
2020-04-16 17:52:40 +03:00
|
|
|
=^ cards-n state (read-envelopes target (flop envelopes.mailbox))
|
2020-03-11 02:42:04 +03:00
|
|
|
=^ cards-l state $(inbox l.inbox)
|
|
|
|
=^ cards-r state $(inbox r.inbox)
|
|
|
|
[:(weld cards-n cards-l cards-r) state]
|
2019-10-07 21:46:35 +03:00
|
|
|
:: +connect: connect to the chat-store
|
|
|
|
::
|
|
|
|
++ connect
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
|
|
|
[%pass /chat-store %agent [our-self %chat-store] %watch /updates]
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2020-03-11 23:52:04 +03:00
|
|
|
++ connect-invites
|
|
|
|
^- card
|
|
|
|
[%pass /invites %agent [our.bowl %invite-store] %watch /invitatory/chat]
|
|
|
|
::
|
2020-05-15 16:44:11 +03:00
|
|
|
::TODO better moon support. (name:title our.bowl)
|
|
|
|
++ our-self our.bowl
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +target-to-path: prepend ship to the path
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
++ target-to-path
|
|
|
|
|= target
|
2020-03-11 02:40:21 +03:00
|
|
|
%+ weld
|
|
|
|
?:(in-group ~ /~)
|
2019-10-08 17:18:20 +03:00
|
|
|
[(scot %p ship) path]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +path-to-target: deduces a target from a mailbox path
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ path-to-target
|
|
|
|
|= =path
|
|
|
|
^- target
|
2020-03-11 02:40:21 +03:00
|
|
|
=^ in-group path
|
|
|
|
?. ?=([%'~' *] path)
|
|
|
|
[& path]
|
|
|
|
[| t.path]
|
|
|
|
:- in-group
|
2019-10-04 23:38:22 +03:00
|
|
|
?. ?=([@ @ *] path)
|
2019-10-09 00:00:46 +03:00
|
|
|
::TODO can we safely assert the above?
|
|
|
|
~& [%path-without-host path]
|
2019-10-04 23:38:22 +03:00
|
|
|
[our-self path]
|
|
|
|
=+ who=(slaw %p i.path)
|
|
|
|
?~ who [our-self path]
|
2019-10-08 17:18:20 +03:00
|
|
|
[u.who t.path]
|
2019-10-07 21:46:35 +03:00
|
|
|
:: +poke-noun: debug helpers
|
|
|
|
::
|
|
|
|
++ poke-noun
|
|
|
|
|= a=*
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-07 21:46:35 +03:00
|
|
|
?: ?=(%connect a)
|
2020-03-11 02:42:04 +03:00
|
|
|
[[connect ~] state]
|
2019-10-08 22:59:25 +03:00
|
|
|
?: ?=(%catch-up a)
|
|
|
|
catch-up
|
2020-03-11 02:42:04 +03:00
|
|
|
[~ state]
|
2020-03-11 23:52:04 +03:00
|
|
|
:: +handle-invite-update: get new invites
|
|
|
|
::
|
|
|
|
++ handle-invite-update
|
|
|
|
|= upd=invite-update
|
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.upd [~ state]
|
|
|
|
%invite [[(show-invite:sh-out invite.upd) ~] state]
|
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +diff-chat-update: get new mailboxes & messages
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
|
|
|
++ diff-chat-update
|
2020-04-25 06:51:28 +03:00
|
|
|
|= [=wire upd=update:store]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.upd [~ state]
|
2020-02-04 22:12:51 +03:00
|
|
|
%create (notice-create (path-to-target path.upd))
|
2020-03-11 02:42:04 +03:00
|
|
|
%delete [[(show-delete:sh-out (path-to-target path.upd)) ~] state]
|
2019-11-27 04:42:24 +03:00
|
|
|
%message (read-envelope (path-to-target path.upd) envelope.upd)
|
2020-04-16 17:52:40 +03:00
|
|
|
%messages (read-envelopes (path-to-target path.upd) (flop envelopes.upd))
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ read-envelopes
|
2020-04-25 06:51:28 +03:00
|
|
|
|= [=target envs=(list envelope:store)]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
?~ envs [~ state]
|
|
|
|
=^ cards-i state (read-envelope target i.envs)
|
|
|
|
=^ cards-t state $(envs t.envs)
|
|
|
|
[(weld cards-i cards-t) state]
|
2019-10-07 17:02:03 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
++ notice-create
|
|
|
|
|= =target
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=^ cards state
|
2019-10-04 23:38:22 +03:00
|
|
|
?: (~(has by bound) target)
|
2020-03-11 02:42:04 +03:00
|
|
|
[~ state]
|
2019-10-04 23:38:22 +03:00
|
|
|
(bind-default-glyph target)
|
2020-03-11 02:42:04 +03:00
|
|
|
[[(show-create:sh-out target) cards] state]
|
2019-10-10 23:38:18 +03:00
|
|
|
:: +bind-default-glyph: bind to default, or random available
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ bind-default-glyph
|
|
|
|
|= =target
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-10 23:38:18 +03:00
|
|
|
=; =glyph (bind-glyph glyph target)
|
|
|
|
|^ =/ g=glyph (choose glyphs)
|
|
|
|
?. (~(has by binds) g) g
|
|
|
|
=/ available=(list glyph)
|
|
|
|
%~ tap in
|
|
|
|
(~(dif in `(set glyph)`(sy glyphs)) ~(key by binds))
|
|
|
|
?~ available g
|
|
|
|
(choose available)
|
|
|
|
++ choose
|
|
|
|
|= =(list glyph)
|
|
|
|
=; i=@ud (snag i list)
|
|
|
|
(mod (mug target) (lent list))
|
|
|
|
--
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +bind-glyph: add binding for glyph
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ bind-glyph
|
|
|
|
|= [=glyph =target]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-04 23:38:22 +03:00
|
|
|
::TODO should send these to settings store eventually
|
2019-10-11 00:49:20 +03:00
|
|
|
:: if the target was already bound to another glyph, un-bind that
|
|
|
|
::
|
|
|
|
=? binds (~(has by bound) target)
|
|
|
|
(~(del ju binds) (~(got by bound) target) target)
|
2019-10-04 23:38:22 +03:00
|
|
|
=. bound (~(put by bound) target glyph)
|
|
|
|
=. binds (~(put ju binds) glyph target)
|
2020-03-11 02:42:04 +03:00
|
|
|
[(show-glyph:sh-out glyph `target) state]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +unbind-glyph: remove all binding for glyph
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ unbind-glyph
|
2019-10-11 00:40:08 +03:00
|
|
|
|= [=glyph targ=(unit target)]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-11 00:40:08 +03:00
|
|
|
?^ targ
|
|
|
|
=. binds (~(del ju binds) glyph u.targ)
|
|
|
|
=. bound (~(del by bound) u.targ)
|
2020-03-11 02:42:04 +03:00
|
|
|
[(show-glyph:sh-out glyph ~) state]
|
2019-10-04 23:38:22 +03:00
|
|
|
=/ ole=(set target)
|
|
|
|
(~(get ju binds) glyph)
|
|
|
|
=. binds (~(del by binds) glyph)
|
|
|
|
=. bound
|
|
|
|
|-
|
|
|
|
?~ ole bound
|
|
|
|
=. bound $(ole l.ole)
|
|
|
|
=. bound $(ole r.ole)
|
|
|
|
(~(del by bound) n.ole)
|
2020-03-11 02:42:04 +03:00
|
|
|
[(show-glyph:sh-out glyph ~) state]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +decode-glyph: find the target that matches a glyph, if any
|
|
|
|
::
|
|
|
|
++ decode-glyph
|
|
|
|
|= =glyph
|
|
|
|
^- (unit target)
|
|
|
|
=+ lax=(~(get ju binds) glyph)
|
2019-10-10 23:39:41 +03:00
|
|
|
:: no circle
|
2019-10-07 17:02:03 +03:00
|
|
|
?: =(~ lax) ~
|
2019-10-10 23:39:41 +03:00
|
|
|
%- some
|
|
|
|
:: single circle
|
|
|
|
?: ?=([* ~ ~] lax) n.lax
|
|
|
|
:: in case of multiple audiences, pick the most recently active one
|
|
|
|
|- ^- target
|
|
|
|
?~ grams -:~(tap in lax)
|
|
|
|
=* source source.i.grams
|
|
|
|
?: (~(has in lax) source)
|
|
|
|
source
|
|
|
|
$(grams t.grams)
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +read-envelope: add envelope to state and show it to user
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2019-10-03 02:30:07 +03:00
|
|
|
++ read-envelope
|
2020-04-25 06:51:28 +03:00
|
|
|
|= [=target =envelope:store]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-04 23:38:22 +03:00
|
|
|
?: (~(has in known) [target uid.envelope])
|
2019-10-03 02:30:07 +03:00
|
|
|
::NOTE we no-op only because edits aren't possible
|
2020-03-11 02:42:04 +03:00
|
|
|
[~ state]
|
2019-10-07 17:02:03 +03:00
|
|
|
:- (show-envelope:sh-out target envelope)
|
2020-03-11 02:42:04 +03:00
|
|
|
%_ state
|
2019-10-04 23:38:22 +03:00
|
|
|
known (~(put in known) [target uid.envelope])
|
|
|
|
grams [[target envelope] grams]
|
2019-10-03 02:30:07 +03:00
|
|
|
count +(count)
|
|
|
|
==
|
|
|
|
::
|
2020-05-24 17:38:09 +03:00
|
|
|
:: +sh: shoe handling
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2020-05-24 17:38:09 +03:00
|
|
|
++ sh
|
|
|
|
|%
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +read: command parser
|
|
|
|
::
|
|
|
|
:: parses the command line buffer.
|
|
|
|
:: produces commands which can be executed by +work.
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2020-05-24 17:38:09 +03:00
|
|
|
++ parser
|
2019-10-07 17:02:03 +03:00
|
|
|
|^
|
|
|
|
%+ knee *command |. ~+
|
|
|
|
=- ;~(pose ;~(pfix mic -) message)
|
|
|
|
;~ pose
|
|
|
|
(stag %target tars)
|
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
;~ (glue ace)
|
|
|
|
(tag %create)
|
|
|
|
security
|
|
|
|
;~ plug
|
|
|
|
path
|
|
|
|
(punt ;~(pfix ace glyph))
|
|
|
|
(punt ;~(pfix ace (fuss 'y' 'n')))
|
|
|
|
==
|
|
|
|
==
|
|
|
|
;~((glue ace) (tag %delete) path)
|
|
|
|
;~((glue ace) (tag %invite) tarx ships)
|
|
|
|
;~((glue ace) (tag %banish) tarx ships)
|
2019-10-08 20:26:30 +03:00
|
|
|
::
|
2019-11-14 03:53:47 +03:00
|
|
|
;~ (glue ace)
|
|
|
|
(tag %join)
|
2019-11-15 00:21:46 +03:00
|
|
|
;~ plug
|
|
|
|
targ
|
|
|
|
(punt ;~(pfix ace glyph))
|
|
|
|
(punt ;~(pfix ace (fuss 'y' 'n')))
|
|
|
|
==
|
2019-11-14 03:53:47 +03:00
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
;~((glue ace) (tag %leave) targ)
|
|
|
|
::
|
|
|
|
;~((glue ace) (tag %bind) glyph targ)
|
2019-10-11 00:40:08 +03:00
|
|
|
;~((glue ace) (tag %unbind) ;~(plug glyph (punt ;~(pfix ace targ))))
|
2019-10-07 17:02:03 +03:00
|
|
|
;~(plug (perk %what ~) (punt ;~(pfix ace ;~(pose glyph targ))))
|
|
|
|
::
|
|
|
|
;~(plug (tag %settings) (easy ~))
|
|
|
|
;~((glue ace) (tag %set) flag)
|
|
|
|
;~((glue ace) (tag %unset) flag)
|
|
|
|
;~(plug (cold %width (jest 'set width ')) dem:ag)
|
2020-03-11 02:40:21 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
;~ plug
|
|
|
|
(cold %timezone (jest 'set timezone '))
|
|
|
|
;~ pose
|
|
|
|
(cold %| (just '-'))
|
|
|
|
(cold %& (just '+'))
|
|
|
|
==
|
|
|
|
%+ sear
|
|
|
|
|= a=@ud
|
|
|
|
^- (unit @ud)
|
|
|
|
?:(&((gte a 0) (lte a 14)) `a ~)
|
|
|
|
dem:ag
|
|
|
|
==
|
|
|
|
::
|
|
|
|
;~(plug (tag %chats) (easy ~))
|
|
|
|
;~(plug (tag %help) (easy ~))
|
|
|
|
::
|
|
|
|
(stag %select nump)
|
|
|
|
==
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
::TODO
|
|
|
|
:: ++ cmd
|
|
|
|
:: |* [cmd=term req=(list rule) opt=(list rule)]
|
|
|
|
:: |^ ;~ plug
|
|
|
|
:: (tag cmd)
|
|
|
|
:: ::
|
|
|
|
:: ::TODO this feels slightly too dumb
|
|
|
|
:: ?~ req
|
|
|
|
:: ?~ opt (easy ~)
|
|
|
|
:: (opt-rules opt)
|
|
|
|
:: ?~ opt (req-rules req)
|
|
|
|
:: ;~(plug (req-rules req) (opt-rules opt)) ::TODO rest-loop
|
|
|
|
:: ==
|
|
|
|
:: ++ req-rules
|
|
|
|
:: |* req=(lest rule)
|
|
|
|
:: =- ;~(pfix ace -)
|
|
|
|
:: ?~ t.req i.req
|
|
|
|
:: ;~(plug i.req $(req t.req))
|
|
|
|
:: ++ opt-rules
|
|
|
|
:: |* opt=(lest rule)
|
|
|
|
:: =- (punt ;~(pfix ace -))
|
|
|
|
:: ?~ t.opt ;~(pfix ace i.opt)
|
|
|
|
:: ;~(pfix ace ;~(plug i.opt $(opt t.opt)))
|
|
|
|
:: --
|
|
|
|
::
|
|
|
|
++ tag |*(a=@tas (cold a (jest a))) ::TODO into stdlib
|
|
|
|
++ ship ;~(pfix sig fed:ag)
|
2020-03-11 02:40:21 +03:00
|
|
|
++ path ;~(pfix net ;~(plug urs:ab (easy ~))) ::NOTE short only, tmp
|
2020-03-16 19:46:58 +03:00
|
|
|
:: +mang: un/managed indicator prefix
|
|
|
|
::
|
|
|
|
++ mang
|
|
|
|
;~ pose
|
|
|
|
(cold %| (jest '~/'))
|
|
|
|
(cold %& (easy ~))
|
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +tarl: local target, as /path
|
|
|
|
::
|
|
|
|
++ tarl (stag our-self path)
|
2020-03-16 19:46:58 +03:00
|
|
|
:: +tarx: local target, maybe managed
|
2020-03-11 02:40:21 +03:00
|
|
|
::
|
2020-03-16 19:46:58 +03:00
|
|
|
++ tarx ;~(plug mang path)
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +tarp: sponsor target, as ^/path
|
|
|
|
::
|
|
|
|
++ tarp
|
|
|
|
=- ;~(pfix ket (stag - path))
|
|
|
|
(sein:title our.bowl now.bowl our-self)
|
|
|
|
:: +targ: any target, as tarl, tarp, ~ship/path or glyph
|
|
|
|
::
|
|
|
|
++ targ
|
2019-10-03 02:30:07 +03:00
|
|
|
;~ pose
|
2020-03-11 02:40:21 +03:00
|
|
|
;~ plug
|
2020-03-16 19:46:58 +03:00
|
|
|
mang
|
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
;~ pose
|
|
|
|
tarl
|
|
|
|
tarp
|
|
|
|
;~(plug ship path)
|
|
|
|
==
|
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
(sear decode-glyph glyph)
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +tars: set of comma-separated targs
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ tars
|
2019-10-03 02:30:07 +03:00
|
|
|
%+ cook ~(gas in *(set target))
|
|
|
|
(most ;~(plug com (star ace)) targ)
|
2019-10-08 20:26:30 +03:00
|
|
|
:: +ships: set of comma-separated ships
|
|
|
|
::
|
|
|
|
++ ships
|
|
|
|
%+ cook ~(gas in *(set ^ship))
|
|
|
|
(most ;~(plug com (star ace)) ship)
|
|
|
|
::
|
|
|
|
:: +security: security mode
|
|
|
|
::
|
|
|
|
++ security
|
2020-03-11 02:40:21 +03:00
|
|
|
(perk %channel %village-with-group %village ~)
|
2019-10-08 20:26:30 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +glyph: shorthand character
|
|
|
|
::
|
|
|
|
++ glyph (mask glyphs)
|
|
|
|
:: +flag: valid flag
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ flag
|
|
|
|
%- perk :~
|
|
|
|
%notify
|
|
|
|
%showtime
|
|
|
|
==
|
|
|
|
:: +nump: message number reference
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ nump
|
2019-10-03 02:30:07 +03:00
|
|
|
;~ pose
|
|
|
|
;~(pfix hep dem:ag)
|
|
|
|
;~ plug
|
|
|
|
(cook lent (plus (just '0')))
|
|
|
|
;~(pose dem:ag (easy 0))
|
|
|
|
==
|
|
|
|
(stag 0 dem:ag)
|
2019-10-07 17:02:03 +03:00
|
|
|
(cook lent (star mic))
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-08 20:54:26 +03:00
|
|
|
:: +message: all messages
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ message
|
2019-10-03 02:30:07 +03:00
|
|
|
;~ pose
|
|
|
|
;~(plug (cold %eval hax) expr)
|
2019-10-08 20:54:26 +03:00
|
|
|
(stag %say letter)
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-08 20:54:26 +03:00
|
|
|
:: +letter: simple messages
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-08 20:54:26 +03:00
|
|
|
++ letter
|
2019-10-03 02:30:07 +03:00
|
|
|
;~ pose
|
2019-10-07 21:45:58 +03:00
|
|
|
(stag %url turl)
|
2019-10-23 21:40:58 +03:00
|
|
|
(stag %me ;~(pfix vat text))
|
|
|
|
(stag %text ;~(less mic hax text))
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-07 21:45:58 +03:00
|
|
|
:: +turl: url parser
|
|
|
|
::
|
|
|
|
++ turl
|
|
|
|
=- (sear - text)
|
|
|
|
|= t=cord
|
|
|
|
^- (unit cord)
|
|
|
|
?~((rush t aurf:de-purl:html) ~ `t)
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +text: text message body
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ text
|
2019-10-03 02:30:07 +03:00
|
|
|
%+ cook crip
|
2020-05-15 16:49:31 +03:00
|
|
|
(plus next)
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +expr: parse expression into [cord hoon]
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ expr
|
|
|
|
|= tub=nail
|
|
|
|
%. tub
|
|
|
|
%+ stag (crip q.tub)
|
|
|
|
wide:(vang & [&1:% &2:% (scot %da now.bowl) |3:%])
|
2019-10-03 02:30:07 +03:00
|
|
|
--
|
2020-05-24 17:38:09 +03:00
|
|
|
:: +tab-list: command descriptions
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2020-05-24 17:38:09 +03:00
|
|
|
++ tab-list
|
|
|
|
^- (list [@t tank])
|
|
|
|
:~
|
|
|
|
[%join leaf+";join ~ship/chat-name (glyph)"]
|
|
|
|
[%leave leaf+";leave ~ship/chat-name"]
|
|
|
|
::
|
|
|
|
[%create leaf+";create [type] /chat-name (glyph)"]
|
|
|
|
[%delete leaf+";delete /chat-name"]
|
|
|
|
[%invite leaf+";invite /chat-name ~ships"]
|
|
|
|
[%banish leaf+";banish /chat-name ~ships"]
|
|
|
|
::
|
|
|
|
[%bind leaf+";bind [glyph] ~ship/chat-name"]
|
|
|
|
[%unbind leaf+";unbind [glyph]"]
|
|
|
|
[%what leaf+";what (~ship/chat-name) (glyph)"]
|
|
|
|
::
|
|
|
|
[%settings leaf+";settings"]
|
|
|
|
[%set leaf+";set key (value)"]
|
|
|
|
[%unset leaf+";unset key"]
|
|
|
|
::
|
|
|
|
[%chats leaf+";chats"]
|
|
|
|
[%help leaf+";help"]
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +work: run user command
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
|
|
|
++ work
|
|
|
|
|= job=command
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-07 17:02:03 +03:00
|
|
|
|^ ?- -.job
|
|
|
|
%target (set-target +.job)
|
|
|
|
%say (say +.job)
|
|
|
|
%eval (eval +.job)
|
2019-10-08 20:26:30 +03:00
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
%create (create +.job)
|
2019-10-08 23:27:43 +03:00
|
|
|
%delete (delete +.job)
|
2019-10-08 20:26:30 +03:00
|
|
|
%invite (change-permission & +.job)
|
|
|
|
%banish (change-permission | +.job)
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
%join (join +.job)
|
|
|
|
%leave (leave +.job)
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
%bind (bind-glyph +.job)
|
|
|
|
%unbind (unbind-glyph +.job)
|
|
|
|
%what (lookup-glyph +.job)
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
%settings show-settings
|
2019-10-07 17:02:03 +03:00
|
|
|
%set (set-setting +.job)
|
|
|
|
%unset (unset-setting +.job)
|
|
|
|
%width (set-width +.job)
|
2019-10-04 23:38:22 +03:00
|
|
|
%timezone (set-timezone +.job)
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
%select (select +.job)
|
|
|
|
%chats chats
|
|
|
|
%help help
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-11-09 06:32:21 +03:00
|
|
|
:: +act: build action card
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
|
|
|
++ act
|
2019-11-09 06:32:21 +03:00
|
|
|
|= [what=term app=term =cage]
|
|
|
|
^- card
|
|
|
|
:* %pass
|
2019-10-03 02:30:07 +03:00
|
|
|
/cli-command/[what]
|
2019-11-09 06:32:21 +03:00
|
|
|
%agent
|
2019-10-04 23:38:22 +03:00
|
|
|
[our-self app]
|
2019-11-09 06:32:21 +03:00
|
|
|
%poke
|
|
|
|
cage
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-11-20 23:51:21 +03:00
|
|
|
:: +invite-card: build invite card
|
2019-11-13 02:09:18 +03:00
|
|
|
::
|
2019-11-20 23:51:21 +03:00
|
|
|
++ invite-card
|
2019-11-13 02:09:18 +03:00
|
|
|
|= [where=path who=ship]
|
2019-11-20 23:51:21 +03:00
|
|
|
^- card
|
|
|
|
:* %pass
|
2019-11-13 02:09:18 +03:00
|
|
|
/cli-command/invite
|
2019-11-20 23:51:21 +03:00
|
|
|
%agent
|
2019-11-13 02:09:18 +03:00
|
|
|
[who %invite-hook] ::NOTE only place chat-cli pokes others
|
2019-11-20 23:51:21 +03:00
|
|
|
%poke
|
2019-11-13 02:09:18 +03:00
|
|
|
%invite-action
|
|
|
|
::
|
2019-11-20 23:51:21 +03:00
|
|
|
!>
|
2019-11-13 02:09:18 +03:00
|
|
|
^- invite-action
|
|
|
|
:^ %invite /chat
|
|
|
|
(shax (jam [our-self where] who))
|
|
|
|
^- invite
|
2020-03-11 23:52:04 +03:00
|
|
|
[our-self %chat-hook where who '']
|
2019-11-13 02:09:18 +03:00
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +set-target: set audience, update prompt
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
++ set-target
|
|
|
|
|= tars=(set target)
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-04 23:38:22 +03:00
|
|
|
=. audience tars
|
2020-03-11 02:42:04 +03:00
|
|
|
[[prompt:sh-out ~] state]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +create: new local mailbox
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2020-03-11 02:40:21 +03:00
|
|
|
++ create
|
|
|
|
|= [security=nu-security =path gyf=(unit char) allow-history=(unit ?)]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2020-03-11 02:40:21 +03:00
|
|
|
=/ with-group=? ?=(%village-with-group security)
|
|
|
|
=/ =target [with-group our-self path]
|
|
|
|
=/ real-path=^path (target-to-path target)
|
|
|
|
=/ =rw-security
|
|
|
|
?- security
|
|
|
|
%channel %channel
|
|
|
|
?(%village %village-with-group) %village
|
|
|
|
==
|
2020-04-25 06:51:28 +03:00
|
|
|
?^ (scry-for (unit mailbox:store) %chat-store [%mailbox real-path])
|
2020-03-11 02:42:04 +03:00
|
|
|
=- [[- ~] state]
|
2020-03-11 02:40:21 +03:00
|
|
|
%- print:sh-out
|
|
|
|
"{(spud path)} already exists!"
|
|
|
|
=. audience [target ~ ~]
|
2020-03-11 02:42:04 +03:00
|
|
|
=^ moz state
|
|
|
|
?. ?=(^ gyf) [~ state]
|
2020-03-11 02:40:21 +03:00
|
|
|
(bind-glyph u.gyf target)
|
2020-03-11 02:42:04 +03:00
|
|
|
=- [[- moz] state]
|
2020-03-11 02:40:21 +03:00
|
|
|
%^ act %do-create %chat-view
|
|
|
|
:- %chat-view-action
|
2020-04-25 06:51:28 +03:00
|
|
|
!> ^- action:view
|
2020-03-11 02:40:21 +03:00
|
|
|
:* %create
|
|
|
|
(rsh 3 1 (spat path))
|
|
|
|
''
|
|
|
|
real-path :: chat
|
|
|
|
real-path :: group
|
|
|
|
rw-security
|
|
|
|
~
|
|
|
|
(fall allow-history %.y)
|
|
|
|
==
|
2019-10-08 23:27:43 +03:00
|
|
|
:: +delete: delete local chats
|
|
|
|
::
|
|
|
|
++ delete
|
|
|
|
|= =path
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=- [[- ~] state]
|
2019-10-08 23:27:43 +03:00
|
|
|
%^ act %do-delete %chat-view
|
|
|
|
:- %chat-view-action
|
2020-04-25 06:51:28 +03:00
|
|
|
!> ^- action:view
|
2020-03-11 02:40:21 +03:00
|
|
|
[%delete (target-to-path | our-self path)]
|
2019-10-08 20:26:30 +03:00
|
|
|
:: +change-permission: modify permissions on a local chat
|
|
|
|
::
|
|
|
|
++ change-permission
|
2020-03-11 02:40:21 +03:00
|
|
|
|= [allow=? [group=? =path] ships=(set ship)]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
2020-03-11 02:40:21 +03:00
|
|
|
=/ real-path=^path
|
|
|
|
(target-to-path group our-self path)
|
|
|
|
=; permit=(unit card)
|
|
|
|
%+ weld (drop permit)
|
2020-02-12 17:53:44 +03:00
|
|
|
?. allow ~
|
2020-03-11 02:40:21 +03:00
|
|
|
^- (list card)
|
|
|
|
%+ murn ~(tap in ships)
|
|
|
|
|= =ship
|
|
|
|
^- (unit card)
|
|
|
|
:: if they weren't permitted before, some hook will send an invite.
|
|
|
|
:: but if they already were, we want to send an invite ourselves.
|
|
|
|
::
|
|
|
|
?. %^ scry-for ?
|
|
|
|
%permission-store
|
|
|
|
[%permitted (scot %p ship) real-path]
|
|
|
|
~
|
|
|
|
`(invite-card real-path ship)
|
2019-10-09 01:06:39 +03:00
|
|
|
:: whitelist: empty if no matching permission, else true if whitelist
|
|
|
|
::
|
2019-10-08 20:26:30 +03:00
|
|
|
=/ whitelist=(unit ?)
|
2019-10-09 01:06:39 +03:00
|
|
|
=; perm=(unit permission)
|
|
|
|
?~(perm ~ `?=(%white kind.u.perm))
|
2019-10-08 20:26:30 +03:00
|
|
|
::TODO +permission-of-target?
|
2020-03-11 01:31:18 +03:00
|
|
|
%^ scry-for (unit permission)
|
|
|
|
%permission-store
|
2020-03-11 02:40:21 +03:00
|
|
|
[%permission real-path]
|
2019-10-08 20:26:30 +03:00
|
|
|
?~ whitelist
|
2020-03-11 02:40:21 +03:00
|
|
|
~& [%weird-no-permission real-path]
|
2019-10-08 20:26:30 +03:00
|
|
|
~
|
|
|
|
%- some
|
|
|
|
%^ act %do-permission %group-store
|
|
|
|
:- %group-action
|
2020-02-12 17:53:44 +03:00
|
|
|
!> ^- group-action
|
2019-10-08 20:26:30 +03:00
|
|
|
?: =(u.whitelist allow)
|
2020-03-11 02:40:21 +03:00
|
|
|
[%add ships real-path]
|
|
|
|
[%remove ships real-path]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +join: sync with remote mailbox
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
++ join
|
2019-11-14 03:53:47 +03:00
|
|
|
|= [=target gyf=(unit char) ask-history=(unit ?)]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=^ moz state
|
|
|
|
?. ?=(^ gyf) [~ state]
|
2019-10-04 23:38:22 +03:00
|
|
|
(bind-glyph u.gyf target)
|
2019-10-18 16:04:34 +03:00
|
|
|
=. audience [target ~ ~]
|
2019-11-09 06:32:21 +03:00
|
|
|
=; =card
|
2020-03-11 02:42:04 +03:00
|
|
|
[[card prompt:sh-out moz] state]
|
2019-10-08 20:26:30 +03:00
|
|
|
::TODO ideally we'd check permission first. attempting this and failing
|
|
|
|
:: gives ugly %chat-hook-reap
|
2019-10-08 23:08:53 +03:00
|
|
|
%^ act %do-join %chat-view
|
|
|
|
:- %chat-view-action
|
2020-04-25 06:51:28 +03:00
|
|
|
!> ^- action:view
|
2020-03-11 02:40:21 +03:00
|
|
|
[%join ship.target (target-to-path target) (fall ask-history %.y)]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +leave: unsync & destroy mailbox
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2019-10-08 23:27:43 +03:00
|
|
|
::TODO allow us to "mute" local chats using this
|
2019-10-04 23:38:22 +03:00
|
|
|
++ leave
|
|
|
|
|= =target
|
2020-03-11 02:42:04 +03:00
|
|
|
=- [[- ~] state]
|
2019-10-08 23:27:43 +03:00
|
|
|
?: =(our-self ship.target)
|
|
|
|
%- print:sh-out
|
|
|
|
"can't ;leave local chats, maybe use ;delete instead"
|
2019-10-04 23:38:22 +03:00
|
|
|
%^ act %do-leave %chat-hook
|
|
|
|
:- %chat-hook-action
|
2020-04-25 06:51:28 +03:00
|
|
|
!> ^- action:hook
|
2019-10-04 23:38:22 +03:00
|
|
|
[%remove (target-to-path target)]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +say: send messages
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2019-10-03 02:30:07 +03:00
|
|
|
++ say
|
2020-04-25 06:51:28 +03:00
|
|
|
|= =letter:store
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-11-09 06:32:21 +03:00
|
|
|
~! bowl
|
2019-10-03 02:30:07 +03:00
|
|
|
=/ =serial (shaf %msg-uid eny.bowl)
|
2020-05-15 15:13:38 +03:00
|
|
|
:_ state
|
2019-11-09 06:32:21 +03:00
|
|
|
^- (list card)
|
2019-10-03 02:30:07 +03:00
|
|
|
%+ turn ~(tap in audience)
|
|
|
|
|= =target
|
|
|
|
%^ act %out-message %chat-hook
|
|
|
|
:- %chat-action
|
2020-04-25 06:51:28 +03:00
|
|
|
!> ^- action:store
|
2019-10-04 23:38:22 +03:00
|
|
|
:+ %message (target-to-path target)
|
2019-10-08 20:54:26 +03:00
|
|
|
[serial *@ our-self now.bowl letter]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +eval: run hoon, send code and result as message
|
|
|
|
::
|
|
|
|
:: this double-virtualizes and clams to disable .^ for security reasons
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-04 23:38:22 +03:00
|
|
|
++ eval
|
|
|
|
|= [txt=cord exe=hoon]
|
2020-04-30 02:04:29 +03:00
|
|
|
(say %code txt (eval:store bowl exe))
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +lookup-glyph: print glyph info for all, glyph or target
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ lookup-glyph
|
|
|
|
|= qur=(unit $@(glyph target))
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=- [[- ~] state]
|
2019-10-04 23:38:22 +03:00
|
|
|
?^ qur
|
|
|
|
?^ u.qur
|
|
|
|
=+ gyf=(~(get by bound) u.qur)
|
2019-10-07 17:02:03 +03:00
|
|
|
(print:sh-out ?~(gyf "none" [u.gyf]~))
|
2019-10-04 23:38:22 +03:00
|
|
|
=+ pan=~(tap in (~(get ju binds) `@t`u.qur))
|
2019-10-07 17:02:03 +03:00
|
|
|
?: =(~ pan) (print:sh-out "~")
|
|
|
|
=< (effect:sh-out %mor (turn pan .))
|
|
|
|
|=(t=target [%txt ~(phat tr t)])
|
|
|
|
%- print-more:sh-out
|
2019-10-04 23:38:22 +03:00
|
|
|
%- ~(rep by binds)
|
|
|
|
|= $: [=glyph tars=(set target)]
|
2019-10-07 17:02:03 +03:00
|
|
|
lis=(list tape)
|
2019-10-04 23:38:22 +03:00
|
|
|
==
|
|
|
|
%+ weld lis
|
2019-10-07 17:02:03 +03:00
|
|
|
^- (list tape)
|
2019-10-04 23:38:22 +03:00
|
|
|
%- ~(rep in tars)
|
2019-10-07 17:02:03 +03:00
|
|
|
|= [t=target l=(list tape)]
|
2019-10-04 23:38:22 +03:00
|
|
|
%+ weld l
|
2019-10-07 17:02:03 +03:00
|
|
|
^- (list tape)
|
|
|
|
[glyph ' ' ~(phat tr t)]~
|
|
|
|
:: +show-settings: print enabled flags, timezone and width settings
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ show-settings
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
2019-10-07 17:02:03 +03:00
|
|
|
:~ %- print:sh-out
|
2019-10-04 23:38:22 +03:00
|
|
|
%- zing
|
|
|
|
^- (list tape)
|
|
|
|
:- "flags: "
|
|
|
|
%+ ^join ", "
|
|
|
|
(turn `(list @t)`~(tap in settings) trip)
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
%- print:sh-out
|
2019-10-04 23:38:22 +03:00
|
|
|
%+ weld "timezone: "
|
|
|
|
^- tape
|
|
|
|
:- ?:(p.timez '+' '-')
|
|
|
|
(scow %ud q.timez)
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
(print:sh-out "width: {(scow %ud width)}")
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +set-setting: enable settings flag
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ set-setting
|
|
|
|
|= =term
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
[~ state(settings (~(put in settings) term))]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +unset-setting: disable settings flag
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ unset-setting
|
|
|
|
|= =term
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
[~ state(settings (~(del in settings) term))]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +set-width: configure cli printing width
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ set-width
|
|
|
|
|= w=@ud
|
2020-05-15 15:44:34 +03:00
|
|
|
[~ state(width (max 40 w))]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +set-timezone: configure timestamp printing adjustment
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ set-timezone
|
|
|
|
|= tz=[? @ud]
|
2020-03-11 02:42:04 +03:00
|
|
|
[~ state(timez tz)]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +select: expand message from number reference
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ select
|
2019-10-07 17:02:03 +03:00
|
|
|
::NOTE rel is the nth most recent message,
|
|
|
|
:: abs is the last message whose numbers ends in n
|
|
|
|
:: (with leading zeros used for precision)
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
|= num=$@(rel=@ud [zeros=@u abs=@ud])
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-04 23:38:22 +03:00
|
|
|
|^ ?@ num
|
|
|
|
=+ tum=(scow %s (new:si | +(num)))
|
2019-10-07 17:02:03 +03:00
|
|
|
?: (gte rel.num count)
|
2019-10-04 23:38:22 +03:00
|
|
|
%- just-print
|
|
|
|
"{tum}: no such telegram"
|
2019-10-07 17:02:03 +03:00
|
|
|
(activate tum rel.num)
|
|
|
|
?. (gte abs.num count)
|
2019-10-04 23:38:22 +03:00
|
|
|
?: =(count 0)
|
|
|
|
(just-print "0: no messages")
|
2019-10-07 17:02:03 +03:00
|
|
|
=+ msg=(index (dec count) num)
|
2019-10-04 23:38:22 +03:00
|
|
|
(activate (scow %ud msg) (sub count +(msg)))
|
|
|
|
%- just-print
|
2019-10-07 17:02:03 +03:00
|
|
|
"…{(reap zeros.num '0')}{(scow %ud abs.num)}: no such telegram"
|
2019-11-09 06:32:21 +03:00
|
|
|
:: +just-print: full [cards state] output with a single print card
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ just-print
|
|
|
|
|= txt=tape
|
2020-03-11 02:42:04 +03:00
|
|
|
[[(print:sh-out txt) ~] state]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +index: get message index from absolute reference
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ index
|
2019-10-04 23:38:22 +03:00
|
|
|
|= [max=@ud nul=@u fin=@ud]
|
|
|
|
^- @ud
|
|
|
|
=+ dog=|-(?:(=(0 fin) 1 (mul 10 $(fin (div fin 10)))))
|
|
|
|
=. dog (mul dog (pow 10 nul))
|
|
|
|
=- ?:((lte - max) - (sub - dog))
|
|
|
|
(add fin (sub max (mod max dog)))
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +activate: echo message selector and print details
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ activate
|
|
|
|
|= [number=tape index=@ud]
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
2019-10-04 23:38:22 +03:00
|
|
|
=+ gam=(snag index grams)
|
|
|
|
=. audience [source.gam ~ ~]
|
2020-03-11 02:42:04 +03:00
|
|
|
:_ state
|
2019-11-09 06:32:21 +03:00
|
|
|
^- (list card)
|
2019-10-07 17:02:03 +03:00
|
|
|
:~ (print:sh-out ['?' ' ' number])
|
|
|
|
(effect:sh-out ~(render-activate mr gam))
|
|
|
|
prompt:sh-out
|
2019-10-04 23:38:22 +03:00
|
|
|
==
|
|
|
|
--
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +chats: display list of local mailboxes
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ chats
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
:_ state
|
2019-10-04 23:38:22 +03:00
|
|
|
:_ ~
|
2019-10-07 17:02:03 +03:00
|
|
|
%- print-more:sh-out
|
2019-10-04 23:38:22 +03:00
|
|
|
=/ all
|
2020-03-11 01:31:18 +03:00
|
|
|
%^ scry-for (set path)
|
|
|
|
%chat-store
|
|
|
|
/keys
|
2019-10-04 23:38:22 +03:00
|
|
|
%+ turn ~(tap in all)
|
|
|
|
%+ cork path-to-target
|
|
|
|
|= target
|
|
|
|
(weld (scow %p ship) (spud path))
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +help: print (link to) usage instructions
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ help
|
2020-03-11 02:42:04 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
=- [[- ~] state]
|
2019-11-03 05:52:06 +03:00
|
|
|
(print:sh-out "see https://urbit.org/using/operations/using-your-ship/#messaging")
|
2019-10-03 02:30:07 +03:00
|
|
|
--
|
2019-10-07 17:02:03 +03:00
|
|
|
--
|
|
|
|
::
|
2020-05-15 02:46:18 +03:00
|
|
|
:: +sh-out: ouput to session
|
2019-10-07 17:02:03 +03:00
|
|
|
::
|
|
|
|
++ sh-out
|
|
|
|
|%
|
2020-05-15 02:46:18 +03:00
|
|
|
:: +effect: console effect card for all listeners
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ effect
|
2020-05-24 17:38:09 +03:00
|
|
|
|= effect=sole-effect:sole
|
2019-12-05 01:40:41 +03:00
|
|
|
^- card
|
2020-05-24 17:38:09 +03:00
|
|
|
[%shoe ~ %sole effect]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +print: puts some text into the cli as-is
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ print
|
|
|
|
|= txt=tape
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
2019-10-07 17:02:03 +03:00
|
|
|
(effect %txt txt)
|
|
|
|
:: +print-more: puts lines of text into the cli
|
|
|
|
::
|
|
|
|
++ print-more
|
|
|
|
|= txs=(list tape)
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
2019-10-03 02:30:07 +03:00
|
|
|
%+ effect %mor
|
2019-10-07 17:02:03 +03:00
|
|
|
(turn txs |=(t=tape [%txt t]))
|
|
|
|
:: +note: prints left-padded ---| txt
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ note
|
|
|
|
|= txt=tape
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
2019-10-07 17:02:03 +03:00
|
|
|
=+ lis=(simple-wrap txt (sub width 16))
|
|
|
|
%- print-more
|
|
|
|
=+ ?:((gth (lent lis) 0) (snag 0 lis) "")
|
|
|
|
:- (runt [14 '-'] '|' ' ' -)
|
|
|
|
%+ turn (slag 1 lis)
|
|
|
|
|=(a=tape (runt [14 ' '] '|' ' ' a))
|
|
|
|
:: +prompt: update prompt to display current audience
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ prompt
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
2019-10-07 17:02:03 +03:00
|
|
|
%+ effect %pro
|
|
|
|
:+ & %talk-line
|
|
|
|
^- tape
|
|
|
|
=- ?: =(1 (lent -)) "{-} "
|
|
|
|
"[{-}] "
|
|
|
|
=/ all
|
|
|
|
%+ sort ~(tap in audience)
|
|
|
|
|= [a=target b=target]
|
|
|
|
(~(beat tr a) b)
|
|
|
|
=+ fir=&
|
|
|
|
|- ^- tape
|
|
|
|
?~ all ~
|
|
|
|
;: welp
|
|
|
|
?:(fir "" " ")
|
|
|
|
~(show tr i.all)
|
|
|
|
$(all t.all, fir |)
|
|
|
|
==
|
|
|
|
:: +show-envelope: print incoming message
|
|
|
|
::
|
|
|
|
:: every five messages, prints the message number also.
|
|
|
|
:: if the message mentions the user's (shortened) ship name,
|
|
|
|
:: and the %notify flag is set, emit a bell.
|
|
|
|
::
|
|
|
|
++ show-envelope
|
2020-04-25 06:51:28 +03:00
|
|
|
|= [=target =envelope:store]
|
2019-11-09 06:32:21 +03:00
|
|
|
^- (list card)
|
2019-10-03 02:30:07 +03:00
|
|
|
%+ weld
|
2019-11-09 06:32:21 +03:00
|
|
|
^- (list card)
|
2019-10-03 02:30:07 +03:00
|
|
|
?. =(0 (mod count 5)) ~
|
|
|
|
:_ ~
|
|
|
|
=+ num=(scow %ud count)
|
2019-10-04 23:38:22 +03:00
|
|
|
%- print
|
2019-10-03 02:30:07 +03:00
|
|
|
(runt [(sub 13 (lent num)) '-'] "[{num}]")
|
2019-10-07 17:02:03 +03:00
|
|
|
=+ lis=~(render-inline mr target envelope)
|
2019-10-03 02:30:07 +03:00
|
|
|
?~ lis ~
|
|
|
|
:_ ~
|
|
|
|
%+ effect %mor
|
|
|
|
%+ turn `(list tape)`lis
|
|
|
|
=+ nom=(scag 7 (cite:title our-self))
|
|
|
|
|= t=tape
|
|
|
|
?. ?& (~(has in settings) %notify)
|
|
|
|
?=(^ (find nom (slag 15 t)))
|
|
|
|
==
|
|
|
|
[%txt t]
|
|
|
|
[%mor [%txt t] [%bel ~] ~]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +show-create: print mailbox creation notification
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ show-create
|
|
|
|
|= =target
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
2019-10-07 17:02:03 +03:00
|
|
|
(note "new: {~(phat tr target)}")
|
|
|
|
:: +show-delete: print mailbox deletion notification
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ show-delete
|
|
|
|
|= =target
|
2019-11-09 06:32:21 +03:00
|
|
|
^- card
|
2019-10-07 17:02:03 +03:00
|
|
|
(note "del: {~(phat tr target)}")
|
|
|
|
:: +show-glyph: print glyph un/bind notification
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
|
|
|
++ show-glyph
|
|
|
|
|= [=glyph target=(unit target)]
|
2019-11-09 06:32:21 +03:00
|
|
|
^- (list card)
|
2019-10-08 17:15:19 +03:00
|
|
|
:_ [prompt ~]
|
2019-10-04 23:38:22 +03:00
|
|
|
%- note
|
2019-10-08 17:15:19 +03:00
|
|
|
%+ weld "set: {[glyph ~]} "
|
2019-10-11 00:40:08 +03:00
|
|
|
?~ target "unbound"
|
2019-10-07 17:02:03 +03:00
|
|
|
~(phat tr u.target)
|
2020-03-11 23:52:04 +03:00
|
|
|
:: +show-invite: print incoming invite notification
|
|
|
|
::
|
|
|
|
++ show-invite
|
|
|
|
|= invite
|
|
|
|
^- card
|
|
|
|
%- note
|
|
|
|
%+ weld "invited to: "
|
|
|
|
~(phat tr (path-to-target path))
|
2019-10-03 02:30:07 +03:00
|
|
|
--
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +tr: render targets
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ tr
|
2019-10-03 02:30:07 +03:00
|
|
|
|_ :: one: the target.
|
|
|
|
::
|
|
|
|
one=target
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +beat: true if one is more "relevant" than two
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ beat
|
2019-10-03 02:30:07 +03:00
|
|
|
|= two=target
|
|
|
|
^- ?
|
|
|
|
:: the target that's ours is better.
|
|
|
|
?: =(our-self ship.one)
|
|
|
|
?. =(our-self ship.two) &
|
|
|
|
?< =(path.one path.two)
|
|
|
|
:: if both targets are ours, the main story is better.
|
|
|
|
?: =(%inbox path.one) &
|
|
|
|
?: =(%inbox path.two) |
|
|
|
|
:: if neither are, pick the "larger" one.
|
|
|
|
(lth (lent path.one) (lent path.two))
|
|
|
|
:: if one isn't ours but two is, two is better.
|
|
|
|
?: =(our-self ship.two) |
|
|
|
|
?: =(ship.one ship.two)
|
|
|
|
:: if they're from the same ship, pick the "larger" one.
|
|
|
|
(lth (lent path.one) (lent path.two))
|
|
|
|
:: if they're from different ships, neither ours, pick hierarchically.
|
|
|
|
(lth (xeb ship.one) (xeb ship.two))
|
2019-11-13 02:09:18 +03:00
|
|
|
:: +full: render target fully, always
|
|
|
|
::
|
|
|
|
++ full
|
|
|
|
^- tape
|
2020-03-11 02:40:21 +03:00
|
|
|
;: weld
|
2020-03-16 19:46:58 +03:00
|
|
|
?:(in-group.one "" "~/")
|
2020-03-11 02:40:21 +03:00
|
|
|
(scow %p ship.one)
|
|
|
|
(spud path.one)
|
|
|
|
==
|
2019-11-13 02:09:18 +03:00
|
|
|
:: +phat: render target with local shorthand
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
:: renders as ~ship/path.
|
|
|
|
:: for local mailboxes, renders just /path.
|
|
|
|
:: for sponsor's mailboxes, renders ^/path.
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ phat
|
2019-10-03 02:30:07 +03:00
|
|
|
^- tape
|
2020-03-11 02:40:21 +03:00
|
|
|
%+ weld
|
2020-03-16 19:46:58 +03:00
|
|
|
?:(in-group.one "" "~/")
|
2019-10-04 23:38:22 +03:00
|
|
|
%+ weld
|
|
|
|
?: =(our-self ship.one) ~
|
|
|
|
?: =((sein:title our.bowl now.bowl our-self) ship.one) "^"
|
|
|
|
(scow %p ship.one)
|
|
|
|
(spud path.one)
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +show: render as tape, as glyph if we can
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ show
|
2019-10-03 02:30:07 +03:00
|
|
|
^- tape
|
2019-10-07 17:02:03 +03:00
|
|
|
=+ cha=(~(get by bound) one)
|
|
|
|
?~(cha phat "{u.cha ~}")
|
|
|
|
:: +glyph: tape for glyph of target, defaulting to *
|
2019-10-04 23:38:22 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ glyph
|
2019-10-04 23:38:22 +03:00
|
|
|
^- tape
|
2019-10-07 17:02:03 +03:00
|
|
|
[(~(gut by bound) one '*') ~]
|
2019-10-03 02:30:07 +03:00
|
|
|
--
|
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +mr: render messages
|
|
|
|
::
|
|
|
|
++ mr
|
2020-05-24 17:38:09 +03:00
|
|
|
=, sole
|
2019-10-07 17:02:03 +03:00
|
|
|
|_ $: source=target
|
2020-04-25 06:51:28 +03:00
|
|
|
envelope:store
|
2019-10-03 02:30:07 +03:00
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +activate: produce sole-effect for printing message details
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ render-activate
|
2020-05-15 15:40:36 +03:00
|
|
|
^- sole-effect
|
2019-10-07 17:02:03 +03:00
|
|
|
~[%mor [%tan meta] body]
|
|
|
|
:: +meta: render message metadata (serial, timestamp, author, target)
|
|
|
|
::
|
|
|
|
++ meta
|
|
|
|
^- tang
|
|
|
|
=. when (sub when (mod when (div when ~s0..0001))) :: round
|
|
|
|
=+ hed=leaf+"{(scow %uv uid)} at {(scow %da when)}"
|
|
|
|
=/ src=tape ~(phat tr source)
|
|
|
|
[%rose [" " ~ ~] [hed >author< [%rose [", " "to " ~] [leaf+src]~] ~]]~
|
|
|
|
:: +body: long-form render of message contents
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ body
|
2020-05-15 15:40:36 +03:00
|
|
|
|- ^- sole-effect
|
2019-10-07 17:02:03 +03:00
|
|
|
?- -.letter
|
2019-10-07 21:45:58 +03:00
|
|
|
?(%text %me)
|
|
|
|
=/ pre=tape ?:(?=(%me -.letter) "@ " "")
|
|
|
|
tan+~[leaf+"{pre}{(trip +.letter)}"]
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
%url
|
|
|
|
url+url.letter
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
%code
|
|
|
|
=/ texp=tape ['>' ' ' (trip expression.letter)]
|
|
|
|
:- %mor
|
2020-05-15 15:40:36 +03:00
|
|
|
|- ^- (list sole-effect)
|
2019-10-07 17:02:03 +03:00
|
|
|
?: =("" texp) [tan+output.letter ~]
|
|
|
|
=/ newl (find "\0a" texp)
|
|
|
|
?~ newl [txt+texp $(texp "")]
|
|
|
|
=+ (trim u.newl texp)
|
|
|
|
:- txt+(scag u.newl texp)
|
|
|
|
$(texp [' ' ' ' (slag +(u.newl) texp)])
|
|
|
|
==
|
|
|
|
:: +render-inline: produces lines to display message body in scrollback
|
|
|
|
::
|
|
|
|
++ render-inline
|
2019-10-03 02:30:07 +03:00
|
|
|
^- (list tape)
|
|
|
|
=/ wyd
|
2019-10-07 17:02:03 +03:00
|
|
|
:: termwidth,
|
|
|
|
%+ sub width
|
|
|
|
:: minus autor,
|
|
|
|
%+ add 14
|
|
|
|
:: minus timestamp.
|
|
|
|
?:((~(has in settings) %showtime) 10 0)
|
|
|
|
=+ txs=(line wyd)
|
2019-10-03 02:30:07 +03:00
|
|
|
?~ txs ~
|
2019-10-07 17:02:03 +03:00
|
|
|
:: nom: rendered author
|
|
|
|
:: den: regular indent
|
|
|
|
:: tam: timestamp, if desired
|
|
|
|
::
|
|
|
|
=/ nom=tape (nome author)
|
|
|
|
=/ den=tape (reap (lent nom) ' ')
|
2019-10-03 02:30:07 +03:00
|
|
|
=/ tam=tape
|
|
|
|
?. (~(has in settings) %showtime) ""
|
|
|
|
=. when
|
|
|
|
%. [when (mul q.timez ~h1)]
|
|
|
|
?:(p.timez add sub)
|
|
|
|
=+ dat=(yore when)
|
|
|
|
=/ t
|
|
|
|
|= a/@
|
|
|
|
%+ weld
|
|
|
|
?:((lth a 10) "0" ~)
|
|
|
|
(scow %ud a)
|
|
|
|
=/ time
|
|
|
|
;: weld
|
|
|
|
"~" (t h.t.dat)
|
|
|
|
"." (t m.t.dat)
|
|
|
|
"." (t s.t.dat)
|
|
|
|
==
|
|
|
|
%+ weld
|
|
|
|
(reap (sub +(wyd) (min wyd (lent (tuba i.txs)))) ' ')
|
|
|
|
time
|
|
|
|
%- flop
|
|
|
|
%+ roll `(list tape)`txs
|
|
|
|
|= [t=tape l=(list tape)]
|
|
|
|
?~ l [:(weld nom t tam) ~]
|
|
|
|
[(weld den t) l]
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +nome: prints a ship name in 14 characters, left-padding with spaces
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
++ nome
|
|
|
|
|= =ship
|
2019-10-03 02:30:07 +03:00
|
|
|
^- tape
|
2019-10-07 17:02:03 +03:00
|
|
|
=+ raw=(cite:title ship)
|
|
|
|
(runt [(sub 14 (lent raw)) ' '] raw)
|
|
|
|
:: +line: renders most important contents, tries to fit one line
|
2019-10-03 02:30:07 +03:00
|
|
|
::
|
2019-10-07 17:02:03 +03:00
|
|
|
::TODO this should probably be rewritten someday
|
|
|
|
++ line
|
2019-10-03 02:30:07 +03:00
|
|
|
:: pre: replace/append line prefix
|
2019-10-07 17:02:03 +03:00
|
|
|
::
|
2019-10-03 02:30:07 +03:00
|
|
|
=| pre=(unit (pair ? tape))
|
|
|
|
|= wyd=@ud
|
|
|
|
^- (list tape)
|
|
|
|
?- -.letter
|
|
|
|
%code
|
|
|
|
=+ texp=(trip expression.letter)
|
|
|
|
=+ newline=(find "\0a" texp)
|
|
|
|
=? texp ?=(^ newline)
|
|
|
|
(weld (scag u.newline texp) " ...")
|
2019-10-07 17:02:03 +03:00
|
|
|
:- (truncate wyd '#' ' ' texp)
|
2019-10-03 02:30:07 +03:00
|
|
|
?~ output.letter ~
|
2019-10-07 17:02:03 +03:00
|
|
|
=- [' ' (truncate (dec wyd) ' ' -)]~
|
2019-10-03 02:30:07 +03:00
|
|
|
~(ram re (snag 0 `(list tank)`output.letter))
|
|
|
|
::
|
|
|
|
%url
|
|
|
|
:_ ~
|
|
|
|
=+ ful=(trip url.letter)
|
|
|
|
=+ pef=q:(fall pre [p=| q=""])
|
|
|
|
:: clean up prefix if needed.
|
|
|
|
=? pef =((scag 1 (flop pef)) " ")
|
|
|
|
(scag (dec (lent pef)) pef)
|
|
|
|
=. pef (weld "/" pef)
|
|
|
|
=. wyd (sub wyd +((lent pef))) :: account for prefix.
|
|
|
|
:: if the full url fits, just render it.
|
|
|
|
?: (gte wyd (lent ful)) :(weld pef " " ful)
|
|
|
|
:: if it doesn't, prefix with _ and render just (the tail of) the domain.
|
|
|
|
%+ weld (weld pef "_")
|
2019-10-07 21:45:58 +03:00
|
|
|
=+ prl=(rust ful aurf:de-purl:html)
|
|
|
|
?~ prl (weld (scag (dec wyd) ful) "…")
|
|
|
|
=+ hok=r.p.p.u.prl
|
2019-10-03 02:30:07 +03:00
|
|
|
=- (swag [a=(sub (max wyd (lent -)) wyd) b=wyd] -)
|
|
|
|
^- tape
|
|
|
|
=< ?: ?=(%& -.hok)
|
|
|
|
(reel p.hok .)
|
|
|
|
+:(scow %if p.hok)
|
|
|
|
|= [a=knot b=tape]
|
|
|
|
?~ b (trip a)
|
|
|
|
(welp b '.' (trip a))
|
|
|
|
::
|
2019-10-07 21:45:58 +03:00
|
|
|
?(%text %me)
|
2019-10-03 02:30:07 +03:00
|
|
|
:: glyph prefix
|
|
|
|
=/ pef=tape
|
|
|
|
?: &(?=(^ pre) p.u.pre) q.u.pre
|
2019-10-07 21:45:58 +03:00
|
|
|
?: ?=(%me -.letter) " "
|
2019-10-03 02:30:07 +03:00
|
|
|
=- (weld - q:(fall pre [p=| q=" "]))
|
2019-10-07 17:02:03 +03:00
|
|
|
~(glyph tr source)
|
2019-10-03 02:30:07 +03:00
|
|
|
=/ lis=(list tape)
|
|
|
|
%+ simple-wrap
|
2020-05-14 23:35:05 +03:00
|
|
|
=/ result=(each tape tang)
|
|
|
|
%- mule |.
|
|
|
|
`(list @)`(tuba (trip +.letter))
|
|
|
|
?- -.result
|
|
|
|
%& p.result
|
|
|
|
%| "[[msg rendering error]]"
|
|
|
|
==
|
2019-10-03 02:30:07 +03:00
|
|
|
(sub wyd (min (div wyd 2) (lent pef)))
|
|
|
|
=+ lef=(lent pef)
|
|
|
|
=+ ?:((gth (lent lis) 0) (snag 0 lis) "")
|
|
|
|
:- (weld pef -)
|
|
|
|
%+ turn (slag 1 lis)
|
|
|
|
|=(a=tape (runt [lef ' '] a))
|
|
|
|
==
|
2019-10-07 17:02:03 +03:00
|
|
|
:: +truncate: truncate txt to fit len, indicating truncation with _ or …
|
|
|
|
::
|
|
|
|
++ truncate
|
|
|
|
|= [len=@u txt=tape]
|
|
|
|
^- tape
|
|
|
|
?: (gth len (lent txt)) txt
|
|
|
|
=. txt (scag len txt)
|
|
|
|
|-
|
|
|
|
?~ txt txt
|
|
|
|
?: =(' ' i.txt)
|
|
|
|
|-
|
|
|
|
:- '_'
|
|
|
|
?. ?=([%' ' *] t.txt)
|
|
|
|
t.txt
|
|
|
|
$(txt t.txt)
|
|
|
|
?~ t.txt "…"
|
|
|
|
[i.txt $(txt t.txt)]
|
2019-10-03 02:30:07 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ simple-wrap
|
2019-10-07 17:02:03 +03:00
|
|
|
|= [txt=tape wid=@ud]
|
2019-10-03 02:30:07 +03:00
|
|
|
^- (list tape)
|
|
|
|
?~ txt ~
|
2019-12-18 03:48:08 +03:00
|
|
|
=/ [end=@ud nex=?]
|
2020-05-15 15:10:07 +03:00
|
|
|
=+ ret=(find "\0a" (scag +(wid) `tape`txt))
|
|
|
|
?^ ret [u.ret &]
|
2019-10-07 17:02:03 +03:00
|
|
|
?: (lte (lent txt) wid) [(lent txt) &]
|
|
|
|
=+ ace=(find " " (flop (scag +(wid) `tape`txt)))
|
|
|
|
?~ ace [wid |]
|
|
|
|
[(sub wid u.ace) &]
|
2019-10-03 02:30:07 +03:00
|
|
|
:- (tufa (scag end `(list @)`txt))
|
|
|
|
$(txt (slag ?:(nex +(end) end) `tape`txt))
|
2020-03-11 01:31:18 +03:00
|
|
|
::
|
|
|
|
::NOTE anything that uses this breaks moons support, because moons don't sync
|
|
|
|
:: full app state rn
|
|
|
|
++ scry-for
|
|
|
|
|* [=mold app=term =path]
|
|
|
|
.^ mold
|
|
|
|
%gx
|
|
|
|
(scot %p our.bowl)
|
|
|
|
app
|
|
|
|
(scot %da now.bowl)
|
|
|
|
(snoc `^path`path %noun)
|
|
|
|
==
|
2019-10-09 00:00:46 +03:00
|
|
|
--
|