Module Ansi_text.Style

include module type of Style
type t = Attr.t list

Models an ANSI escape sequence that can modify several attributes.

include Ppx_compare_lib.Comparable.S with type t := t
val compare : t -> t -> int
include Ppx_compare_lib.Equal.S with type t := t
val equal : t -> t -> bool
include Ppx_compare_lib.Equal.S__local with type t := t
include Ppx_quickcheck_runtime.Quickcheckable.S with type t := t
val quickcheck_generator : t Base_quickcheck.Generator.t
val quickcheck_observer : t Base_quickcheck.Observer.t
val quickcheck_shrinker : t Base_quickcheck.Shrinker.t
include Sexplib0.Sexpable.S with type t := t
include Sexplib0.Sexpable.Of_sexp with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> t
include Sexplib0.Sexpable.Sexp_of with type t := t
val sexp_of_t : t -> Sexplib0.Sexp.t
val turn_off : t -> t

Gives a style that turns off all attributes that are turned on by the given style.

val of_sgr : params:string -> t

Make a Style.t from bytes extracted from a parsed string. For example the parser, when handling:

"\027[1;38;5;1m"

would invoke:

of_sgr ~params:"1;38;5;1"

yielding:

[Bold; Fg Red]
val to_string : t -> string

Converts a Style.t to a string. For example

[Bold; Fg Standard Red] -> "\027[1;31m"
val compress : t -> t

Simplifies a Style.t by removing redundant attributes. For example Bold; Bg Blue; Reset; Fg Red; Fg Green -> Reset; Fg Green. This runs in O(n^2) time, but should be ok since Style lists are generally short.

val update : old_style:t -> added_style:t -> t

Style that results from applying added_style when old_style is already active.

val delta : old_style:t -> added_style:t -> t

A minimal style that would transition the active state from old_style to old_style + additional_style.

val to_string_hum : t -> string

Lists the attributes in a somewhat human-readable style.

val includes_reset : t -> bool

Whether any of the attributes are Reset.

val is_reset : t -> bool

Whether final attribute is Reset.

val closes : new_style:t -> old_style:t -> bool

Whether new_style overrides all attributes that old_style set.