chat-cli: Make more fully-featured

Brings it largely up to parity with Talk, save for features relating to:
- presence & nicknames
- circle management (permissions, sources)
- deprecated message types

In addition to implementing remaining functionality for basic usage
patterns, makes the following changes:
- glyphs per target, not multiple targets
- assume /~ship/path paths are created/used by the chat-hook

Code cleanup pending.
This commit is contained in:
Fang 2019-10-04 22:38:22 +02:00
parent 07454e2327
commit 7911061dab
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -3,21 +3,27 @@
:: pulls all known messages into a single stream. :: pulls all known messages into a single stream.
:: type ;help for usage instructions. :: type ;help for usage instructions.
:: ::
:: 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.
::
::NOTE the code is a mess. heavily wip! ::NOTE the code is a mess. heavily wip!
:: ::
/- sole-sur=sole, *chat-store, *chat-view, *chat-hook /- sole-sur=sole, *chat-store, *chat-view, *chat-hook
/+ sole-lib=sole /+ sole-lib=sole
/= seed /~ !>(.)
:: ::
|% |%
+$ state +$ state
$: grams=(list mail) $: grams=(list mail)
known=(set [path serial]) known=(set [target serial])
count=@ud :: (lent grams) count=@ud :: (lent grams)
:: ui state :: :: ui state ::
nicks=(map ship @t) ::TODO contacts ::TODO nicks from contacts
bound=(map (set target) char) :: bound circle glyphs bound=(map target char) :: bound circle glyphs
binds=(jug char (set target)) :: circle glyph lookup binds=(jug char target) :: circle glyph lookup
latest=@ud :: latest shown msg num
audience=(set target) :: active targets audience=(set target) :: active targets
settings=(set term) :: frontend flags settings=(set term) :: frontend flags
width=@ud :: display width width=@ud :: display width
@ -25,19 +31,33 @@
cli=[=bone state=sole-share:sole-sur] :: console id & state cli=[=bone state=sole-share:sole-sur] :: console id & state
== ==
:: ::
+$ mail [source=path envelope] +$ mail [source=target envelope]
+$ target [=ship =path] +$ target [=ship =path]
:: ::
++ command +$ glyph char
$% [%say (list letter)] :: send message ++ glyphs "!@#$%^&()-=_+[]\{};'\\:\",.<>?"
::
+$ command
$% [%target (set target)] :: set messaging target
[%say (list letter)] :: send message
[%eval cord hoon] :: send #-message [%eval cord hoon] :: send #-message
:: ::
[%create =path =(unit char)] [%create path =(unit glyph)] :: create chat
[%join targets=(set target)] [%join target =(unit glyph)] :: join target
[%leave targets=(set target)] [%leave target] :: nuke target
:: ::
[%target to=(set target)] [%bind glyph target] :: bind glyph
[%unbind glyph] :: unbind glyph
[%what (unit $@(char target))] :: glyph lookup
:: ::
[%settings ~] :: show active settings
[%set term] :: set settings flag
[%unset term] :: unset settings flag
[%width @ud] :: adjust display width
[%timezone ? @ud] :: adjust time printing
::
[%select $@(back=@ud [zeros=@u num=@ud])] :: rel/abs msg selection
[%chats ~] :: list available chats
[%help ~] :: print usage info [%help ~] :: print usage info
== :: == ::
:: ::
@ -53,13 +73,6 @@
[%chat-view-action chat-view-action] [%chat-view-action chat-view-action]
[%chat-hook-action chat-hook-action] [%chat-hook-action chat-hook-action]
== ==
::
::TODO why is this not in /sur/chat-store
+$ in-diff
$% [%chat-initial inbox]
[%chat-configs chat-configs]
[%chat-update chat-update]
==
-- --
:: ::
|_ [=bowl:gall state] |_ [=bowl:gall state]
@ -67,8 +80,10 @@
++ prep ++ prep
|= old=(unit state) |= old=(unit state)
~& %chat-cli-prep ~& %chat-cli-prep
?^ old [~ this(+<+ u.old)] ?^ old
=. audience [[our.bowl /inbox] ~ ~] :_ this(+<+ u.old)
[ost.bowl %peer /chat-store [our-self %chat-store] /all]~
=. audience [[our-self /inbox] ~ ~]
=. settings (sy %showtime %notify ~) =. settings (sy %showtime %notify ~)
=. width 80 =. width 80
:_ this :_ this
@ -86,22 +101,41 @@
:: ::
++ our-self (true-self our.bowl) ++ our-self (true-self our.bowl)
:: ::
++ target-to-path
|= target
path
::TODO
:: [(scot %p ship) path]
::
++ path-to-target
|= =path
^- target
?. ?=([@ @ *] path)
::TODO but then doing target-to-path won't get us the same path...
[our-self path]
=+ who=(slaw %p i.path)
?~ who [our-self path]
[u.who path]
::
++ diff-chat-initial ++ diff-chat-initial
|= [=wire =inbox] |= [=wire =inbox]
^- (quip move _this) ^- (quip move _this)
=| moves=(list move) =| moves=(list move)
|- ^- (quip move _this) |- ^- (quip move _this)
?~ inbox [~ this] ?~ inbox [~ this]
=^ mon this (read-envelopes [p envelopes.q]:n.inbox) =* path p.n.inbox
=* mailbox q.n.inbox
=/ =target (path-to-target path)
=^ mon this (read-envelopes target envelopes.mailbox)
=^ mol this $(inbox l.inbox) =^ mol this $(inbox l.inbox)
=^ mor this $(inbox r.inbox) =^ mor this $(inbox r.inbox)
[:(weld mon mol mor) this] [:(weld mon mol mor) this]
:: ::
++ read-envelopes ++ read-envelopes
|= [=path envs=(list envelope)] |= [=target envs=(list envelope)]
^- (quip move _this) ^- (quip move _this)
?~ envs [~ this] ?~ envs [~ this]
=^ moi this (read-envelope path i.envs) =^ moi this (read-envelope target i.envs)
=^ mot this $(envs t.envs) =^ mot this $(envs t.envs)
[(weld moi mot) this] [(weld moi mot) this]
:: ::
@ -109,26 +143,68 @@
|= [=wire upd=chat-update] |= [=wire upd=chat-update]
^- (quip move _this) ^- (quip move _this)
?+ -.upd [~ this] ?+ -.upd [~ this]
%message (read-envelope +.upd) %create (notice-create (path-to-target path.upd))
%delete [[(show-delete:sh (path-to-target path.upd)) ~] this]
%message (read-envelope (path-to-target path.upd) envelope.upd)
== ==
:: ::
++ read-envelope ++ notice-create
|= [=path =envelope] |= =target
^- (quip move _this) ^- (quip move _this)
?: (~(has in known) [path uid.envelope]) =^ moz this
?: (~(has by bound) target)
[~ this]
(bind-default-glyph target)
[[(show-create:sh target) moz] this]
::
++ bind-default-glyph
|= =target
^- (quip move _this)
=- (bind-glyph - target)
::TODO try not to double-bind
=- (snag - glyphs)
(mod (mug target) (lent glyphs))
::
++ bind-glyph
|= [=glyph =target]
^- (quip move _this)
::TODO should send these to settings store eventually
::TODO disallow double-binding glyphs?
=. bound (~(put by bound) target glyph)
=. binds (~(put ju binds) glyph target)
[(show-glyph:sh glyph `target) this]
::
++ unbind-glyph
|= =glyph ::TODO do we really not want this optionally per-audience?
^- (quip move _this)
=/ 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)
[(show-glyph:sh glyph ~) this]
::
++ read-envelope
|= [=target =envelope]
^- (quip move _this)
?: (~(has in known) [target uid.envelope])
::NOTE we no-op only because edits aren't possible ::NOTE we no-op only because edits aren't possible
[~ this] [~ this]
:- (print-envelope:sh path envelope) :- (print-envelope:sh target envelope)
%_ this %_ this
known (~(put in known) [path uid.envelope]) known (~(put in known) [target uid.envelope])
grams [[path envelope] grams] grams [[target envelope] grams]
count +(count) count +(count)
== ==
:: ::
++ peer ++ peer
|= =path |= =path
^- (quip move _this) ^- (quip move _this)
?. =(src.bowl our.bowl) ?. (team:title our-self src.bowl)
~| [%peer-talk-stranger src.bowl] ~| [%peer-talk-stranger src.bowl]
!! !!
?. ?=([%sole *] path) ?. ?=([%sole *] path)
@ -147,6 +223,7 @@
~|(%strange-sole !!) ~|(%strange-sole !!)
(sole:sh act) (sole:sh act)
:: ::
::TODO maybe separate +shin and +shout
++ sh ++ sh
|% |%
++ effect ++ effect
@ -156,6 +233,12 @@
^- move ^- move
[bone.cli %diff %sole-effect fec] [bone.cli %diff %sole-effect fec]
:: ::
++ print
:: just puts some text into the cli as-is.
::
|= txt=tape
(effect %txt txt)
::
++ note ++ note
:: shell message :: shell message
:: ::
@ -176,14 +259,22 @@
:: makes and stores a move to modify the cli :: makes and stores a move to modify the cli
:: prompt to display the current audience. :: prompt to display the current audience.
:: ::
::TODO take arg?
^- move ^- move
%+ effect %pro %+ effect %pro
:+ & %talk-line :+ & %talk-line
^- tape ^- tape
=+ cha=(~(get by bound) audience) =- ?: =(1 (lent -)) "{-} "
?^ cha ~[u.cha ' '] "[{-}] "
=+ por=~(ar-prom ar audience) :: %- zing
(weld `tape`['[' por] `tape`[']' ' ' ~]) :: %+ join " "
:: ^- (list tape)
:: %+ turn ~(tap in audience)
:: |= =target
:: ^- tape
:: =+ gyf=(~(get by bound) target)
:: ?^ gyf ~[u.gyf]
~(ar-prom ar audience)
:: ::
++ sole ++ sole
:: applies sole action. :: applies sole action.
@ -246,34 +337,27 @@
|=(a/(list ^ship) (~(gas in *(set ^ship)) a)) |=(a/(list ^ship) (~(gas in *(set ^ship)) a))
(most ;~(plug com (star ace)) ship) (most ;~(plug com (star ace)) ship)
:: ::
::TODO stolen from stdlib stab, add to stdlib
++ path ++ path
;~(pfix net (more net urs:ab)) ;~(pfix net (most net urs:ab))
:: ::
++ tarl :: local target ++ tarl :: local target
;~(pfix cen (stag our-self path)) (stag our-self path)
::
++ tarp :: sponsor target
;~(pfix ket (stag (sein:title our.bowl now.bowl our-self) path))
:: ::
++ targ :: target ++ targ :: target
;~ pose ;~ pose
(cold [our-self /] col)
;~(pfix ket (stag (^sein:title our-self) path))
tarl tarl
tarp
;~(plug ship path) ;~(plug ship path)
== (sear glyf glyph)
::
++ targets-flat :: collapse mixed list
|= a=(list (each target (set target)))
^- (set target)
?~ a ~
?- -.i.a
%& (~(put in $(a t.a)) p.i.a)
%| (~(uni in $(a t.a)) p.i.a)
== ==
:: ::
++ tars :: non-empty circles ++ tars :: non-empty circles
%+ cook targets-flat %+ cook ~(gas in *(set target))
%+ most ;~(plug com (star ace)) %+ most ;~(plug com (star ace))
(^pick targ (sear glyf glyph)) ;~(pose targ (sear glyf glyph))
:: ::
++ drat ++ drat
:: @da or @dr :: @da or @dr
@ -331,11 +415,9 @@
(plus ;~(less (jest '•') next)) (plus ;~(less (jest '•') next))
:: ::
++ nick (cook crip (plus next)) :: nickname ++ nick (cook crip (plus next)) :: nickname
++ glyph (mask "!@#$%^&()-=_+[]\{}'\\:\"|,./<>?") :: circle postfix ++ glyph (mask glyphs) :: circle postfix
++ setting :: setting flag ++ setting :: setting flag
%- perk :~ %- perk :~
%nicks
%quiet
%notify %notify
%showtime %showtime
== ==
@ -343,17 +425,40 @@
++ work :: full input ++ work :: full input
%+ knee *command |. ~+ %+ knee *command |. ~+
=- ;~(pose ;~(pfix mic -) message) =- ;~(pose ;~(pfix mic -) message)
::TODO refactor the optional trailing args, glue junk
;~ pose ;~ pose
(stag %target tars)
:: ::
;~((glue ace) (tag %create) ;~(plug path (punt ;~(pfix ace glyph)))) ;~((glue ace) (tag %create) ;~(plug path (punt ;~(pfix ace glyph))))
:: ::
;~((glue ace) (tag %join) tars) ;~((glue ace) (tag %join) ;~(plug targ (punt ;~(pfix ace glyph))))
;~((glue ace) (tag %leave) tars) ;~((glue ace) (tag %leave) targ)
:: ::
(stag %target tars) ;~((glue ace) (tag %bind) glyph targ)
;~((glue ace) (tag %unbind) glyph)
;~(plug (perk %what ~) (punt ;~(pfix ace ;~(pose glyph targ))))
:: ::
;~(plug (tag %settings) (easy ~))
;~((glue ace) (tag %set) setting)
;~((glue ace) (tag %unset) setting)
;~(plug (cold %width (jest 'set width ')) dem:ag)
;~ 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 ~)) ;~(plug (tag %help) (easy ~))
:: ::
(stag %select pick)
== ==
-- --
:: ::
@ -396,16 +501,28 @@
:: ::
|= job=command |= job=command
^- (quip move _this) ^- (quip move _this)
|^ ?+ -.job ~|([%unimplemented -.job] !!) |^ ?- -.job ::~|([%unimplemented -.job] !!)
:: %join (join +.job) %target (set-target +.job)
:: %leave (leave +.job) ::
%join (join +.job)
%leave (leave +.job)
%create (create +.job) %create (create +.job)
:: ::
%say (say +.job) %say (say +.job)
:: %eval (eval +.job) %eval (eval +.job)
:: ::
%target (set-target +.job) %bind (bind-glyph +.job)
%unbind (unbind-glyph +.job)
%what (lookup-glyph +.job)
:: ::
%settings show-settings
%set (set-setting +.job)
%unset (unset-setting +.job)
%width (set-width +.job)
%timezone (set-timezone +.job)
::
%select (select +.job)
%chats chats
%help help %help help
== ==
:: ::
@ -415,58 +532,49 @@
:* ost.bowl :* ost.bowl
%poke %poke
/cli-command/[what] /cli-command/[what]
[our.bowl app] [our-self app]
out-action out-action
== ==
:: ::
++ set-glyph ++ set-target
:: new glyph binding |= tars=(set target)
:: ^- (quip move _this)
:: applies glyph binding to our state. =. audience tars
:: [[prompt ~] this]
|= [cha=char aud=(set target)]
%_ this
bound (~(put by bound) aud cha)
binds (~(put ju binds) cha aud)
==
::TODO should send these to settings store eventually
::
++ unset-glyph
:: remove old glyph binding
::
:: removes either {aud} or all bindings on a
:: glyph.
::
|= [cha=char aud=(unit (set target))]
^+ this
=/ ole=(set (set target))
?^ aud [u.aud ~ ~]
(~(get ju binds) cha)
|- ^+ this
?~ ole this
=. this $(ole l.ole)
=. this $(ole r.ole)
%_ this
bound (~(del by bound) n.ole)
binds (~(del ju binds) cha n.ole)
==
::TODO should send these to settings store eventually
:: ::
++ create ++ create
::TODO configurable security ::TODO configurable security
|= [=path gyf=(unit char)] |= [=path gyf=(unit char)]
^- (quip move _this) ^- (quip move _this)
::TODO check if already exists ::TODO check if already exists
=/ =target [our.bowl path] =/ =target [our-self path]
=. audience [target ~ ~] =^ moz this
=? this ?=(^ gyf) ?. ?=(^ gyf) [~ this]
(set-glyph u.gyf audience) (bind-glyph u.gyf target)
:_ this =- [[- moz] this(audience [target ~ ~])]
:_ ~
%^ act %do-create %chat-view %^ act %do-create %chat-view
:- %chat-view-action :- %chat-view-action
[%create path %channel ~ ~] [%create path %channel ~ ~]
:: ::
++ join
|= [=target gyf=(unit char)]
^- (quip move _this)
=^ moz this
?. ?=(^ gyf) [~ this]
(bind-glyph u.gyf target)
=- [[- moz] this(audience [target ~ ~])]
%^ act %do-join %chat-hook
:- %chat-hook-action
[%add-synced target]
::
::TODO but if we leave our own circle, then it disappears for everyone?
++ leave
|= =target
=- [[- ~] this]
%^ act %do-leave %chat-hook
:- %chat-hook-action
[%remove (target-to-path target)]
::
++ say ++ say
|= letters=(list letter) |= letters=(list letter)
^- (quip move _this) ^- (quip move _this)
@ -478,27 +586,171 @@
|= =target |= =target
%^ act %out-message %chat-hook %^ act %out-message %chat-hook
:- %chat-action :- %chat-action
:+ %message path.target :+ %message (target-to-path target)
:* serial :* serial
*@ *@
our.bowl our-self
now.bowl now.bowl
(snag 0 letters) ::TODO support multiple (snag 0 letters) ::TODO support multiple
== ==
:: ::
++ set-target ++ eval
|= tars=(set target) :: run
::
:: executes {exe} and sends both its code and
:: result.
::
|= [txt=cord exe=hoon]
:: XX revisit
::
:: this double-virtualizes and clams to disable .^
::
=; tan=(list tank)
(say [%code txt tan] ~)
;; (list tank)
=< +>
%+ mong
:- mute
=- |.([(sell (slap (slop !>(-) seed) exe))]~)
^- [our=@p now=@da eny=@uvI]
[our-self now.bowl (shas %eny eny.bowl)]
|=(^ ~)
::
++ lookup-glyph
::TODO we probably want a function for the (list tape) -> %mor %txt case
|= qur=(unit $@(glyph target))
^- (quip move _this) ^- (quip move _this)
=. audience tars =- [[- ~] this]
[[prompt ~] this] ?^ qur
?^ u.qur
=+ gyf=(~(get by bound) u.qur)
(print ?~(gyf "none" [u.gyf]~))
=+ pan=~(tap in (~(get ju binds) `@t`u.qur))
?: =(~ pan) (print "~")
=< (effect %mor (turn pan .))
|=(t=target [%txt ~(cr-phat cr t)])
%+ effect %mor
%- ~(rep by binds)
|= $: [=glyph tars=(set target)]
lis=(list sole-effect:sole-sur)
==
%+ weld lis
^- (list sole-effect:sole-sur)
%- ~(rep in tars)
|= [t=target l=(list sole-effect:sole-sur)]
%+ weld l
^- (list sole-effect:sole-sur)
[%txt glyph ' ' ~(cr-phat cr t)]~
::
++ show-settings
^- (quip move _this)
:_ this
:~ %- print
%- zing
^- (list tape)
:- "flags: "
%+ ^join ", "
(turn `(list @t)`~(tap in settings) trip)
::
%- print
%+ weld "timezone: "
^- tape
:- ?:(p.timez '+' '-')
(scow %ud q.timez)
::
(print "width: {(scow %ud width)}")
==
::
++ set-setting
|= =term
^- (quip move _this)
[~ this(settings (~(put in settings) term))]
::
++ unset-setting
|= =term
^- (quip move _this)
[~ this(settings (~(del in settings) term))]
::
++ set-width
|= w=@ud
[~ this(width w)]
::
++ set-timezone
|= tz=[? @ud]
[~ this(timez tz)]
::
++ select
:: finds selected message, expand it.
::
::TODO this either needs a different implementation or extensive comments
|= num=$@(@ud [p=@u q=@ud])
^- (quip move _this)
|^ ?@ num
=+ tum=(scow %s (new:si | +(num)))
?: (gte num count)
%- just-print
"{tum}: no such telegram"
(activate tum num)
?. (gte q.num count)
?: =(count 0)
(just-print "0: no messages")
=+ msg=(deli (dec count) num)
(activate (scow %ud msg) (sub count +(msg)))
%- just-print
"…{(reap p.num '0')}{(scow %ud q.num)}: no such telegram"
::
++ just-print
|= txt=tape
[[(print txt) ~] this]
::
++ deli
:: gets absolute message number from relative.
::
|= [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)))
::
++ activate
:: prints message details.
::
|= [number=tape index=@ud]
^- (quip move _this)
=+ gam=(snag index grams)
=+ tay=~(. tr settings gam)
=. audience [source.gam ~ ~]
:_ this
^- (list move)
:~ (print ['?' ' ' number])
(effect tr-fact:tay)
prompt
==
--
::
++ chats
^- (quip move _this)
:_ this
:_ ~
%+ effect %mor
=/ all
::TODO refactor
::TODO remote scries fail... but moon support?
.^ (set path)
%gx
/(scot %p our-self)/chat-store/(scot %da now.bowl)/keys/noun
==
%+ turn ~(tap in all)
%+ cork path-to-target
|= target
:- %txt
(weld (scow %p ship) (spud path))
:: ::
++ help ++ help
^- (quip move _this) ^- (quip move _this)
:_ this =- [[- ~] this]
:~ (effect %txt "see https://urbit.org/docs/using/messaging/") (print "see https://urbit.org/docs/using/messaging/")
::TODO tmp
`move`[ost.bowl %peer /chat-store [our.bowl %chat-store] /all]
==
-- --
:: ::
++ sanity ++ sanity
@ -535,34 +787,34 @@
:: finds the circle(s) that match a glyph. :: finds the circle(s) that match a glyph.
:: ::
|= cha=char |= cha=char
^- (unit (set target)) ^- (unit target)
=+ lax=(~(get ju binds) cha) =+ lax=(~(get ju binds) cha)
:: no circle. :: no circle.
?: =(~ lax) ~ ?: =(~ lax) ~
:: single circle. :: single circle.
?: ?=({* ~ ~} lax) `n.lax ?: ?=([* ~ ~] lax) `n.lax
:: in case of multiple audiences, pick the most recently active one. :: in case of multiple audiences, pick the most recently active one.
|- ^- (unit (set target)) |- ^- (unit target)
~& %multi-bind-support-missing
?~ grams ~ ?~ grams ~
~ ~
::TODO ::TODO
:: :: get first circle from a telegram's audience.
:: =+ pan=(silt ~(tap in aud.i.grams)) :: =+ pan=(silt ~(tap in aud.i.grams))
:: ?: (~(has in lax) pan) `pan :: ?: (~(has in lax) pan) `pan
:: $(grams t.grams) :: $(grams t.grams)
:: ::
++ print-envelope ++ print-envelope
|= [=path =envelope] |= [=target =envelope]
^- (list move) ^- (list move)
%+ weld %+ weld
^- (list move) ^- (list move)
?. =(0 (mod count 5)) ~ ?. =(0 (mod count 5)) ~
:_ ~ :_ ~
=+ num=(scow %ud count) =+ num=(scow %ud count)
%+ effect %txt %- print
(runt [(sub 13 (lent num)) '-'] "[{num}]") (runt [(sub 13 (lent num)) '-'] "[{num}]")
::TODO %notify logic? or do elsewhere? just check the %text msgs ::TODO %notify logic? or do elsewhere? just check the %text msgs
=+ lis=~(render tr settings path envelope) =+ lis=~(render tr settings target envelope)
?~ lis ~ ?~ lis ~
:_ ~ :_ ~
%+ effect %mor %+ effect %mor
@ -574,6 +826,25 @@
== ==
[%txt t] [%txt t]
[%mor [%txt t] [%bel ~] ~] [%mor [%txt t] [%bel ~] ~]
::
++ show-create
|= =target
^- move
(note "new: {~(cr-phat cr target)}")
::
++ show-delete
|= =target
^- move
(note "del: {~(cr-phat cr target)}")
::
++ show-glyph
|= [=glyph target=(unit target)]
^- (list move)
=- [prompt - ~]
%- note
%+ weld "set: {[glyph ~]} -> "
?~ target "nothing"
~(cr-phat cr u.target)
-- --
:: ::
:: ::
@ -605,7 +876,7 @@
:: remove ourselves from the audience. :: remove ourselves from the audience.
:: ::
^+ . ^+ .
.(aud (~(del in aud) [our.bowl /])) .(aud (~(del in aud) [our-self /inbox]))
:: ::
++ ar-maud ++ ar-maud
:: multiple audience :: multiple audience
@ -649,30 +920,6 @@
:: render sender as the most relevant circle. :: render sender as the most relevant circle.
:: ::
(~(cr-show cr (need ar-best)) ~ ar-maud) (~(cr-show cr (need ar-best)) ~ ar-maud)
::
++ ar-dire
:: returns true if circle is a mailbox of ours.
::
|= cir=target ^- ?
?& =(ship.cir our-self)
::TODO permissions check
==
::
++ ar-glyf
:: audience glyph
::
:: get the glyph that corresponds to the audience.
:: for mailbox messages and complex audiences, use
:: reserved "glyphs".
::
^- tape
=+ cha=(~(get by bound) aud)
?^ cha ~[u.cha]
?. (lien ~(tap by aud) ar-dire)
"*"
?: ?=({^ ~ ~} aud)
":"
";"
-- --
:: ::
++ cr ++ cr
@ -731,39 +978,21 @@
:: ::
:: left-pads with spaces. :: left-pads with spaces.
:: ::
|= source=path |= source=target
^- tape ::TODO get nick from contacts store?
=/ nic=(unit cord) (cr-curt |)
?: (~(has by nicks) ship.one)
(~(get by nicks) ship.one)
::TODO get their-set nick from presence
~
?~ nic (cr-curt |)
=+ raw=(scag 14 (trip u.nic))
=+ len=(sub 14 (lent raw))
(weld (reap len ' ') raw)
::
:: todo: figure out why enabling the doccord causes a nest fail, even when
:: attached to the arm instead of the product.
:: ::
++ cr-phat ::: render accurately ++ cr-phat ::: render accurately
::: prints a target fully, but still taking :: prints a target fully as ~ship/path.
::: "shortcuts" where possible: :: for local targets, print as /path.
::: ":" for local mailbox, "~ship" for foreign :: for targets on our sponsor, ^/path.
::: mailbox, "%/channel" for local target,
::: "^/channel" for parent target.
:: ::
^- tape ^- tape
?: =(our-self ship.one) %+ weld
?: =(/ path.one) ?: =(our-self ship.one) ~
":" ?: =((sein:title our.bowl now.bowl our-self) ship.one) "^"
['%' (spud path.one)] (scow %p ship.one)
=+ wun=(cite:title ship.one) (spud path.one)
?: =(path.one %inbox)
wun
?: =(ship.one (^sein:title our-self))
['/' (spud path.one)]
:(welp wun "/" (spud path.one))
:: ::
++ cr-full (cr-show ~) :: render full width ++ cr-full (cr-show ~) :: render full width
:: ::
@ -775,10 +1004,32 @@
^- tape ^- tape
:: render target (as glyph if we can). :: render target (as glyph if we can).
?~ moy ?~ moy
=+ cha=(~(get by bound) one ~ ~) =+ cha=(~(get by bound) one)
=- ?~(cha - "{u.cha ~}") =- ?~(cha - "{u.cha ~}")
~(cr-phat cr one) ~(cr-phat cr one)
(~(cr-curt cr one) u.moy) (~(cr-curt cr one) u.moy)
::
++ cr-dire
:: returns true if circle is a mailbox of ours.
::
|= cir=target ^- ?
?& =(ship.cir our-self)
::TODO permissions check
==
::
++ cr-glyph
:: target glyph
::
:: get the glyph that corresponds to the target.
:: for mailboxes and complex audiences, use
:: reserved "glyphs".
::
^- tape
=+ gyf=(~(get by bound) one)
?^ gyf ~[u.gyf]
?. (cr-dire one)
"*"
":"
-- --
:: ::
++ tr ++ tr
@ -789,7 +1040,7 @@
:: displayed in the cli. :: displayed in the cli.
:: ::
|_ $: settings=(set term) |_ $: settings=(set term)
source=path source=target
envelope envelope
== ==
:: ::
@ -859,7 +1110,7 @@
^- tang ^- tang
=. when (sub when (mod when (div when ~s0..0001))) :: round =. when (sub when (mod when (div when ~s0..0001))) :: round
=+ hed=leaf+"{(scow %uv uid)} at {(scow %da when)}" =+ hed=leaf+"{(scow %uv uid)} at {(scow %da when)}"
=/ src=tape (spud source) =/ src=tape ~(cr-phat cr source)
[%rose [" " ~ ~] [hed >author< [%rose [", " "to " ~] [leaf+src]~] ~]]~ [%rose [" " ~ ~] [hed >author< [%rose [", " "to " ~] [leaf+src]~] ~]]~
:: ::
++ tr-body ++ tr-body
@ -962,8 +1213,7 @@
=/ pef=tape =/ pef=tape
?: &(?=(^ pre) p.u.pre) q.u.pre ?: &(?=(^ pre) p.u.pre) q.u.pre
=- (weld - q:(fall pre [p=| q=" "])) =- (weld - q:(fall pre [p=| q=" "]))
%~ ar-glyf ar ~(cr-glyph cr source)
[[our.bowl source] ~ ~] ::TODO just single source path
=/ lis=(list tape) =/ lis=(list tape)
%+ simple-wrap %+ simple-wrap
`tape``(list @)`(tuba (trip text.letter)) `tape``(list @)`(tuba (trip text.letter))