diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-05-12 15:53:58 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-05-12 15:53:58 +0200 |
commit | 799007fcf66b5d4299f31533d57a8eee1a345c22 (patch) | |
tree | 7d67ef477292d7f5f90a21cfec599a392eecee18 | |
parent | dc36755731c92771647531427e390076e558567d (diff) | |
download | dotty-799007fcf66b5d4299f31533d57a8eee1a345c22.tar.gz dotty-799007fcf66b5d4299f31533d57a8eee1a345c22.tar.bz2 dotty-799007fcf66b5d4299f31533d57a8eee1a345c22.zip |
Use ChoiceSetting for coloring
-rw-r--r-- | src/dotty/tools/dotc/config/ScalaSettings.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/AmmoniteReader.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 2 | ||||
-rw-r--r-- | test/test/TestREPL.scala | 2 |
4 files changed, 6 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala index 09234fb3c..54a77eee8 100644 --- a/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -28,6 +28,7 @@ class ScalaSettings extends Settings.SettingGroup { val help = BooleanSetting("-help", "Print a synopsis of standard options") val nowarn = BooleanSetting("-nowarn", "Generate no warnings.") val print = BooleanSetting("-print", "Print program with Scala-specific features removed.") + val color = ChoiceSetting("-color", "mode", "Colored output", List("always", "never", "auto"), "auto") val target = ChoiceSetting("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.", List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "jvm-1.8", "msil"), "jvm-1.8") @@ -94,7 +95,6 @@ class ScalaSettings extends Settings.SettingGroup { val sourceReader = StringSetting("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "") val XnoValueClasses = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") val XreplLineWidth = IntSetting("-Xrepl-line-width", "Maximial number of columns per line for REPL output", 390) - val XreplNoColor = BooleanSetting("-Xrepl-no-color", "Removes syntax highlighting in REPL") val XoldPatmat = BooleanSetting("-Xoldpatmat", "Use the pre-2.10 pattern matcher. Otherwise, the 'virtualizing' pattern matcher is used in 2.10.") val XnoPatmatAnalysis = BooleanSetting("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.") val XfullLubs = BooleanSetting("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.") diff --git a/src/dotty/tools/dotc/repl/AmmoniteReader.scala b/src/dotty/tools/dotc/repl/AmmoniteReader.scala index 508257e44..c02a14451 100644 --- a/src/dotty/tools/dotc/repl/AmmoniteReader.scala +++ b/src/dotty/tools/dotc/repl/AmmoniteReader.scala @@ -58,8 +58,10 @@ class AmmoniteReader(val interpreter: Interpreter)(implicit ctx: Context) extend allFilters, displayTransform = (buffer, cursor) => { val coloredBuffer = - if (!ctx.settings.XreplNoColor.value) SyntaxHighlighting(buffer) + if (List("auto", "always").contains(ctx.settings.color.value)) + SyntaxHighlighting(buffer) else buffer + val ansiBuffer = Ansi.Str.parse(coloredBuffer) val (newBuffer, cursorOffset) = SelectionFilter.mangleBuffer( selectionFilter, ansiBuffer, cursor, Ansi.Reversed.On diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index 7de7a4bd6..700909fd0 100644 --- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -419,7 +419,7 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit withOutput(new ByteOutputStream) { ps => val rawRes = valMethodRes.invoke(interpreterResultObject).toString val res = - if (!ictx.settings.XreplNoColor.value) + if (List("auto", "always").contains(ictx.settings.color.value)) new String(SyntaxHighlighting(rawRes).toArray) else rawRes val prints = ps.toString("utf-8") diff --git a/test/test/TestREPL.scala b/test/test/TestREPL.scala index 2beb9e40b..4899607ce 100644 --- a/test/test/TestREPL.scala +++ b/test/test/TestREPL.scala @@ -21,7 +21,7 @@ class TestREPL(script: String) extends REPL { override val output = new NewLinePrintWriter(out) override def context(ctx: Context) = - ctx.fresh.setSetting(ctx.settings.XreplNoColor, true) + ctx.fresh.setSetting(ctx.settings.color, "never") override def input(in: Interpreter)(implicit ctx: Context) = new InteractiveReader { val lines = script.lines |