Ansi.kt

  1. package com.hexagonkt.core.text

  2. /**
  3.  * Constants for console formatting with [ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code)
  4.  * codes. They can be used in strings to enable or disable a display option.
  5.  */
  6. object Ansi {
  7.     /** Regex that matches ANSI escape sequences. */
  8.     val REGEX: Regex by lazy { """\u001B\[\d+?m""".toRegex() }

  9.     /** Control Sequence Introducer. */
  10.     const val CSI = "\u001B["
  11.     /** Operating System Command. */
  12.     const val OSC = "\u001B]"
  13.     /** String Terminator. */
  14.     const val ST = "\u001B\\"

  15.     /** Disable all options applied before. */
  16.     const val RESET = "${CSI}0m"
  17. }