|
Play Framework/Scala example source code file (Colors.scala)
The Colors.scala Play Framework example source code
/*
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package play.sbtplugin
object Colors {
import scala.Console._
lazy val isANSISupported = {
Option(System.getProperty("sbt.log.noformat")).map(_ != "true").orElse {
Option(System.getProperty("os.name"))
.map(_.toLowerCase)
.filter(_.contains("windows"))
.map(_ => false)
}.getOrElse(true)
}
def red(str: String): String = if (isANSISupported) (RED + str + RESET) else str
def blue(str: String): String = if (isANSISupported) (BLUE + str + RESET) else str
def cyan(str: String): String = if (isANSISupported) (CYAN + str + RESET) else str
def green(str: String): String = if (isANSISupported) (GREEN + str + RESET) else str
def magenta(str: String): String = if (isANSISupported) (MAGENTA + str + RESET) else str
def white(str: String): String = if (isANSISupported) (WHITE + str + RESET) else str
def black(str: String): String = if (isANSISupported) (BLACK + str + RESET) else str
def yellow(str: String): String = if (isANSISupported) (YELLOW + str + RESET) else str
}
Other Play Framework source code examplesHere is a short list of links related to this Play Framework Colors.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.