aboutsummaryrefslogtreecommitdiff
path: root/lib/done.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/done.ml')
-rw-r--r--lib/done.ml29
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/done.ml b/lib/done.ml
index a8b4750..f7e1a0b 100644
--- a/lib/done.ml
+++ b/lib/done.ml
@@ -12,6 +12,7 @@ type state =
; goto_todo : (unit -> unit) -> unit
; tag : string
; output : string option
+ ; hide_file_name : bool
}
let title = I.strf ~attr:A.(st bold) "%s" "Done" |> I.pad ~l:0 ~t:0
@@ -28,18 +29,28 @@ let init ~goto_todo ~goto_headlines =
; goto_todo
; tag = ""
; output = None
+ ; hide_file_name = false
}
-let load_done () =
+let load_done ?(hide_file_name = false) () =
let done_content = Grep.get_done () |> Grep.parse_todo_string in
- let done_pretty = Grep.pretty_format_todo done_content in
+ let done_pretty = Grep.pretty_format_todo ~hide_file_name done_content in
done_content, done_pretty
let rec render
t
- ({ pos; scroll; content; content_pretty; goto_headlines; goto_todo; output; _ } as state)
+ ({ pos
+ ; scroll
+ ; content
+ ; content_pretty
+ ; goto_headlines
+ ; goto_todo
+ ; output
+ ; hide_file_name
+ ; _
+ } as state)
=
let x, y = pos in
let size_x, size_y = Common.Term.size t in
@@ -112,8 +123,14 @@ let rec render
Input_prompt.render t input_state
| `Key (`ASCII '1', []) -> goto_headlines (fun () -> render t state)
| `Key (`ASCII '2', []) -> goto_todo (fun () -> render t 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 'g', []) ->
- let content, content_pretty = load_done () in
+ let content, content_pretty = load_done ~hide_file_name () in
let y = min (List.length content_pretty + content_start) y in
render
t
@@ -142,7 +159,7 @@ let rec render
~content
~selected_file
~on_return:(fun result ->
- let content, content_pretty = load_done () in
+ let content, content_pretty = load_done ~hide_file_name () in
let y = min (List.length content_pretty + content_start) y in
Common.Term.cursor t None;
render
@@ -166,7 +183,7 @@ let rec render
| `Key (`ASCII 'T', [ `Ctrl ]) ->
let selected_file, _ = Array.get content (y - content_start) in
let _ = Grep.toggle_todo selected_file in
- let content, content_pretty = load_done () in
+ let content, content_pretty = load_done ~hide_file_name () in
let y = min (List.length content_pretty + content_start) y in
render
t