Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit e790f97

Browse files
committed
Enable colors for terse output
There was a choice for “many”, “some” or “none” but no way to set it. The color choices were impractical anyway (bold black foreground on standard background). Now the colors for terse output provide proper visibility and are enabled together with colored output.
1 parent bd2d2c6 commit e790f97

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

src/main/scala/scala/tools/partest/nest/NestUI.scala

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package nest
88

99
import java.io.PrintWriter
1010

11-
class Colors(enabled: => Boolean) {
11+
class Colors(enabled: Boolean) {
1212
import Console._
1313

1414
val bold = colored(BOLD)
@@ -38,15 +38,9 @@ class NestUI(val verbose: Boolean = false, val debug: Boolean = false, val terse
3838
val color = new Colors(colorEnabled)
3939
import color._
4040

41-
val NONE = 0
42-
val SOME = 1
43-
val MANY = 2
44-
45-
private[this] var _outline = ""
46-
private[this] var _success = ""
47-
private[this] var _failure = ""
48-
private[this] var _warning = ""
49-
private[this] var _default = ""
41+
private[this] val (_outline, _success, _failure, _warning, _default) =
42+
if (colorEnabled) (Console.BOLD, Console.BOLD + Console.GREEN, Console.BOLD + Console.RED, Console.BOLD + Console.YELLOW, Console.RESET)
43+
else ("", "", "", "", "")
5044

5145
private[this] var dotCount = 0
5246
private[this] val DotWidth = 72
@@ -113,22 +107,6 @@ class NestUI(val verbose: Boolean = false, val debug: Boolean = false, val terse
113107
def echoMixed(msg: String) = echo(bold(yellow(msg)))
114108
def echoWarning(msg: String) = echo(bold(red(msg)))
115109

116-
def initialize(number: Int) = number match {
117-
case MANY =>
118-
_outline = Console.BOLD + Console.BLACK
119-
_success = Console.BOLD + Console.GREEN
120-
_failure = Console.BOLD + Console.RED
121-
_warning = Console.BOLD + Console.YELLOW
122-
_default = Console.RESET
123-
case SOME =>
124-
_outline = Console.BOLD + Console.BLACK
125-
_success = Console.RESET
126-
_failure = Console.BOLD + Console.BLACK
127-
_warning = Console.BOLD + Console.BLACK
128-
_default = Console.RESET
129-
case _ =>
130-
}
131-
132110
def outline(msg: String) = print(_outline + msg + _default)
133111
def outline(msg: String, wr: PrintWriter) = synchronized {
134112
wr.print(_outline + msg + _default)

0 commit comments

Comments
 (0)