mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
Basic dialog workings.
This commit is contained in:
parent
7b56bcfe06
commit
25bbc1c67f
@ -2855,6 +2855,12 @@
|
||||
:: section 2eI, parsing (external) ::
|
||||
::
|
||||
++ rash |*([naf=@ sab=_rule] (scan (trip naf) sab)) ::
|
||||
++ ruse |* [los=tape sab=_rule]
|
||||
=+ vex=(sab [[0 0] los])
|
||||
?. =((lent los) q.p.vex) ~
|
||||
?~ q.vex
|
||||
[~ u=~]
|
||||
[~ u=[~ u=p.u.q.vex]]
|
||||
++ rush |*([naf=@ sab=_rule] (rust (trip naf) sab))
|
||||
++ rust |* [los=tape sab=_rule]
|
||||
=+ vex=((full sab) [[1 1] los])
|
||||
|
@ -14,10 +14,12 @@
|
||||
== ::
|
||||
++ helm-session ::
|
||||
$: say=console-share ::
|
||||
mud=(unit (console-dialog ,@ud)) ::
|
||||
== ::
|
||||
++ helm-wish ::
|
||||
$| $? %solid :: save kernel pill
|
||||
%reset :: reset kernel
|
||||
%test :: fun test
|
||||
%verb :: verbose mode
|
||||
== ::
|
||||
$% [%reload p=(list term)] :: reload vanes
|
||||
@ -50,6 +52,7 @@
|
||||
++ parse-helm-wish
|
||||
%+ cook |=(a=helm-wish a)
|
||||
;~ pose
|
||||
(cold %test (jest %test))
|
||||
(cold %solid (jest %solid))
|
||||
(cold %reset (jest %reset))
|
||||
==
|
||||
@ -69,6 +72,23 @@
|
||||
|= git=gift
|
||||
%_(+> moz [[ost %give git] moz])
|
||||
::
|
||||
++ he-test
|
||||
^- (console-dialog ,@)
|
||||
|= fin=(unit console-input)
|
||||
?^ fin !!
|
||||
:- ~ :- ~
|
||||
:- [%leaf "a number..."]~
|
||||
:- %|
|
||||
:- `console-prompt`[& %$ (tuba "number one> ")]
|
||||
he-test-two
|
||||
::
|
||||
++ he-test-two
|
||||
|= fin=(unit console-input)
|
||||
=+ uno=?~(fin ~ (ruse u.fin dem:ag))
|
||||
?~ uno ~
|
||||
?~ u.uno [~ ~]
|
||||
[~ ~ ~ %& ~ u.u.uno]
|
||||
::
|
||||
++ he-peer :: subscribe to
|
||||
(he-rush [%pro %& %$ (tuba ":helm! ")]~)
|
||||
::
|
||||
@ -150,13 +170,31 @@
|
||||
[ost %pass /verb %d %verb ~]
|
||||
==
|
||||
::
|
||||
++ he-proceed
|
||||
|= res=(unit (unit ,@))
|
||||
^+ +>
|
||||
?~ res
|
||||
~& %abort
|
||||
+>.$(mud ~)
|
||||
?~ u.res
|
||||
+>.$
|
||||
~& [%result u.u.res]
|
||||
+>.$(mud ~)
|
||||
::
|
||||
++ he-wish-test
|
||||
|- ^+ +
|
||||
=+ cow=he-test
|
||||
=^ nib say ((~(apse cs say) cow) ~)
|
||||
=^ don cow nib
|
||||
(he-proceed:(he-rush(mud `cow) p.don) q.don)
|
||||
::
|
||||
++ he-wish
|
||||
|= wus=(unit helm-wish)
|
||||
^+ +>
|
||||
?~ wus
|
||||
~&(%he-wish-aborted +>)
|
||||
?~ wus +>
|
||||
?- u.wus
|
||||
%verb he-wish-verb
|
||||
%test he-wish-test
|
||||
%solid he-wish-solid
|
||||
%reset he-wish-reset
|
||||
[%reload *] !! :: (he-wish-reload +.u.wus)
|
||||
@ -166,8 +204,12 @@
|
||||
++ he-work :: apply input
|
||||
|= act=console-action
|
||||
^+ +>
|
||||
=^ wig say ((~(apex cs say) parse-helm-wish) act)
|
||||
(he-wish:(he-rush p.wig) q.wig)
|
||||
?~ mud
|
||||
=^ wig say ((~(apex cs say) parse-helm-wish) act)
|
||||
(he-wish:(he-rush p.wig) q.wig)
|
||||
=^ nib say ((~(apse cs say) u.mud) `act)
|
||||
=^ don u.mud nib
|
||||
(he-proceed:(he-rush p.don) q.don)
|
||||
--
|
||||
::
|
||||
++ peer
|
||||
|
@ -22,7 +22,7 @@
|
||||
%g %mess
|
||||
[our.hid /seat] our.hid
|
||||
%dill-belt
|
||||
!>(`dill-belt`[%yow %dojo])
|
||||
!>(`dill-belt`[%yow %helm])
|
||||
==
|
||||
==
|
||||
--
|
||||
|
@ -18,19 +18,19 @@
|
||||
^+ [[p=*(list console-effect) q=(rust ~ sef)] *console-share]
|
||||
?- -.act
|
||||
%det
|
||||
=^ dut +>+>+<.$
|
||||
=^ dut +<.apex
|
||||
%+ remit +.act
|
||||
|= buf=(list ,@c)
|
||||
=+ txt=(tufa buf)
|
||||
=((lent txt) q.p:(sef [0 0] txt))
|
||||
[[?~(dut ~ [[%det u.dut] ~]) ~] +>+>+<.$]
|
||||
[[?~(dut ~ [[%det u.dut] [%bel ~] ~]) ~] +<.apex]
|
||||
::
|
||||
%ret
|
||||
=+ dod=(rust (tufa buf) sef)
|
||||
?~ dod
|
||||
[[[%bel ~]~ ~] +>+>+<.$]
|
||||
=^ cal +>+>+<.$ (transmit [%set ~])
|
||||
:_ +>+>+<.$
|
||||
[[[%bel ~]~ ~] +<.apex]
|
||||
=^ cal +<.apex (transmit [%set ~])
|
||||
:_ +<.apex
|
||||
:_ dod
|
||||
:~ [%det cal]
|
||||
[%nex ~]
|
||||
@ -38,35 +38,52 @@
|
||||
==
|
||||
++ apse :: dialog engine
|
||||
|* dog=(console-dialog)
|
||||
|% ++ abet `console-share`+>+>- :: resolve
|
||||
++ dole ::
|
||||
=+ fov=^+(init:dog [[~ ~] [%& ~]])
|
||||
|-
|
||||
=+ fex=[%tan p.fov]
|
||||
?- -.q.fov
|
||||
%& [[p=fex q=[~ u=p.q.fov]] +>.$]
|
||||
%| :- [p=[i=[%pro `console-prompt`p.p.q.fov] t=fex] q=~]
|
||||
+>.$(dog q.p.q.fov)
|
||||
==
|
||||
::
|
||||
++ init (dole init:dog) :: initialize
|
||||
++ work
|
||||
|= act=console-action
|
||||
^+ init
|
||||
?- -.act
|
||||
%det
|
||||
=^ dut +<.apse
|
||||
%+ remit +.act
|
||||
|= buf=(list ,@c)
|
||||
!=(~ (nice:dog (tufa buf)))
|
||||
[[?~(dut ~ [[%det u.dut] ~]) ~] +>+>+<.$]
|
||||
::
|
||||
%ret
|
||||
=+ txt=(tufa buf)
|
||||
?. =(`& (nice:dog txt))
|
||||
[[[%bel ~]~ ~] +>+>+<.$]
|
||||
(dole (kick:dog txt))
|
||||
==
|
||||
|= act=(unit console-action)
|
||||
=< abet |%
|
||||
++ abet
|
||||
?~ act (ajar ~)
|
||||
?- -.u.act
|
||||
%det
|
||||
=^ dut +<.apse
|
||||
%+ remit +.u.act
|
||||
|= buf=(list ,@c)
|
||||
!=(~ (dog `(tufa buf)))
|
||||
:_ +<.apse
|
||||
:_ dog
|
||||
:_ q=[~ u=~]
|
||||
^= p ^- (list console-effect)
|
||||
?~(dut ~ [[%det u.dut] [%bel ~] ~])
|
||||
::
|
||||
%ret (ajar `(tufa buf))
|
||||
==
|
||||
++ ajar
|
||||
|= unp=(unit console-input)
|
||||
=+ god=(dog unp)
|
||||
?: |(?=(~ god) ?=(~ u.god))
|
||||
:_ +<.apse
|
||||
:_ dog
|
||||
:- p=`(list console-effect)`[%bel ~]~
|
||||
q=[~ u=~]
|
||||
=+ fex=`(list console-effect)`[%tan p.u.u.god]~
|
||||
?- -.q.u.u.god
|
||||
%&
|
||||
:_ +<.apse
|
||||
:_ dog
|
||||
:- p=fex
|
||||
q=?~(p.q.u.u.god ~ [~ u=p.q.u.u.god])
|
||||
::
|
||||
%|
|
||||
=^ cal +<.apse (transmit [%set ~])
|
||||
:_ +<.apse
|
||||
:_ q.p.q.u.u.god
|
||||
:_ q=[~ u=~]
|
||||
^= p ^+ fex
|
||||
:* [%det cal]
|
||||
[%nex ~]
|
||||
[%pro p.p.q.u.u.god]
|
||||
fex
|
||||
==
|
||||
==
|
||||
--
|
||||
::
|
||||
++ apply
|
||||
|
@ -14,15 +14,16 @@
|
||||
ted=console-edit :: state change
|
||||
== ::
|
||||
++ console-dialog :: standard dialog
|
||||
|* out=$+(* *) :: output type
|
||||
$_ ^? |% ::
|
||||
++ init =< $ :: initial response
|
||||
%+ pair (list tank) ::
|
||||
%+ each (unit out) ::
|
||||
(pair console-prompt ,_.) ::
|
||||
++ kick |=(console-input init) :: next response
|
||||
++ nice $+(console-input (unit ,?)) :: legal/partial
|
||||
-- ::
|
||||
|* out=$+(* *) :: final output
|
||||
$_ ^? ::
|
||||
|= (unit console-input) :: ~ is init
|
||||
=< $ ::
|
||||
%- unit :: ~ is invalid
|
||||
%- unit :: ~ is prefix
|
||||
%+ pair (list tank) ::
|
||||
%+ each (unit out) :: ~ is abort
|
||||
(pair console-prompt (console-dialog out)) :: ask and continue
|
||||
::
|
||||
++ console-clock ,[own=@ud his=@ud] :: vector clock
|
||||
++ console-edit :: shared state change
|
||||
$% [%del p=@ud] :: delete one at
|
||||
|
Loading…
Reference in New Issue
Block a user