summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chart.ml5
-rw-r--r--src/connector.ml6
-rw-r--r--src/options.ml17
3 files changed, 23 insertions, 5 deletions
diff --git a/src/chart.ml b/src/chart.ml
index 194e3ba..39f97f9 100644
--- a/src/chart.ml
+++ b/src/chart.ml
@@ -29,9 +29,8 @@ let pp formatter { vals : int list; opts : Options.t } =
29 match Stdlib.compare s e with 29 match Stdlib.compare s e with
30 | 0 -> make_marker axis_spc s (height - s) "-" 30 | 0 -> make_marker axis_spc s (height - s) "-"
31 | x -> 31 | x ->
32 let ltr_chr, rtl_chr = 32 let dr, rd, ru, ur = Connector.of_kind opts.connector in
33 match x with 1 -> ("└", "┐") | _ -> ("┘", "┌") 33 let ltr_chr, rtl_chr = match x with 1 -> (dr, rd) | _ -> (ru, ur) in
34 in
35 let st, en = Stdlib.(min s e, max s e) in 34 let st, en = Stdlib.(min s e, max s e) in
36 let l = en - st |> saturating_sub 1 in 35 let l = en - st |> saturating_sub 1 in
37 let left, right = (repeat st space, repeat (height - l - st) space) in 36 let left, right = (repeat st space, repeat (height - l - st) space) in
diff --git a/src/connector.ml b/src/connector.ml
new file mode 100644
index 0000000..d00d036
--- /dev/null
+++ b/src/connector.ml
@@ -0,0 +1,6 @@
1type t = Squared | Rounded
2
3let of_kind (k : t) =
4 match k with
5 | Squared -> ("└", "┐", "┘", "┌")
6 | Rounded -> ("╰", "╮", "╯", "╭")
diff --git a/src/options.ml b/src/options.ml
index 341c0bb..fa49ef1 100644
--- a/src/options.ml
+++ b/src/options.ml
@@ -1,7 +1,20 @@
1type t = { height : int; ascii : bool; marker : Marker.t } 1type t = {
2 height : int;
3 ascii : bool;
4 marker : Marker.t;
5 connector : Connector.t;
6}
2 7
3let default = { height = 14; ascii = false; marker = Marker.Circle } 8let default =
9 {
10 height = 14;
11 ascii = false;
12 marker = Marker.Circle;
13 connector = Connector.Rounded;
14 }
4 15
5let with_height v c = { c with height = v } 16let with_height v c = { c with height = v }
6 17
7let with_marker v c = { c with marker = v } 18let with_marker v c = { c with marker = v }
19
20let with_connector v c = { c with connector = v }