aboutsummaryrefslogtreecommitdiff
path: root/lib/todos.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/todos.ml')
-rw-r--r--lib/todos.ml15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/todos.ml b/lib/todos.ml
index 4e52cd4..d2af47f 100644
--- a/lib/todos.ml
+++ b/lib/todos.ml
@@ -8,11 +8,18 @@ type state =
; scroll : int
; content : (string * string) array
; content_pretty : string array
- ; goto_headlines : state -> unit
+ ; goto_headlines : (unit -> unit) -> unit
}
-let init ~goto_headlines ~content ~content_pretty =
- { pos = 0, 0; scroll = 0; content; content_pretty; goto_headlines }
+let init ~goto_headlines =
+ let content = Grep.get_todos () |> Grep.parse_todo_string in
+ let content_pretty = Grep.pretty_format_todo content in
+ { pos = 0, 0
+ ; scroll = 0
+ ; content = content |> Array.of_list
+ ; content_pretty = content_pretty |> Array.of_list
+ ; goto_headlines
+ }
let load_todos () =
@@ -75,7 +82,7 @@ let rec render t ({ pos; scroll; content; content_pretty; goto_headlines } as st
}
in
Input_screen.render t input_state
- | `Key (`ASCII '1', []) -> goto_headlines state
+ | `Key (`ASCII '1', []) -> goto_headlines (fun () -> render t state)
| `Key (`ASCII 'j', []) | `Key (`ASCII 'N', [ `Ctrl ]) -> scroll_down ()
| `Key (`ASCII 'k', []) | `Key (`ASCII 'P', [ `Ctrl ]) -> scroll_up ()
| `Key (`ASCII 't', []) ->