diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-15 14:05:03 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-15 14:05:03 -0500 |
commit | 3f696169ab1a560d94d169c1a5b744346da4c081 (patch) | |
tree | d2aa5d6b0b9d70a594ede7795e423250a92729e1 /lib/stitch.ml | |
parent | 961339f0bd28c0f30bdb3c995a27927def8a991e (diff) | |
download | stitch-3f696169ab1a560d94d169c1a5b744346da4c081.tar.gz stitch-3f696169ab1a560d94d169c1a5b744346da4c081.tar.bz2 stitch-3f696169ab1a560d94d169c1a5b744346da4c081.zip |
Add done view + visual
Diffstat (limited to 'lib/stitch.ml')
-rw-r--r-- | lib/stitch.ml | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/lib/stitch.ml b/lib/stitch.ml index e49ed9c..2fc0a9c 100644 --- a/lib/stitch.ml +++ b/lib/stitch.ml @@ -5,7 +5,8 @@ module Headlines = Headlines let start (tag : string) () = (* This is a rather funky state management that isn't maybe entirely functional. - What we do is store a function for each view that restores it's state. + What we do is store a function for each view that restores it's state. Since the render function is + void -> void This allows us to remember the state of the view and restore it as we travel between different views. @@ -13,17 +14,47 @@ let start (tag : string) () = *) let term = Common.Term.create () in let restore_headline_state = ref (fun () -> ()) in + let restore_done_state = ref (fun () -> ()) in let restore_todo_state = ref (fun () -> ()) in + (* DONE *) + let goto_todo_from_done new_done_state = + restore_done_state := new_done_state; + !restore_todo_state () + in + let goto_headlines_from_done new_done_state = + restore_done_state := new_done_state; + !restore_headline_state () + in + (restore_done_state + := fun () -> + let done_state = + Done.init + ~goto_headlines:goto_headlines_from_done + ~goto_todo:goto_todo_from_done + in + Done.render term done_state); + (* TODO *) + let goto_done_from_todo new_todo_state = + restore_todo_state := new_todo_state; + !restore_done_state () + in let goto_headline_from_todo new_todo_state = restore_todo_state := new_todo_state; !restore_headline_state () in (restore_todo_state := fun () -> - let todo = Todos.init ~goto_headlines:goto_headline_from_todo in + let todo = + Todos.init + ~goto_headlines:goto_headline_from_todo + ~goto_done:goto_done_from_todo + in Todos.render term todo); let headline = Headlines.init + ~goto_done_view:(fun new_state -> + restore_headline_state := new_state; + !restore_done_state ()) ~goto_todos_view:(fun new_state -> restore_headline_state := new_state; !restore_todo_state ()) |