From 681c9e3a618a6834aa778102d8f4fd201d488244 Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Sun, 30 Jun 2024 17:23:27 -0500 Subject: Bug fixes --- lib/stitch.ml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/stitch.ml') diff --git a/lib/stitch.ml b/lib/stitch.ml index 3383c83..453b7d1 100644 --- a/lib/stitch.ml +++ b/lib/stitch.ml @@ -4,13 +4,13 @@ module Todos = Todos module Headlines = Headlines let start (tag : string) () = - (* This is a rather funky state management that isn't maybe entirely functional. + (* This is a rather funky state management. 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. - It does create a rather funky, cyclical state though. + It does create a cyclical state though. *) if String.equal String.empty (String.trim Grep.execution_directory) then @@ -19,12 +19,12 @@ let start (tag : string) () = STITCH_DIRECTORY to the absolute path of your notes. For example: \ STITCH_DIRECTORY='/home/you/notes'." else ( - print_endline "Launching"; 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 *) + (* INIT DONE VIEW *) + print_endline "DONE INIT"; let goto_todo_from_done new_done_state = restore_done_state := new_done_state; !restore_todo_state () @@ -41,7 +41,8 @@ let start (tag : string) () = ~goto_todo:goto_todo_from_done in Done.render term done_state); - (* TODO *) + (* INIT TODO VIEW *) + print_endline "TODO INIT"; let goto_done_from_todo new_todo_state = restore_todo_state := new_todo_state; !restore_done_state () @@ -58,6 +59,8 @@ let start (tag : string) () = ~goto_done:goto_done_from_todo in Todos.render term todo); + (* INIT HEADLINE VIEW *) + print_endline "HEADLINE INIT"; let headline = Headlines.init ~goto_done_view:(fun new_state -> @@ -68,4 +71,7 @@ let start (tag : string) () = !restore_todo_state ()) ~regexp:tag in - Headlines.render term headline) + print_endline "Got render without error"; + match headline with + | Ok headline -> Headlines.render term headline + | Error msg -> print_endline msg) -- cgit v1.2.3