Commits

Paweł Wieczorek committed 8cc76f0

ANSI_Colors and ColorScheme are moved out from main module

  • Participants
  • Parent commits aa44ba9

Comments (0)

Files changed (3)

File src/StringPainter.ml

 
 
 (*********************************************************************************************************************
- * ANSI escapes codes
+ * Imports
  ********************************************************************************************************************)
 
-module ANSI_Colors = struct
-
-    type color
-        = Black
-        | Red
-        | Green
-        | Yellow
-        | Blue
-        | Magenta
-        | Cyan
-        | White
-
-    let code_of_color = function
-        | Black ->   0
-        | Red ->     1
-        | Green ->   2
-        | Yellow ->  3
-        | Blue ->    4
-        | Magenta -> 5
-        | Cyan ->    6
-        | White ->   7
-
-    type attribute
-        = Bright
-        | Reverse
-        | Underline
-        | Blink
-        | Background of color
-        | Foreground of color
-
-    let code_of_attribute = function
-        | Bright -> 1
-        | Reverse -> 7
-        | Underline -> 4
-        | Blink     -> 5
-        | Background color -> 40 + code_of_color color
-        | Foreground color -> 30 + code_of_color color
-
-    let escape codes str =
-        let f = fun str c -> str ^ ";" ^ string_of_int (code_of_attribute c)
-        in
-
-    (List.fold_left f "\027[" codes) ^ "m" ^ str ^ "\027[0m"
-
-end
-
-module ColorScheme = struct
-    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
-        }
-
-    let dummy_color_scheme =
-        { cs_keyword        = []
-        ; cs_value          = []
-        ; cs_value_keyword  = []
-        ; cs_operator       = []
-        ; cs_syntax         = []
-        }
-
-    let default_color_scheme =
-        { cs_keyword        = [Bright; Underline]
-        ; cs_value          = [Foreground Cyan]
-        ; cs_value_keyword  = [Bright; Foreground Cyan]
-        ; cs_operator       = [Foreground Yellow]
-        ; cs_syntax         = [Bright; Foreground Black]
-        }
-
-    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
-        }
-
-    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
-        }
-end
+module ANSI_Colors = StringPainter_ANSI_Colors
+module ColorScheme = StringPainter_ColorScheme
 
 (*********************************************************************************************************************
  * The core of whole system

File src/StringPainter_ANSI_Colors.ml

+(*********************************************************************************************************************
+ * Copyrights (C) by
+ *  Pawel Wieczorek <wieczyk gmail>
+ *
+ * http://bitbucket.org/wieczyk/ocaml-stringpainter
+ ********************************************************************************************************************)
+
+
+(*********************************************************************************************************************
+ * ANSI escapes codes
+ ********************************************************************************************************************)
+
+type color
+    = Black
+    | Red
+    | Green
+    | Yellow
+    | Blue
+    | Magenta
+    | Cyan
+    | White
+
+let code_of_color = function
+    | Black ->   0
+    | Red ->     1
+    | Green ->   2
+    | Yellow ->  3
+    | Blue ->    4
+    | Magenta -> 5
+    | Cyan ->    6
+    | White ->   7
+
+type attribute
+    = Bright
+    | Reverse
+    | Underline
+    | Blink
+    | Background of color
+    | Foreground of color
+
+let code_of_attribute = function
+    | Bright -> 1
+    | Reverse -> 7
+    | Underline -> 4
+    | Blink     -> 5
+    | Background color -> 40 + code_of_color color
+    | Foreground color -> 30 + code_of_color color
+
+let escape codes str =
+    let f = fun str c -> str ^ ";" ^ string_of_int (code_of_attribute c)
+    in
+
+(List.fold_left f "\027[" codes) ^ "m" ^ str ^ "\027[0m"
+

File src/StringPainter_ColorScheme.ml

+(*********************************************************************************************************************
+ * Copyrights (C) by
+ *  Pawel Wieczorek <wieczyk gmail>
+ *
+ * http://bitbucket.org/wieczyk/ocaml-stringpainter
+ ********************************************************************************************************************)
+
+
+open StringPainter_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
+    }
+
+let dummy_color_scheme =
+    { cs_keyword        = []
+    ; cs_value          = []
+    ; cs_value_keyword  = []
+    ; cs_operator       = []
+    ; cs_syntax         = []
+    }
+
+let default_color_scheme =
+    { cs_keyword        = [Bright; Underline]
+    ; cs_value          = [Foreground Cyan]
+    ; cs_value_keyword  = [Bright; Foreground Cyan]
+    ; cs_operator       = [Foreground Yellow]
+    ; cs_syntax         = [Bright; Foreground Black]
+    }
+
+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
+    }
+
+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
+    }
+