Class jm_Ansi._ansi

java.lang.Object
com.jackmeng.ansicolors.jm_Ansi._ansi
Enclosing class:
jm_Ansi

public static final class jm_Ansi._ansi extends Object

This class is where all of the formatting happens. Acquire an instance via jm_Ansi.make() or jm_Ansi.make(String) where you can use cascading to create formatting.

For 4bit colors you should check out: https://i.stack.imgur.com/9UVnC.png

[!] You must always be aware that colors look different depending on the system!
Author:
Jack Meng
  • Method Details

    • content

      public String content()

      Get what is currently treated as raw content in this builder. Raw content signifies anything that is TO BE FORMATTED and not the things that do the formatting.

      [!] THIS METHOD DESTROYS CASCADING [!]
      Returns:
      The raw text to format
    • append

      public jm_Ansi._ansi append(boolean b)
      Extracted method
    • append

      public jm_Ansi._ansi append(char b)
      Extracted method
    • append

      public jm_Ansi._ansi append(char[] b)
      Extracted method
    • append

      public jm_Ansi._ansi append(char[] b, int offset, int len)
      Extracted method
    • append

      public jm_Ansi._ansi append(CharSequence b)
      Extracted method
    • append

      public jm_Ansi._ansi append(CharSequence b, int start, int end)
      Extracted method
    • append

      public jm_Ansi._ansi append(double b)
      Extracted method
    • append

      public jm_Ansi._ansi append(float b)
      Extracted method
    • append

      public jm_Ansi._ansi append(int b)
      Extracted method
    • append

      public jm_Ansi._ansi append(long b)
      Extracted method
    • append

      public jm_Ansi._ansi append(Object b)
      Extracted method
    • append

      public jm_Ansi._ansi append(String b)
      Extracted method
    • append

      public jm_Ansi._ansi append(StringBuffer b)
      Extracted method
    • delete

      public jm_Ansi._ansi delete(int start, int end)
      Extracted method
    • deleteCharAt

      public StringBuilder deleteCharAt(int index)
      Extracted method
    • getChars

      public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
      Extracted method

      [!] This method destroys cascading! [!]

    • indexOf

      public int indexOf(String str)
      Extracted method

      [!] This method destroys cascading! [!]

    • indexOf

      public int indexOf(String str, int fromIndex)
      Extracted method

      [!] This method destroys cascading! [!]

    • insert

      public jm_Ansi._ansi insert(int offset, boolean b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, char b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, char[] b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int index, char[] b, int offset, int len)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int dstOffset, CharSequence s)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int dstOffset, CharSequence s, int start, int end)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, double b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, float b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, int b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, long b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, Object b)
      Extracted method
    • insert

      public jm_Ansi._ansi insert(int offset, String b)
      Extracted method
    • lastIndexOf

      public int lastIndexOf(String str)
      Extracted method

      [!] This method destroys cascading! [!]

    • lastIndexOf

      public int lastIndexOf(String str, int fromIndex)
      Extracted method

      [!] This method destroys cascading! [!]

    • length

      public int length()
      Extracted method

      [!] This method destroys cascading! [!]

    • replace

      public jm_Ansi._ansi replace(int start, int end, String str)
      Extracted method
    • reverse

      public jm_Ansi._ansi reverse()
      Extracted method
    • setCharAt

      public jm_Ansi._ansi setCharAt(int index, char ch)
      Extracted method
    • setLength

      public jm_Ansi._ansi setLength(int newLength)
      Extracted method
    • subSequence

      public CharSequence subSequence(int start, int end)
      Extracted method

      [!] This method destroys cascading! [!]

    • substring

      public String substring(int start)
      Extracted method

      [!] This method destroys cascading! [!]

    • substring

      public String substring(int start, int end)
      Extracted method

      [!] This method destroys cascading! [!]

    • trimToSize

      public jm_Ansi._ansi trimToSize()
      Extracted method
    • black_fg

      public jm_Ansi._ansi black_fg()
    • black

      public jm_Ansi._ansi black()
    • black_bg

      public jm_Ansi._ansi black_bg()
    • red_fg

      public jm_Ansi._ansi red_fg()
    • red

      public jm_Ansi._ansi red()
      Calls red_fg()
    • red_bg

      public jm_Ansi._ansi red_bg()
    • green_fg

      public jm_Ansi._ansi green_fg()
    • green

      public jm_Ansi._ansi green()
    • green_bg

      public jm_Ansi._ansi green_bg()
    • yellow_fg

      public jm_Ansi._ansi yellow_fg()
    • yellow

      public jm_Ansi._ansi yellow()
    • yellow_bg

      public jm_Ansi._ansi yellow_bg()
    • blue_fg

      public jm_Ansi._ansi blue_fg()
    • blue

      public jm_Ansi._ansi blue()
      Calls blue_fg()
    • blue_bg

      public jm_Ansi._ansi blue_bg()
    • magenta_fg

      public jm_Ansi._ansi magenta_fg()
    • magenta

      public jm_Ansi._ansi magenta()
    • magenta_bg

      public jm_Ansi._ansi magenta_bg()
    • cyan_fg

      public jm_Ansi._ansi cyan_fg()
    • cyan

      public jm_Ansi._ansi cyan()
      Calls cyan_fg()
    • cyan_bg

      public jm_Ansi._ansi cyan_bg()
    • white_fg

      public jm_Ansi._ansi white_fg()
    • gray

      public jm_Ansi._ansi gray()
      NOTE: On certain renderers, white_fg and white_bg will return a GRAY color, while on some it returns WHITE! Calls white_fg()
    • white_bg

      public jm_Ansi._ansi white_bg()
    • bright_black_fg

      public jm_Ansi._ansi bright_black_fg()
    • dark_gray

      public jm_Ansi._ansi dark_gray()
      NOTE: On certain renderers, bright_black_fg and bright_black_bg will return the same colors as black_fg and black_bg respectively. Calls bright_black_fg()
    • bright_black_bg

      public jm_Ansi._ansi bright_black_bg()
    • bright_red_fg

      public jm_Ansi._ansi bright_red_fg()
    • bright_red

      public jm_Ansi._ansi bright_red()
    • bright_red_bg

      public jm_Ansi._ansi bright_red_bg()
    • bright_green_fg

      public jm_Ansi._ansi bright_green_fg()
    • bright_green

      public jm_Ansi._ansi bright_green()
    • bright_green_bg

      public jm_Ansi._ansi bright_green_bg()
    • bright_yellow_fg

      public jm_Ansi._ansi bright_yellow_fg()
    • bright_yellow

      public jm_Ansi._ansi bright_yellow()
    • bright_yellow_bg

      public jm_Ansi._ansi bright_yellow_bg()
    • bright_blue_fg

      public jm_Ansi._ansi bright_blue_fg()
    • bright_blue

      public jm_Ansi._ansi bright_blue()
    • bright_blue_bg

      public jm_Ansi._ansi bright_blue_bg()
    • bright_magenta_fg

      public jm_Ansi._ansi bright_magenta_fg()
    • bright_magenta

      public jm_Ansi._ansi bright_magenta()
    • bright_magenta_bg

      public jm_Ansi._ansi bright_magenta_bg()
    • bright_cyan_fg

      public jm_Ansi._ansi bright_cyan_fg()
    • bright_cyan

      public jm_Ansi._ansi bright_cyan()
    • bright_cyan_bg

      public jm_Ansi._ansi bright_cyan_bg()
    • bright_white_fg

      public jm_Ansi._ansi bright_white_fg()
    • white

      public jm_Ansi._ansi white()
    • bright_white_bg

      public jm_Ansi._ansi bright_white_bg()
    • reset

      public jm_Ansi._ansi reset()
      Just use jm_Ansi::reset
      Returns:
      _ansi object
    • bold

      public jm_Ansi._ansi bold()
    • faint

      public jm_Ansi._ansi faint()
      Not widely supported
    • italic

      public jm_Ansi._ansi italic()
      Not widely supported. Some renderers treat this as invert the text
    • underline

      public jm_Ansi._ansi underline()
    • swap_fg_bg

      public jm_Ansi._ansi swap_fg_bg()
      Swaps the foreground and background
    • hide

      public jm_Ansi._ansi hide()
      Hides the text. Not widely supported.
    • strikethrough

      public jm_Ansi._ansi strikethrough()
      Does not conceal. Not widely supported.
    • primary

      public jm_Ansi._ansi primary()
      Regular font effects
    • font_1

      public jm_Ansi._ansi font_1()
    • font_2

      public jm_Ansi._ansi font_2()
    • font_3

      public jm_Ansi._ansi font_3()
    • font_4

      public jm_Ansi._ansi font_4()
    • font_5

      public jm_Ansi._ansi font_5()
    • font_6

      public jm_Ansi._ansi font_6()
    • font_7

      public jm_Ansi._ansi font_7()
    • font_8

      public jm_Ansi._ansi font_8()
    • font_9

      public jm_Ansi._ansi font_9()
    • fraktur

      public jm_Ansi._ansi fraktur()
      Unsupported.
    • no_bold

      public jm_Ansi._ansi no_bold()
      Sometimes treated as double underline. Both are not widely supported.
    • normal

      public jm_Ansi._ansi normal()
      No bold or low thickness
    • no_italic

      public jm_Ansi._ansi no_italic()
      no_fraktur as well
    • no_underline

      public jm_Ansi._ansi no_underline()
      Both single and double underlines eliminated
    • no_blink

      public jm_Ansi._ansi no_blink()
    • no_inverse

      public jm_Ansi._ansi no_inverse()
    • no_hide

      public jm_Ansi._ansi no_hide()
    • no_strikethrough

      public jm_Ansi._ansi no_strikethrough()
    • framed

      public jm_Ansi._ansi framed()
    • encircled

      public jm_Ansi._ansi encircled()
    • overlined

      public jm_Ansi._ansi overlined()
    • no_framed_no_encircled

      public jm_Ansi._ansi no_framed_no_encircled()
    • no_overlined

      public jm_Ansi._ansi no_overlined()
    • fg

      public jm_Ansi._ansi fg()
      Mostly used for internal creation of colors. You should rarely use this if at all.

      Tells to treat the following elements (in the ANSI code) as a color for the text's foreground

    • bg

      public jm_Ansi._ansi bg()
      Mostly used for internal creation of colors. You should rarely use this if at all.

      Tells to treat the following elements (in the ANSI code) as a color for the text's background

    • make

      public jm_Ansi._ansi make(int... codes)
    • rgb_fg

      public jm_Ansi._ansi rgb_fg(int[] rgb)
    • rgb_fg

      public jm_Ansi._ansi rgb_fg(int r, int g, int b)
    • rgb_bg

      public jm_Ansi._ansi rgb_bg(int[] rgb)
    • rgb_bg

      public jm_Ansi._ansi rgb_bg(int r, int g, int b)
    • apply

      public jm_Ansi._ansi apply(int... i)
      Apply your own custom list of ANSI codes. It is not suggested using this unless there are codes outside this builder's range.
      Parameters:
      i - ANSI codes (vararg)
      Returns:
      Instance for cascading
    • end

      public StringBuilder end()
      Should not be called by the programmer unless absolutely necessary. The toString() and escaped() all call this method in order to validate the String.

      This method does not create the final values for rendering

      Returns:
      String -> A validated String for printing.
    • toString

      public String toString()
      This method also appends a RESET character at the end to reset all ANSI coloring after. Technically this is just a wrapper call to toString(String)
      Overrides:
      toString in class Object
    • toString

      public String toString(String content)
      Allows for content to be added at the end (either end). This method also appends a RESET character at the end to reset all ANSI coloring after.
      Parameters:
      content - the content to append to the original content before returning the string
      Returns:
      The formatted content
    • render

      public String render()
      Does not provide a RESET at the end as compared to toString() or toString(String)
      Returns:
      The finalized string without a rest character
    • escaped

      public String escaped()
      For debugging purposes. Displays the built value by escaping all the necessary components.
      Returns:
      String
    • print

      public jm_Ansi._ansi print(PrintStream e)
    • println

      public jm_Ansi._ansi println(PrintStream e)
    • print

      public jm_Ansi._ansi print()
      Uses the default {@link System#out#print()}
    • println

      public jm_Ansi._ansi println()
      Uses the default {@link System#out#println()}
    • println

      public jm_Ansi._ansi println(PrintStream ps, String content)
      Use for end cascading payload submission
      Parameters:
      ps - Suggested PrintStream to use
      content - The payload
      Returns:
      The current instance
      Since:
      1.1
    • print

      public jm_Ansi._ansi print(PrintStream ps, String content)
      Use for end cascading payload submission
      Parameters:
      ps - Suggested PrintStream to use
      content - The payload
      Returns:
      The current instance
      Since:
      1.1
    • print

      public jm_Ansi._ansi print(String content)
      Parameters:
      content -
      Returns:
      Since:
      1.1
    • println

      public jm_Ansi._ansi println(String content)
      Parameters:
      content -
      Returns:
      Since:
      1.1