diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-20 09:07:45 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-20 09:07:45 -0500 |
commit | 5aec082b915416107cec9e8c811bbbedafb70b59 (patch) | |
tree | a39601d40898e332508d9708014e0415c069b01b /lib/done.ml | |
parent | 0bc408515cfc9c8feff686f8c758dfaf6c997bb4 (diff) | |
download | stitch-5aec082b915416107cec9e8c811bbbedafb70b59.tar.gz stitch-5aec082b915416107cec9e8c811bbbedafb70b59.tar.bz2 stitch-5aec082b915416107cec9e8c811bbbedafb70b59.zip |
Enable hiding the file name using 'h'
Diffstat (limited to 'lib/done.ml')
-rw-r--r-- | lib/done.ml | 29 |
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 |