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

Commit fb7c37d

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 c50e7a4 commit fb7c37d

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)
@@ -37,15 +37,9 @@ class NestUI(val verbose: Boolean = false, val debug: Boolean = false, val terse
3737
val color = new Colors(colorEnabled)
3838
import color._
3939

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

5044
private[this] var dotCount = 0
5145
private[this] val DotWidth = 72
@@ -102,22 +96,6 @@ class NestUI(val verbose: Boolean = false, val debug: Boolean = false, val terse
10296
def echoMixed(msg: String) = echo(bold(yellow(msg)))
10397
def echoWarning(msg: String) = echo(bold(red(msg)))
10498

105-
def initialize(number: Int) = number match {
106-
case MANY =>
107-
_outline = Console.BOLD + Console.BLACK
108-
_success = Console.BOLD + Console.GREEN
109-
_failure = Console.BOLD + Console.RED
110-
_warning = Console.BOLD + Console.YELLOW
111-
_default = Console.RESET
112-
case SOME =>
113-
_outline = Console.BOLD + Console.BLACK
114-
_success = Console.RESET
115-
_failure = Console.BOLD + Console.BLACK
116-
_warning = Console.BOLD + Console.BLACK
117-
_default = Console.RESET
118-
case _ =>
119-
}
120-
12199
def outline(msg: String) = print(_outline + msg + _default)
122100
def outline(msg: String, wr: PrintWriter) = synchronized {
123101
wr.print(_outline + msg + _default)

0 commit comments

Comments
 (0)