package miaou-core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file border.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
(******************************************************************************)
(*                                                                            *)
(* SPDX-License-Identifier: MIT                                               *)
(* Copyright (c) 2026 Nomadic Labs <contact@nomadic-labs.com>                 *)
(*                                                                            *)
(******************************************************************************)

type style = None_ | Single | Double | Rounded | Ascii | Heavy

let style_to_yojson = function
  | None_ -> `String "None"
  | Single -> `String "Single"
  | Double -> `String "Double"
  | Rounded -> `String "Rounded"
  | Ascii -> `String "Ascii"
  | Heavy -> `String "Heavy"

let style_of_yojson = function
  | `String s -> (
      match String.lowercase_ascii s with
      | "none" | "none_" -> Ok None_
      | "single" -> Ok Single
      | "double" -> Ok Double
      | "rounded" -> Ok Rounded
      | "ascii" -> Ok Ascii
      | "heavy" -> Ok Heavy
      | _ -> Error "Border.style")
  | `List [`String "None"] -> Ok None_
  | `List [`String "Single"] -> Ok Single
  | `List [`String "Double"] -> Ok Double
  | `List [`String "Rounded"] -> Ok Rounded
  | `List [`String "Ascii"] -> Ok Ascii
  | `List [`String "Heavy"] -> Ok Heavy
  | `Assoc [("None", _)] -> Ok None_
  | `Assoc [("Single", _)] -> Ok Single
  | `Assoc [("Double", _)] -> Ok Double
  | `Assoc [("Rounded", _)] -> Ok Rounded
  | `Assoc [("Ascii", _)] -> Ok Ascii
  | `Assoc [("Heavy", _)] -> Ok Heavy
  | _ -> Error "Border.style"

type chars = {
  tl : string;
  tr : string;
  bl : string;
  br : string;
  h : string;
  v : string;
  t_down : string;
  t_up : string;
  t_right : string;
  t_left : string;
  cross : string;
}

let single_chars =
  {
    tl = "┌";
    tr = "┐";
    bl = "└";
    br = "┘";
    h = "─";
    v = "│";
    t_down = "┬";
    t_up = "┴";
    t_right = "├";
    t_left = "┤";
    cross = "┼";
  }

let double_chars =
  {
    tl = "╔";
    tr = "╗";
    bl = "╚";
    br = "╝";
    h = "═";
    v = "║";
    t_down = "╦";
    t_up = "╩";
    t_right = "╠";
    t_left = "╣";
    cross = "╬";
  }

let rounded_chars =
  {
    tl = "╭";
    tr = "╮";
    bl = "╰";
    br = "╯";
    h = "─";
    v = "│";
    t_down = "┬";
    t_up = "┴";
    t_right = "├";
    t_left = "┤";
    cross = "┼";
  }

let ascii_chars =
  {
    tl = "+";
    tr = "+";
    bl = "+";
    br = "+";
    h = "-";
    v = "|";
    t_down = "+";
    t_up = "+";
    t_right = "+";
    t_left = "+";
    cross = "+";
  }

let heavy_chars =
  {
    tl = "┏";
    tr = "┓";
    bl = "┗";
    br = "┛";
    h = "━";
    v = "┃";
    t_down = "┳";
    t_up = "┻";
    t_right = "┣";
    t_left = "┫";
    cross = "╋";
  }

let none_chars =
  {
    tl = " ";
    tr = " ";
    bl = " ";
    br = " ";
    h = " ";
    v = " ";
    t_down = " ";
    t_up = " ";
    t_right = " ";
    t_left = " ";
    cross = " ";
  }

let chars_of_style = function
  | None_ -> none_chars
  | Single -> single_chars
  | Double -> double_chars
  | Rounded -> rounded_chars
  | Ascii -> ascii_chars
  | Heavy -> heavy_chars

let default_style = Single