aboutsummaryrefslogtreecommitdiff
path: root/lib/headlines.ml
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-20 09:07:45 -0500
committerMarc Coquand <marc@mccd.space>2024-05-20 09:07:45 -0500
commit5aec082b915416107cec9e8c811bbbedafb70b59 (patch)
treea39601d40898e332508d9708014e0415c069b01b /lib/headlines.ml
parent0bc408515cfc9c8feff686f8c758dfaf6c997bb4 (diff)
downloadstitch-5aec082b915416107cec9e8c811bbbedafb70b59.tar.gz
stitch-5aec082b915416107cec9e8c811bbbedafb70b59.tar.bz2
stitch-5aec082b915416107cec9e8c811bbbedafb70b59.zip
Enable hiding the file name using 'h'
Diffstat (limited to 'lib/headlines.ml')
-rw-r--r--lib/headlines.ml22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/headlines.ml b/lib/headlines.ml
index eaa68d9..90bad7d 100644
--- a/lib/headlines.ml
+++ b/lib/headlines.ml
@@ -14,6 +14,7 @@ type state =
; goto_done_view : (unit -> unit) -> unit
; output : string option
; tag : string
+ ; hide_file_name : bool
}
let init ~goto_done_view ~goto_todos_view ~regexp =
@@ -37,6 +38,7 @@ let init ~goto_done_view ~goto_todos_view ~regexp =
; goto_todos_view
; output = None
; tag = ""
+ ; hide_file_name = false
})
@@ -45,8 +47,16 @@ let title = I.strf ~attr:A.(st bold) "%s" "Notes" |> I.pad ~l:0 ~t:0
(* TODO: Add page title *)
let rec render
t
- ({ pos; scroll; content; content_pretty; goto_todos_view; goto_done_view; tag; output }
- as state)
+ ({ pos
+ ; scroll
+ ; content
+ ; content_pretty
+ ; goto_todos_view
+ ; goto_done_view
+ ; tag
+ ; output
+ ; hide_file_name
+ } as state)
=
let content_start = 2 in
let size_x, size_y = Common.Term.size t in
@@ -96,6 +106,10 @@ let rec render
render t { state with pos = 0, min y content_end; output = None }
| `Key (`ASCII '?', []) -> Help_screen.render t { go_back = (fun () -> render t state) }
| `Key (`ASCII '2', []) -> goto_todos_view (fun () -> render t state)
+ | `Key (`ASCII 'h', []) ->
+ let hide_file_name = not hide_file_name in
+ let content_pretty = content |> Grep.pretty_format ~hide_file_name in
+ render t { state with hide_file_name; content_pretty }
| `Key (`ASCII '3', []) -> goto_done_view (fun () -> render t state)
| `Key (`ASCII 'f', []) ->
let content =
@@ -128,7 +142,7 @@ let rec render
; on_enter =
(fun tag ->
let content = Grep.get_tagged_headlines tag () |> Grep.parse_headlines in
- let content_pretty = Grep.pretty_format content in
+ let content_pretty = Grep.pretty_format ~hide_file_name content in
Common.Term.cursor t None;
render
t
@@ -176,7 +190,7 @@ let rec render
let content =
Grep.get_tagged_headlines tag () |> Grep.parse_headlines
in
- let content_pretty = Grep.pretty_format content in
+ let content_pretty = Grep.pretty_format ~hide_file_name content in
Common.Term.cursor t None;
render
t