aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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 0f6b23af3..58851ed27 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 f308ede32..49172e3ce 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 160e549af..af7169ad6 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 =