diff options
Diffstat (limited to '')
-rw-r--r-- | lib/todos.ml | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/todos.ml b/lib/todos.ml index f657d6c..237732f 100644 --- a/lib/todos.ml +++ b/lib/todos.ml @@ -12,6 +12,7 @@ type state = ; goto_done : (unit -> unit) -> unit ; output : string option ; tag : string + ; hide_file_name : bool } let title = I.strf ~attr:A.(st bold) "%s" "Todo" |> I.pad ~l:0 ~t:0 @@ -28,18 +29,28 @@ let init ~goto_done ~goto_headlines = ; goto_done ; output = None ; tag = "" + ; hide_file_name = false } -let load_todos () = +let load_todos ?(hide_file_name = false) () = let todo_content = Grep.get_todos () |> Grep.parse_todo_string in - let todo_pretty = Grep.pretty_format_todo todo_content in + let todo_pretty = Grep.pretty_format_todo ~hide_file_name todo_content in todo_content, todo_pretty let rec render t - ({ pos; scroll; content; content_pretty; goto_headlines; goto_done; output; _ } as state) + ({ pos + ; scroll + ; content + ; content_pretty + ; goto_headlines + ; goto_done + ; output + ; hide_file_name + ; _ + } as state) = let x, y = pos in let size_x, size_y = Common.Term.size t in @@ -90,7 +101,7 @@ let rec render | `Key (`ASCII '1', []) -> goto_headlines (fun () -> render t state) | `Key (`ASCII '3', []) -> goto_done (fun () -> render t state) | `Key (`ASCII 'g', []) -> - let content, content_pretty = load_todos () in + let content, content_pretty = load_todos ~hide_file_name () in let y = min (List.length content_pretty + content_start) y in render t @@ -145,7 +156,7 @@ let rec render ~content ~selected_file ~on_return:(fun result -> - let content, content_pretty = load_todos () in + let content, content_pretty = load_todos ~hide_file_name () in let y = min (List.length content_pretty + content_start) y in Common.Term.cursor t None; render @@ -164,10 +175,16 @@ let rec render } in Input_prompt.render t input_state + | `Key (`ASCII 'h', []) -> + let hide_file_name = not hide_file_name in + let content_pretty = + Grep.pretty_format_todo ~hide_file_name (content |> Array.to_list) |> Array.of_list + in + render t { state with hide_file_name; content_pretty } | `Key (`ASCII 'T', [ `Ctrl ]) -> let selected_file, _ = Array.get content (y - content_start) in let _ = Grep.toggle_done selected_file in - let content, content_pretty = load_todos () in + let content, content_pretty = load_todos ~hide_file_name () in let y = min (List.length content_pretty + content_start) y in render t |