package ansifmt

  1. Overview
  2. Docs

Module Ansifmt.StylingSource

Sourcetype t = {
  1. foreground : Color.t option;
  2. background : Color.t option;
  3. bold : bool;
  4. dim : bool;
  5. italic : bool;
  6. underlined : bool;
}
Sourceval none : t

none is the empty styling.

Sourceval create : ?foreground:[< Color.t ] -> ?background:[< Color.t ] -> ?bold:bool -> ?dim:bool -> ?italic:bool -> ?underlined:bool -> unit -> t

create ?foreground ?background ?bold ?dim ?italic ?underlined () creates a new style object given the provided configuration.

Sourceval fg : [< Color.t ] -> t

fg color is a convenient constructor for creating composable styles. Creates a style with the specified foreground color only. See & for usage examples.

Sourceval bg : [< 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.

Sourceval bold : t

bold is a convenient constructor for creating composable styles. Creates a bold style only. See & for usage examples.

Sourceval dim : t

dim is a convenient constructor for creating composable styles. Creates a dim style only. See & for usage examples.

Sourceval italic : t

italic is a convenient constructor for creating composable styles. Creates an italic style only. See & for usage examples.

Sourceval underlined : t

underlined is a convenient constructor for creating composable styles. Creates an underline style only. See & for usage examples.

Sourceval (&) : t -> t -> 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 or combination of both is applied

Usage example:

  let my_style = Styling.(default_style & fg yellow & bg black & bold) in
Sourceval to_ansi : t -> string

to_ansi styling renders the styling to an ANSI escape sequence as a string.

Sourceval wrap : contents:string -> t -> string

wrap ~contents styling wraps contents in an ANSI escape sequence using styling.

OCaml

Innovation. Community. Security.