Class TerminalColors

java.lang.Object
org.ek9lang.compiler.common.TerminalColors

public final class TerminalColors extends Object
Terminal color and symbol support with automatic capability detection. Provides ANSI escape codes for colors and Unicode symbols for enhanced error display.

Automatically detects terminal capabilities and falls back gracefully:

  • Full: Colors + Emoji + Box-drawing (modern terminals)
  • Unicode: Colors + Box-drawing, no emoji (some terminals)
  • Basic: Colors only, ASCII symbols (older terminals)
  • Plain: No colors, ASCII only (dumb terminals, redirected output)

THE terminal formatting functions. Hold an instance; every instance reads the ONE capability source of the process (TerminalCapabilities.PROCESS), so two parts of one run never disagree about colour - a test that forces a mode (TerminalCapabilities.forcePlainTextMode()) is seen by instances made before it too.

  • Constructor Details

    • TerminalColors

      public TerminalColors()
  • Method Details

    • isColorsSupported

      public boolean isColorsSupported()
    • isUnicodeSupported

      public boolean isUnicodeSupported()
    • isEmojiSupported

      public boolean isEmojiSupported()
    • errorSymbol

      public String errorSymbol()
    • warningSymbol

      public String warningSymbol()
    • infoSymbol

      public String infoSymbol()
    • hintSymbol

      public String hintSymbol()
    • linkSymbol

      public String linkSymbol()
    • checkSymbol

      public String checkSymbol()
    • fixSymbol

      public String fixSymbol()
    • exampleSymbol

      public String exampleSymbol()
    • aiSymbol

      public String aiSymbol()
    • pipe

      public String pipe()
    • arrow

      public String arrow()
    • corner

      public String corner()
    • tee

      public String tee()
    • horizontalLine

      public String horizontalLine()
    • error

      public String error(String text)
    • errorCaret

      public String errorCaret(String text)
      Bright red for error carets (^^^^^) - more vivid than regular red.
    • warning

      public String warning(String text)
    • warningCaret

      public String warningCaret(String text)
      Bright yellow for warning carets (^^^^^) - more vivid than regular yellow.
    • info

      public String info(String text)
    • hint

      public String hint(String text)
    • code

      public String code(String text)
    • dim

      public String dim(String text)
    • bold

      public String bold(String text)
    • white

      public String white(String text)
    • errorHeader

      public String errorHeader(String errorCode, String message)
      Format an error header like: ❌ error[E50001]: message
    • warningHeader

      public String warningHeader(String warningCode, String message)
      Format a warning header like: ⚠️ warning[W01234]: message
    • location

      public String location(String fileName, int line, int column)
      Format a location like: ──▶ file.ek9:15:12
    • sourceLine

      public String sourceLine(int lineNumber, String source)
      Format a source line with line number.
    • carets

      public String carets(int offset, int length, String message)
      Format error carets (^^^^^) under the error location.
    • hintLine

      public String hintLine(String hintText)
      Format a hint line like: ├─ 💡 Did you mean: 'count'?
    • linkLine

      public String linkLine(String url)
      Format a link line like: └─ 🔗 See: https://...
    • pipeLine

      public String pipeLine()
      Format the pipe-only line for visual separation.
    • thickPipe

      public String thickPipe()
      The thick vertical bar for blockquote-style boxes.
    • topCorner

      public String topCorner()
      Top-left corner for heavy box drawing.
    • bottomCorner

      public String bottomCorner()
      Bottom-left corner for heavy box drawing.
    • thickHorizontalLine

      public String thickHorizontalLine()
      Heavy horizontal line for box drawing.
    • richBlock

      public String richBlock(String text, String indent)
      Format a rich explanation block with box corners. Uses heavy box-drawing characters to encapsulate the explanation.
      Parameters:
      text - The multi-line rich explanation text
      indent - The base indentation before the border
      Returns:
      The formatted block with box borders