Source

ocaml-stringpainter / src / ColorScheme.ml

(*********************************************************************************************************************
 * Copyrights (C) by
 *  Pawel Wieczorek <wieczyk gmail>
 *
 * http://bitbucket.org/wieczyk/ocaml-stringpainter
 ********************************************************************************************************************)


open ANSI_Colors

type color_scheme =
    { cs_keyword        : attribute list
    ; cs_value          : attribute list
    ; cs_value_keyword  : attribute list
    ; cs_operator       : attribute list
    ; cs_syntax         : attribute list
    ; cs_label          : attribute list
    ; cs_special        : attribute list
    }

let dummy_color_scheme =
    { cs_keyword        = []
    ; cs_value          = []
    ; cs_value_keyword  = []
    ; cs_operator       = []
    ; cs_syntax         = []
    ; cs_label          = []
    ; cs_special        = []
    }

let default_color_scheme =
    { cs_keyword        = [Bright; Underline; Foreground Blue]
    ; cs_value          = [Foreground Cyan]
    ; cs_value_keyword  = [Bright; Foreground Cyan]
    ; cs_operator       = [Foreground Yellow]
    ; cs_syntax         = [Bright; Foreground Black]
    ; cs_label          = [Foreground Green]
    ; cs_special        = [Foreground Magenta]
    }

(* TODO: remove, escape function should be used directly *)
type color_scheme_functionalized =
    { fcs_keyword       : string -> string
    ; fcs_value         : string -> string
    ; fcs_value_keyword : string -> string
    ; fcs_operator      : string -> string
    ; fcs_syntax        : string -> string
    ; fcs_label         : string -> string
    ; fcs_special       : string -> string
    }

let functionalize cs = 
    { fcs_keyword       = escape cs.cs_keyword
    ; fcs_value         = escape cs.cs_value
    ; fcs_value_keyword = escape cs.cs_value_keyword
    ; fcs_operator      = escape cs.cs_operator
    ; fcs_syntax        = escape cs.cs_syntax
    ; fcs_label         = escape cs.cs_label
    ; fcs_special       = escape cs.cs_special
    }