diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-15 14:05:03 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-15 14:05:03 -0500 |
commit | 3f696169ab1a560d94d169c1a5b744346da4c081 (patch) | |
tree | d2aa5d6b0b9d70a594ede7795e423250a92729e1 /lib/stitched_article.ml | |
parent | 961339f0bd28c0f30bdb3c995a27927def8a991e (diff) | |
download | stitch-3f696169ab1a560d94d169c1a5b744346da4c081.tar.gz stitch-3f696169ab1a560d94d169c1a5b744346da4c081.tar.bz2 stitch-3f696169ab1a560d94d169c1a5b744346da4c081.zip |
Add done view + visual
Diffstat (limited to 'lib/stitched_article.ml')
-rw-r--r-- | lib/stitched_article.ml | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/stitched_article.ml b/lib/stitched_article.ml index 66a108e..56250c8 100644 --- a/lib/stitched_article.ml +++ b/lib/stitched_article.ml @@ -13,6 +13,9 @@ type state = ; goto_todos_view : (unit -> unit) -> unit } +let title = I.strf ~attr:A.(st bold) "%s" "Note View" |> I.pad ~l:0 ~t:0 +let content_start = 1 + (* TODO: Use grep -l to filter notes by regexp and rerender those files*) let rec render t @@ -23,18 +26,18 @@ let rec render let img = let elements = Array.mapi - (fun i el -> Compontent.current_line size_x y scroll el i) + (fun i el -> Compontent.current_line size_x y scroll el (i + content_start)) (* TODO: Fix this ugly slow conversion *) (Array.to_seq content_pretty |> Seq.drop scroll |> Array.of_seq) in let open I in - Array.fold_left (fun sum el -> el </> sum) I.empty elements + Array.fold_left (fun sum el -> el </> sum) title elements in Common.Term.image t img; let content_length = Array.length content_pretty in let scroll_up () = - let scroll = if y - scroll = 0 then max (scroll - 1) 0 else scroll in - render t @@ { state with pos = x, max (y - 1) 0; scroll } + let scroll = if y - content_start - scroll = 0 then max (scroll - 1) 0 else scroll in + render t @@ { state with pos = x, max (y - 1) content_start; scroll } in let scroll_down () = let scroll = if y - scroll >= size_y - 1 then scroll + 1 else scroll in @@ -59,7 +62,9 @@ let rec render let[@warning "-8"] (editor :: args) = String.split_on_char ' ' (Sys.getenv "EDITOR") in - let selected_file, line_number, _, file_number_offset = Array.get content y in + let selected_file, line_number, _, file_number_offset = + Array.get content (y - content_start) + in let full_path_file = Grep.execution_directory ^ "/" ^ selected_file in (* Because each file title consists of two lines, we need to account for the offset it adds by removing the file_number *) |