Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework statemachine #139

Merged
merged 48 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
31a538c
Initial work on new fsm
Grazfather Sep 18, 2021
c674d13
pop/push -> butlast/conf
Grazfather Sep 19, 2021
04e620f
fsm2: Simplify schema and add subscribe functionality
Grazfather Sep 19, 2021
278d760
Add and tweak Jay's effect-handler
Grazfather Sep 19, 2021
8d78658
Keep handlers from touching atoms
Grazfather Sep 19, 2021
71975ba
Cleanup a bit
Grazfather Sep 25, 2021
942d773
create-machine takes initial state in states arg
Grazfather Sep 25, 2021
714a51f
Combine context and state into single atom
Grazfather Sep 25, 2021
9a4da43
cleanup
Grazfather Sep 25, 2021
67299d6
log error if current state has no handler for action
Grazfather Sep 25, 2021
2b96c82
Add methods to fsm
Grazfather Sep 25, 2021
820d818
Let caller provider a logger tag
Grazfather Sep 25, 2021
25cf8bb
Make signal return boolean success
Grazfather Sep 26, 2021
907fc0c
Fix unsub function
Grazfather Sep 26, 2021
278c626
Export effect-handler
Grazfather Sep 26, 2021
284eb43
Add tests
Grazfather Sep 26, 2021
775bb8d
Cleanup tests slightly
Grazfather Sep 26, 2021
ff9b5ec
Add new-modal using new-statemachine
Grazfather Sep 26, 2021
78e79fb
Remove example and add big doc string
Grazfather Sep 26, 2021
1cc0852
Rename timeout transition function
Grazfather Sep 26, 2021
b167f03
Remove more duplicated code for review
Grazfather Sep 26, 2021
8bca53c
Duplicate funcs from statemachine into new
Grazfather Oct 1, 2021
fe2840a
Fix timeout current-state
Grazfather Oct 6, 2021
ac4199e
Remove some todos
Grazfather Oct 6, 2021
a1c0180
remove todo
Grazfather Oct 6, 2021
f3be7ec
Cleanup docstrings
Grazfather Oct 6, 2021
e397806
wip new apps
Grazfather Oct 6, 2021
6eed996
apps: Fix getting current app to display app-menu
Grazfather Oct 8, 2021
31bf99e
apps: Update app even when new app isn't in config
Grazfather Oct 8, 2021
3ec63bb
Log debug not warn
Grazfather Oct 8, 2021
a385ae7
Get app switching in modal working
Grazfather Oct 8, 2021
8b6c388
Cleanup some logging
Grazfather Oct 8, 2021
35873d6
Remove old modal, apps, mostly remove old statemachine
Grazfather Oct 10, 2021
f2e18f8
Fix monkey patch
Grazfather Oct 10, 2021
b4a427e
Remove extra logging from apps and modal
Grazfather Oct 10, 2021
758ac82
wip: Port vim to new statemachine
Grazfather Oct 10, 2021
f7354fb
minor cleanup
Grazfather Oct 10, 2021
7628b47
cleanup in modal
Grazfather Oct 10, 2021
32c6b15
apps: Update app even when new app isn't in config
Grazfather Oct 8, 2021
8b86f26
apps: close & leave effects have to operate on prev app
Grazfather Oct 10, 2021
0883a7f
fix bug in watch-screen
Grazfather Oct 10, 2021
89018c8
statemachine: Rename 'signal' to 'send'
Grazfather Oct 12, 2021
65c0f4e
Remove all debug prints
Grazfather Oct 12, 2021
fe69427
Remove comment
Grazfather Oct 12, 2021
2b8e11b
Better heading
Grazfather Oct 15, 2021
4f2470c
Better function names
Grazfather Oct 15, 2021
9784eed
s/signal/send in statemachine test
Grazfather Oct 15, 2021
53a4cbc
statemachine test: assert in sub func
Grazfather Oct 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Returns nil. This function causes side-effects.
:apps
:lib.bind
:lib.modal
:lib.new-modal
:lib.apps])

(defadvice get-config-impl
Expand Down
14 changes: 13 additions & 1 deletion lib/functional.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@
(let [filtered (filter f tbl)]
(<= 1 (length filtered))))

(fn conj
[tbl e]
"Return a new list with the element e added at the end"
(concat tbl [e]))

(fn butlast
[tbl]
"Return a new list with all but the last item"
(slice 1 -1 tbl))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Others
Expand All @@ -226,9 +236,11 @@
;; Exports
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

{: call-when
{: butlast
: call-when
: compose
: concat
: conj
: contains?
: count
: eq?
Expand Down
15 changes: 12 additions & 3 deletions lib/modal.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ switching menus in one place which is then powered by config.fnl.
(local atom (require :lib.atom))
(local statemachine (require :lib.statemachine))
(local apps (require :lib.apps))
(local {: call-when
(local {: butlast
: call-when
: concat
: conj
: find
: filter
: has-some?
Expand Down Expand Up @@ -272,7 +274,7 @@ switching menus in one place which is then powered by config.fnl.
:stop-timeout :nil
:unbind-keys (bind-menu-keys menu.items)
:history (if history
(concat [] history [menu])
(conj history menu)
[menu])})


Expand Down Expand Up @@ -438,7 +440,7 @@ switching menus in one place which is then powered by config.fnl.
(show-modal-menu (merge state
{:menu prev-menu
:prev-menu menu}))
{:history (slice 1 -1 history)})
{:history (butlast history)})
(idle->active state))))


Expand Down Expand Up @@ -536,4 +538,11 @@ switching menus in one place which is then powered by config.fnl.


{:init init
: modal-alert ;; DELETEME: Temporary for PR
: timeout ;; DELETEME: Temporary for PR
: by-key ;; DELETEME: Temporary for PR
: activate-modal ;; DELETEME: Temporary for PR
: deactivate-modal ;; DELETEME: Temporary for PR
: previous-modal ;; DELETEME: Temporary for PR
: proxy-app-action ;; DELETEME: Temporary for PR
:activate-modal activate-modal}
Loading