Skip to content

Package io.github.qishr.cascara.common.util

Enum Style

java.lang.Object
        java.lang.Enum<io.github.qishr.cascara.common.util.CommandLine.Help.Ansi.Style>
                io.github.qishr.cascara.common.util.CommandLine.Help.Ansi.Style

All Implemented Interfaces:
    IStyle


public static final enum Style
extends Enum<Style>

A set of pre-defined ANSI escape code styles and colors, and a set of convenience methods for parsing text with embedded markup style names, as well as convenience methods for converting styles to strings with embedded escape codes.

Enum Constants

Enum Constant Description
reset
bold
faint
italic
underline
blink
reverse
fg_black
fg_red
fg_green
fg_yellow
fg_blue
fg_magenta
fg_cyan
fg_white
bg_black
bg_red
bg_green
bg_yellow
bg_blue
bg_magenta
bg_cyan
bg_white

Method Summary

Modifier and Type Method Description
public static Style[] values()
public static Style valueOf(String name)
public String on()
public String off()
public static String on(IStyle[] styles) Returns the concatenated ANSI escape codes for turning all specified styles on.
public static String off(IStyle[] styles) Returns the concatenated ANSI escape codes for turning all specified styles off.
public static IStyle fg(String str) Parses the specified style markup and returns the associated style.
public static IStyle bg(String str) Parses the specified style markup and returns the associated style.
public static IStyle[] parse(String commaSeparatedCodes) Parses the specified comma-separated sequence of style descriptors and returns the associated styles.

Enum Constant Details

reset

public static final reset


bold

public static final bold


faint

public static final faint


italic

public static final italic


underline

public static final underline


public static final blink


reverse

public static final reverse


fg_black

public static final fg_black


fg_red

public static final fg_red


fg_green

public static final fg_green


fg_yellow

public static final fg_yellow


fg_blue

public static final fg_blue


fg_magenta

public static final fg_magenta


fg_cyan

public static final fg_cyan


fg_white

public static final fg_white


bg_black

public static final bg_black


bg_red

public static final bg_red


bg_green

public static final bg_green


bg_yellow

public static final bg_yellow


bg_blue

public static final bg_blue


bg_magenta

public static final bg_magenta


bg_cyan

public static final bg_cyan


bg_white

public static final bg_white


Method Details

values

public static Style[] values()


valueOf

public static Style valueOf(String name)


on

public String on()

Specified By:

IStyle


off

public String off()

Specified By:

IStyle


on

public static String on(IStyle[] styles)

Returns the concatenated ANSI escape codes for turning all specified styles on.

Parameters:

styles - the styles to generate ANSI escape codes for

Returns:

the concatenated ANSI escape codes for turning all specified styles on


off

public static String off(IStyle[] styles)

Returns the concatenated ANSI escape codes for turning all specified styles off.

Parameters:

styles - the styles to generate ANSI escape codes for

Returns:

the concatenated ANSI escape codes for turning all specified styles off


fg

public static IStyle fg(String str)

Parses the specified style markup and returns the associated style.The markup may be one of the Style enum value names, or it may be one of the Style enum value names when "fg_" is prepended, or it may be one of the indexed colors in the 256 color palette.

Parameters:

str - the case-insensitive style markup to convert, e.g. "blue" or "fg_blue", or "46" (indexed color) or "0;5;0" (RGB components of an indexed color)

Returns:

the IStyle for the specified converter


bg

public static IStyle bg(String str)

Parses the specified style markup and returns the associated style.The markup may be one of the Style enum value names, or it may be one of the Style enum value names when "bg_" is prepended, or it may be one of the indexed colors in the 256 color palette.

Parameters:

str - the case-insensitive style markup to convert, e.g. "blue" or "bg_blue", or "46" (indexed color) or "0;5;0" (RGB components of an indexed color)

Returns:

the IStyle for the specified converter


parse

public static IStyle[] parse(String commaSeparatedCodes)

Parses the specified comma-separated sequence of style descriptors and returns the associated styles.For each markup, strings starting with "bg(" are delegated to bg.bg, others are delegated to fg.fg.

Parameters:

commaSeparatedCodes - one or more descriptors, e.g. "bg(blue),underline,red"

Returns:

an array with all styles for the specified descriptors