-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStyling.mli
69 lines (55 loc) · 2 KB
/
Styling.mli
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
type t =
{ foreground : Color.t option
; background : Color.t option
; bold : bool
; dim : bool
; italic : bool
; underlined : bool
}
(** [none] is the empty styling. *)
val none : t
(** [create ?foreground ?background ?bold ?dim ?italic ?underlined ()]
creates a new style object given the provided configuration. *)
val create
: ?foreground:[< Color.t ]
-> ?background:[< Color.t ]
-> ?bold:bool
-> ?dim:bool
-> ?italic:bool
-> ?underlined:bool
-> unit
-> t
(** [fg color] is a convenient constructor for creating composable styles.
Creates a style with the specified foreground color only. See [&] for usage examples. *)
val fg : [< Color.t ] -> t
(** [fg color] is a convenient constructor for creating composable styles.
Creates a style with the specified background color only. See [&] for usage
examples. *)
val bg : [< Color.t ] -> t
(** [bold] is a convenient constructor for creating composable styles.
Creates a bold style only. See [&] for usage examples. *)
val bold : t
(** [dim] is a convenient constructor for creating composable styles.
Creates a dim style only. See [&] for usage examples. *)
val dim : t
(** [italic] is a convenient constructor for creating composable styles.
Creates an italic style only. See [&] for usage examples. *)
val italic : t
(** [underlined] is a convenient constructor for creating composable styles.
Creates an underline style only. See [&] for usage examples. *)
val underlined : t
(** [left & right] combines two styles with the following rules:
- For colors, [right] is taken if it's present, otherwise [left]
- For boolean fields, the {b or} combination of both is applied
Usage example:
{[
let my_style = Styling.(default_style & fg yellow & bg black & bold) in
]}
*)
val ( & ) : t -> t -> t
(** [to_ansi styling] renders the [styling] to an ANSI escape
sequence as a string. *)
val to_ansi : t -> string
(** [wrap ~contents styling] wraps [contents] in an ANSI escape
sequence using [styling]. *)
val wrap : contents:string -> t -> string