aboutsummaryrefslogtreecommitdiff
path: root/lib/stitched_article.ml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/stitched_article.ml15
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 *)