Jelajahi Sumber

[MessageReporting] Invert logic for color handling

Default is now to not enable colors; colors can be enabled with -D message.color
Rudy Ges 3 minggu lalu
induk
melakukan
a76069be0d
2 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 3 3
      src-json/define.json
  2. 1 1
      src/compiler/messageReporting.ml

+ 3 - 3
src-json/define.json

@@ -885,10 +885,10 @@
 		"params": ["mode: classic | pretty | indent"]
 		"params": ["mode: classic | pretty | indent"]
 	},
 	},
 	{
 	{
-		"name": "MessageNoColor",
-		"define": "message.no-color",
+		"name": "MessageColor",
+		"define": "message.color",
 		"signatureNeutral": true,
 		"signatureNeutral": true,
-		"doc": "Disable ANSI color codes in message reporting."
+		"doc": "Enable ANSI color codes in message reporting."
 	},
 	},
 	{
 	{
 		"name": "MessageAbsolutePositions",
 		"name": "MessageAbsolutePositions",

+ 1 - 1
src/compiler/messageReporting.ml

@@ -142,7 +142,7 @@ let compiler_pretty_message_string defines ectx cm =
 
 
 		let gutter_len = (try String.length (Printf.sprintf "%d" (IntMap.find cm.cm_depth ectx.max_lines)) with Not_found -> 0) + 2 in
 		let gutter_len = (try String.length (Printf.sprintf "%d" (IntMap.find cm.cm_depth ectx.max_lines)) with Not_found -> 0) + 2 in
 
 
-		let no_color = Define.defined defines Define.MessageNoColor in
+		let no_color = not (Define.defined defines Define.MessageColor) in
 		let c_reset = if no_color then "" else "\x1b[0m" in
 		let c_reset = if no_color then "" else "\x1b[0m" in
 		let c_bold = if no_color then "" else "\x1b[1m" in
 		let c_bold = if no_color then "" else "\x1b[1m" in
 		let c_dim = if no_color then "" else "\x1b[2m" in
 		let c_dim = if no_color then "" else "\x1b[2m" in