Skip to content

Commit a8c4a54

Browse files
authored
Merge pull request scala#5663 from gourlaysama/ticket/sd-256-enable-repl-colors-unix-2
Enable colored output by default on unix Fix scala/scala-dev#256
2 parents c96a977 + 6411170 commit a8c4a54

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

bincompat-forward.whitelist.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,14 @@ filter {
423423
{
424424
matchName="scala.annotation.showAsInfix"
425425
problemName=MissingClassProblem
426+
},
427+
{
428+
matchName="scala.util.PropertiesTrait.coloredOutputEnabled"
429+
problemName=DirectMissingMethodProblem
430+
},
431+
{
432+
matchName="scala.util.Properties.coloredOutputEnabled"
433+
problemName=DirectMissingMethodProblem
426434
}
427435
]
428436
}

src/library/scala/util/Properties.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ private[scala] trait PropertiesTrait {
154154
/* Some runtime values. */
155155
private[scala] def isAvian = javaVmName contains "Avian"
156156

157+
private[scala] def coloredOutputEnabled: Boolean = propOrElse("scala.color", "auto") match {
158+
case "auto" => System.console() != null && !isWin
159+
case a if a.toLowerCase() == "true" => true
160+
case _ => false
161+
}
162+
157163
// This is looking for javac, tools.jar, etc.
158164
// Tries JDK_HOME first, then the more common but likely jre JAVA_HOME,
159165
// and finally the system property based javaHome.

src/reflect/scala/reflect/internal/TypeDebugging.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ trait TypeDebugging {
5959
object typeDebug {
6060
import scala.Console._
6161

62-
private val colorsOk = sys.props contains "scala.color"
62+
private val colorsOk = scala.util.Properties.coloredOutputEnabled
6363
private def inColor(s: String, color: String) = if (colorsOk && s != "") color + s + RESET else s
6464
private def inBold(s: String, color: String) = if (colorsOk && s != "") color + BOLD + s + RESET else s
6565

src/repl/scala/tools/nsc/interpreter/ReplProps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ReplProps {
1717
private def int(name: String) = Prop[Int](name)
1818

1919
// This property is used in TypeDebugging. Let's recycle it.
20-
val colorOk = bool("scala.color")
20+
val colorOk = Properties.coloredOutputEnabled
2121

2222
val info = bool("scala.repl.info")
2323
val debug = bool("scala.repl.debug")

0 commit comments

Comments
 (0)