aboutsummaryrefslogtreecommitdiff
path: root/lib/stitch.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-06-30 17:23:27 -0500
committerMarc Coquand <marc@mccd.space>2024-06-30 17:23:27 -0500
commit681c9e3a618a6834aa778102d8f4fd201d488244 (patch)
treeb0d3424ab2b1879f27d402ba1589e554da29dfab /lib/stitch.ml
parent598ce9ecef91264bd78555bd5b6fcca97a073d95 (diff)
downloadstitch-main.tar.gz
stitch-main.tar.bz2
stitch-main.zip
Bug fixesHEADmain
Diffstat (limited to 'lib/stitch.ml')
-rw-r--r--lib/stitch.ml18
1 files changed, 12 insertions, 6 deletions
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)