Only colorize on unix/linux
This commit is contained in:
@@ -3,6 +3,7 @@ package org.jeudego.pairgoth.util
|
||||
import com.diogonunes.jcolor.Ansi
|
||||
import com.diogonunes.jcolor.AnsiFormat
|
||||
import com.diogonunes.jcolor.Attribute
|
||||
import java.util.*
|
||||
|
||||
private val blue = AnsiFormat(Attribute.BRIGHT_BLUE_TEXT())
|
||||
private val green = AnsiFormat(Attribute.BRIGHT_GREEN_TEXT())
|
||||
@@ -11,8 +12,10 @@ private val bold = AnsiFormat(Attribute.BOLD())
|
||||
|
||||
object Colorizer {
|
||||
|
||||
fun blue(str: String) = Ansi.colorize(str, blue)
|
||||
fun green(str: String) = Ansi.colorize(str, green)
|
||||
fun red(str: String) = Ansi.colorize(str, red)
|
||||
fun bold(str: String) = Ansi.colorize(str, bold)
|
||||
val colorize = System.getProperty("os.name").lowercase(Locale.ROOT).contains(Regex("nix|nux|aix"))
|
||||
|
||||
fun blue(str: String) = if (colorize) Ansi.colorize(str, blue) else str
|
||||
fun green(str: String) = if (colorize) Ansi.colorize(str, green) else str
|
||||
fun red(str: String) = if (colorize) Ansi.colorize(str, red) else str
|
||||
fun bold(str: String) = if (colorize) Ansi.colorize(str, bold) else str
|
||||
}
|
||||
|
Reference in New Issue
Block a user