java.lang.Object
net.orbyfied.j8.util.logging.formatting.Ansi

public class Ansi extends Object
Main class for ANSI information. Special thanks to: https://github.com/dialex/JColor for showing me how to do RGB codes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final char
    The escape character which denotes the ANSI code.
    static final String
    Every ANSI attribute/sequence starts like this.
    static final String
    The separator between ANSI attributes.
    static final String
    Every ANSI attribute/sequence ends like this.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    encode(AnsiAttr... attributes)
    Encodes an array of attributes into a valid ANSI sequence.
    static String
    Strips the string 's' of all of its ANSI sequences.
    static String
    translate(String s, char prefix, char hexprefix)
    Parses a string with sequences prefixed by 'prefix' (+'hexprefix' if RGB) to a string with ANSI attributes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Ansi

      public Ansi()
  • Method Details

    • encode

      public static String encode(AnsiAttr... attributes)
      Encodes an array of attributes into a valid ANSI sequence.
      Parameters:
      attributes - The specified of the attributes.
      Returns:
      The encoded sequence.
    • translate

      public static String translate(String s, char prefix, char hexprefix)
      Parses a string with sequences prefixed by 'prefix' (+'hexprefix' if RGB) to a string with ANSI attributes.
      Parameters:
      s - The string to parse.
      prefix - The prefix of all of the sequences.
      hexprefix - The prefix of all of the RGB (hexadecimal) sequences. The final prefix is prefix + hexprefix
      Returns:
      The parsed string.
    • strip

      public static String strip(String s)
      Strips the string 's' of all of its ANSI sequences.
      Parameters:
      s - The string.
      Returns:
      The stripped string.