aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2015-05-14 12:49:41 +0200
committerPierre-Marie Pédrot2015-05-14 13:02:17 +0200
commit5f8dc36fb2d65699233b9ac9a3ff9f93701a01cb (patch)
tree57855137873a81f1b026b8be73560c71a9915acb
parent81eb133d64ac81cbf6962d624b20c1aa55c2baae (diff)
The -list-tag options now prints the corresponding COQ_COLORS value.
-rw-r--r--lib/terminal.ml7
-rw-r--r--lib/terminal.mli3
-rw-r--r--toplevel/coqtop.ml11
3 files changed, 18 insertions, 3 deletions
diff --git a/lib/terminal.ml b/lib/terminal.ml
index 0f6b23af36..58851ed274 100644
--- a/lib/terminal.ml
+++ b/lib/terminal.ml
@@ -117,7 +117,7 @@ let is_extended = function
| `INDEX _ | `RGB _ -> true
| _ -> false
-let eval st =
+let repr st =
let fg = match st.fg_color with
| None -> []
| Some c ->
@@ -152,7 +152,10 @@ let eval st =
| Some true -> [7]
| Some false -> [27]
in
- let tags = fg @ bg @ bold @ italic @ underline @ negative in
+ fg @ bg @ bold @ italic @ underline @ negative
+
+let eval st =
+ let tags = repr st in
let tags = List.map string_of_int tags in
Printf.sprintf "\027[%sm" (String.concat ";" tags)
diff --git a/lib/terminal.mli b/lib/terminal.mli
index f308ede323..49172e3ce3 100644
--- a/lib/terminal.mli
+++ b/lib/terminal.mli
@@ -46,6 +46,9 @@ val make : ?fg_color:color -> ?bg_color:color ->
val merge : style -> style -> style
(** [merge s1 s2] returns [s1] with all defined values of [s2] overwritten. *)
+val repr : style -> int list
+(** Generate the ANSI code representing the given style. *)
+
val eval : style -> string
(** Generate an escape sequence from a style. *)
diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml
index 160e549afe..af7169ad6c 100644
--- a/toplevel/coqtop.ml
+++ b/toplevel/coqtop.ml
@@ -281,7 +281,16 @@ let print_style_tags () =
in
print_string opt
in
- List.iter iter tags;
+ let make (t, st) = match st with
+ | None -> None
+ | Some st ->
+ let tags = List.map string_of_int (Terminal.repr st) in
+ let t = String.concat "." (Ppstyle.repr t) in
+ Some (t ^ "=" ^ String.concat ";" tags)
+ in
+ let repr = List.map_filter make tags in
+ let () = Printf.printf "COQ_COLORS=\"%s\"\n" (String.concat ":" repr) in
+ let () = List.iter iter tags in
flush_all ()
let error_missing_arg s =