"Fossies" - the Fresh Open Source Software Archive

Member "scala-js-1.3.1/junit-runtime/src/main/scala/org/scalajs/junit/Ansi.scala" (14 Nov 2020, 1069 Bytes) of package /linux/www/scala-js-1.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Scala source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Scala.js (https://www.scala-js.org/)
    3  *
    4  * Copyright EPFL.
    5  *
    6  * Licensed under Apache License 2.0
    7  * (https://www.apache.org/licenses/LICENSE-2.0).
    8  *
    9  * See the NOTICE file distributed with this work for
   10  * additional information regarding copyright ownership.
   11  */
   12 
   13 package org.scalajs.junit
   14 
   15 private[junit] object Ansi {
   16 
   17   private[this] final val NORMAL = "\u001B[0m"
   18 
   19   def c(s: String, colorSequence: String): String =
   20     if (colorSequence == null) s
   21     else colorSequence + s + NORMAL
   22 
   23   def filterAnsi(s: String): String = {
   24     if (s == null) {
   25       null
   26     } else {
   27       var r: String = ""
   28       val len = s.length
   29       var i = 0
   30       while (i < len) {
   31         val c = s.charAt(i)
   32         if (c == '\u001B') {
   33           i += 1
   34           while (i < len && s.charAt(i) != 'm')
   35             i += 1
   36         } else {
   37           r += c
   38         }
   39         i += 1
   40       }
   41       r
   42     }
   43   }
   44 
   45   final val RED = "\u001B[31m"
   46   final val YELLOW = "\u001B[33m"
   47   final val BLUE = "\u001B[34m"
   48   final val MAGENTA = "\u001B[35m"
   49   final val CYAN = "\u001B[36m"
   50 }