aboutsummaryrefslogtreecommitdiff
path: root/printing/proof_diffs.ml
diff options
context:
space:
mode:
authorJim Fehrle2018-10-07 15:14:56 -0700
committerJim Fehrle2019-02-28 15:39:08 -0800
commitef2fce93057484b015c85713ad83f53f88762271 (patch)
tree9d7f73ebe0fa75e91855099465f3c3469cbe27ca /printing/proof_diffs.ml
parent9736f255287a7207d00422b06de802d62b8304fe (diff)
Show diffs in error messages if color is enabled
Diffstat (limited to 'printing/proof_diffs.ml')
-rw-r--r--printing/proof_diffs.ml24
1 files changed, 19 insertions, 5 deletions
diff --git a/printing/proof_diffs.ml b/printing/proof_diffs.ml
index 878e9f477b..07cdc1e8a3 100644
--- a/printing/proof_diffs.ml
+++ b/printing/proof_diffs.ml
@@ -39,6 +39,13 @@ uses strikeout on removed text.
open Pp_diff
+let term_color = ref true
+
+let write_color_enabled enabled =
+ term_color := enabled
+
+let color_enabled () = !term_color
+
let diff_option = ref `OFF
let read_diffs_option () = match !diff_option with
@@ -46,11 +53,18 @@ let read_diffs_option () = match !diff_option with
| `ON -> "on"
| `REMOVED -> "removed"
-let write_diffs_option = function
-| "off" -> diff_option := `OFF
-| "on" -> diff_option := `ON
-| "removed" -> diff_option := `REMOVED
-| _ -> CErrors.user_err Pp.(str "Diffs option only accepts the following values: \"off\", \"on\", \"removed\".")
+let write_diffs_option opt =
+ let enable opt =
+ if not (color_enabled ()) then
+ CErrors.user_err Pp.(str "Enabling Diffs requires setting the \"-color\" command line argument to \"on\" or \"auto\".")
+ else
+ diff_option := opt
+ in
+ match opt with
+ | "off" -> diff_option := `OFF
+ | "on" -> enable `ON
+ | "removed" -> enable `REMOVED
+ | _ -> CErrors.user_err Pp.(str "Diffs option only accepts the following values: \"off\", \"on\", \"removed\".")
let () =
Goptions.(declare_string_option {