diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ILoop.scala | 8 | ||||
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala | 10 | ||||
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/ReplProps.scala | 3 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index 50c89f7442..cfc4e5a5c8 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -445,8 +445,14 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) } private def readOneLine() = { + import scala.io.AnsiColor.{ MAGENTA, RESET } out.flush() - in readLine prompt + in readLine ( + if (replProps.colorOk) + MAGENTA + prompt + RESET + else + prompt + ) } /** The main read-eval-print loop for the repl. It calls diff --git a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala index a37cdc2ec8..8e624174ed 100644 --- a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -119,7 +119,15 @@ trait MemberHandlers { if (replProps.vids) s"""" + f"@$${System.identityHashCode($path)}%8x" + """" else "" - """ + "%s%s: %s = " + %s""".format(string2code(prettyName), vidString, string2code(req typeOf name), resultString) + import scala.io.AnsiColor.{ BOLD, BLUE, GREEN, RESET } + + def color(c: String, s: String) = + if (replProps.colorOk) string2code(BOLD) + string2code(c) + s + string2code(RESET) + else s + + val nameString = color(BLUE, string2code(prettyName)) + vidString + val typeString = color(GREEN, string2code(req typeOf name)) + s""" + "$nameString: $typeString = " + $resultString""" } } } diff --git a/src/repl/scala/tools/nsc/interpreter/ReplProps.scala b/src/repl/scala/tools/nsc/interpreter/ReplProps.scala index 36e6dbbccc..8c4faf7278 100644 --- a/src/repl/scala/tools/nsc/interpreter/ReplProps.scala +++ b/src/repl/scala/tools/nsc/interpreter/ReplProps.scala @@ -13,6 +13,9 @@ class ReplProps { private def bool(name: String) = BooleanProp.keyExists(name) private def int(name: String) = IntProp(name) + // This property is used in TypeDebugging. Let's recycle it. + val colorOk = bool("scala.color") + val info = bool("scala.repl.info") val debug = bool("scala.repl.debug") val trace = bool("scala.repl.trace") |