aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2024-05-20 09:23:23 -0500
committerMarc Coquand <marc@mccd.space>2024-05-20 09:23:23 -0500
commit964d6773395b7008661b38c11acd24959f280fb1 (patch)
treed4f58518302d406e571a3eb976efbc25b560a8d7 /lib
parent5aec082b915416107cec9e8c811bbbedafb70b59 (diff)
downloadstitch-964d6773395b7008661b38c11acd24959f280fb1.tar.gz
stitch-964d6773395b7008661b38c11acd24959f280fb1.tar.bz2
stitch-964d6773395b7008661b38c11acd24959f280fb1.zip
Replace ugly conversion
Diffstat (limited to '')
-rw-r--r--lib/basic.ml3
-rw-r--r--lib/done.ml2
-rw-r--r--lib/headlines.ml3
-rw-r--r--lib/todos.ml2
4 files changed, 6 insertions, 4 deletions
diff --git a/lib/basic.ml b/lib/basic.ml
new file mode 100644
index 0000000..76b6863
--- /dev/null
+++ b/lib/basic.ml
@@ -0,0 +1,3 @@
+let array_drop n arr =
+ if Array.length arr < n then [||] else Array.sub arr n (max (Array.length arr - n) 0)
+
diff --git a/lib/done.ml b/lib/done.ml
index f7e1a0b..cda47e4 100644
--- a/lib/done.ml
+++ b/lib/done.ml
@@ -72,7 +72,7 @@ let rec render
if i == y - scroll
then I.strf "%s" el |> I.pad ~l:2 ~t:(i + content_start)
else I.strf "%s" el |> I.pad ~l:2 ~t:(i + content_start))
- (Array.to_seq content_pretty |> Seq.drop scroll |> Array.of_seq)
+ (content_pretty |> Basic.array_drop scroll)
in
let open I in
Array.fold_left (fun sum el -> el </> sum) (title </> dot </> output_info) elements
diff --git a/lib/headlines.ml b/lib/headlines.ml
index 90bad7d..38ff42d 100644
--- a/lib/headlines.ml
+++ b/lib/headlines.ml
@@ -44,7 +44,6 @@ let init ~goto_done_view ~goto_todos_view ~regexp =
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
@@ -80,7 +79,7 @@ let rec render
if i + 1 == y - scroll (* TODO: Should be reverse *)
then I.strf "%s" el |> I.pad ~l:2 ~t:(i + content_start)
else I.strf "%s" el |> I.pad ~l:2 ~t:(i + content_start))
- (Array.to_seq content_pretty |> Seq.drop scroll |> Array.of_seq)
+ (Basic.array_drop scroll content_pretty)
in
let open I in
Array.fold_left (fun sum el -> sum </> el) (title </> dot </> output_info) elements
diff --git a/lib/todos.ml b/lib/todos.ml
index 237732f..0cdbc79 100644
--- a/lib/todos.ml
+++ b/lib/todos.ml
@@ -73,7 +73,7 @@ let rec render
if i == y - scroll
then I.strf "%s" el |> I.pad ~l:2 ~t:(i + content_start)
else I.strf "%s" el |> I.pad ~l:2 ~t:(i + content_start))
- (Array.to_seq content_pretty |> Seq.drop scroll |> Array.of_seq)
+ (content_pretty |> Basic.array_drop scroll)
in
let open I in
Array.fold_left (fun sum el -> el </> sum) (title </> dot </> output_info) elements