Last active
July 30, 2020 18:35
-
-
Save nothub/591f29176fa74870fd8beeab2c47eaef to your computer and use it in GitHub Desktop.
ANSI Formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package not.hub.ansi; | |
/** | |
* ANSI formatting codes | |
* <p> | |
* SGR | |
* Code Effect Note | |
* 0 Reset / Normal All attributes off | |
* 1 Bold or increased intensity As with faint, the color change is a PC (SCO / CGA) invention.[28][better source needed] | |
* 2 Faint or decreased intensity aka Dim (with a saturated color). May be implemented as a light font weight like bold.[29] | |
* 3 Italic Not widely supported. Sometimes treated as inverse or blink.[28] | |
* 4 Underline Style extensions exist for Kitty, VTE, mintty and iTerm2.[30][31] | |
* 5 Slow Blink less than 150 per minute | |
* 6 Rapid Blink MS-DOS ANSI.SYS, 150+ per minute; not widely supported | |
* 7 Reverse video swap foreground and background colors, aka invert; inconsistent emulation[32] | |
* 8 Conceal aka Hide, not widely supported. | |
* 9 Crossed-out aka Strike, characters legible but marked as if for deletion. | |
* 10 Primary (default) font | |
* 11–19 Alternative font Select alternative font n − 10 | |
* 20 Fraktur Rarely supported | |
* 21 Doubly underline or Bold off Double-underline per ECMA-48.[5]:8.3.117 See discussion | |
* 22 Normal color or intensity Neither bold nor faint | |
* 23 Not italic, not Fraktur | |
* 24 Underline off Not singly or doubly underlined | |
* 25 Blink off | |
* 26 Proportional spacing ITU T.61 and T.416, not known to be used on terminals | |
* 27 Reverse/invert off | |
* 28 Reveal conceal off | |
* 29 Not crossed out | |
* 30–37 Set foreground color See color table below | |
* 38 Set foreground color Next arguments are 5;n or 2;r;g;b, see below | |
* 39 Default foreground color implementation defined (according to standard) | |
* 40–47 Set background color See color table below | |
* 48 Set background color Next arguments are 5;n or 2;r;g;b, see below | |
* 49 Default background color implementation defined (according to standard) | |
* 50 Disable proportional spacing T.61 and T.416 | |
* 51 Framed | |
* 52 Encircled Implemented as "emoji variation selector" in mintty.[33] | |
* 53 Overlined Implemented as "emoji variation selector" in mintty.[33] | |
* 54 Not framed or encircled | |
* 55 Not overlined | |
* 58 Set underline color Kitty, VTE, mintty, and iTerm2. (not in standard)[30][31] Next arguments are 5;n or 2;r;g;b, see below | |
* 59 Default underline color Kitty, VTE, mintty, and iTerm2. (not in standard)[30][31] | |
* 60 ideogram underline or right side line Rarely supported | |
* 61 ideogram double underline or double line on the right side Rarely supported | |
* 62 ideogram overline or left side line Rarely supported | |
* 63 ideogram double overline or double line on the left side Rarely supported | |
* 64 ideogram stress marking Rarely supported | |
* 65 ideogram attributes off reset the effects of all of 60–64 | |
* 73 superscript mintty (not in standard)[33] | |
* 74 subscript mintty (not in standard)[33] | |
* 90–97 Set bright foreground color aixterm (not in standard) | |
* 100–107 Set bright background color aixterm (not in standard) | |
* <p> | |
* COLORS | |
* Name FG BG | |
* Black 30 40 | |
* Red 31 41 | |
* Green 32 42 | |
* Yellow 33 43 | |
* Blue 34 44 | |
* Magenta 35 45 | |
* Cyan 36 46 | |
* White 37 47 | |
* Bright Black 90 100 | |
* Bright Red 91 101 | |
* Bright Green 92 102 | |
* Bright Yellow 93 103 | |
* Bright Blue 94 104 | |
* Bright Magenta 95 105 | |
* Bright Cyan 96 106 | |
* Bright White 97 107 | |
* | |
* @author blockparole | |
*/ | |
public class AnsiFormat { | |
public static final String SGR_RESET = "\u001B[0m"; | |
public static final String SGR_HIGH_INTENSITY = "\u001B[1m"; | |
public static final String SGR_LOW_INTESITY = "\u001B[2m"; | |
public static final String SGR_ITALIC = "\u001B[3m"; | |
public static final String SGR_UNDERLINE = "\u001B[4m"; | |
public static final String SGR_BLINK = "\u001B[5m"; | |
public static final String SGR_RAPID_BLINK = "\u001B[6m"; | |
public static final String SGR_REVERSE_VIDEO = "\u001B[7m"; | |
public static final String SGR_INVISIBLE_TEXT = "\u001B[8m"; | |
public static final String FG_BLACK = "\u001B[30m"; | |
public static final String FG_RED = "\u001B[31m"; | |
public static final String FG_GREEN = "\u001B[32m"; | |
public static final String FG_YELLOW = "\u001B[33m"; | |
public static final String FG_BLUE = "\u001B[34m"; | |
public static final String FG_MAGENTA = "\u001B[35m"; | |
public static final String FG_CYAN = "\u001B[36m"; | |
public static final String FG_WHITE = "\u001B[37m"; | |
public static final String FG_BLACK_BRIGHT = "\u001B[90m"; | |
public static final String FG_RED_BRIGHT = "\u001B[91m"; | |
public static final String FG_GREEN_BRIGHT = "\u001B[92m"; | |
public static final String FG_YELLOW_BRIGHT = "\u001B[93m"; | |
public static final String FG_BLUE_BRIGHT = "\u001B[94m"; | |
public static final String FG_MAGENTA_BRIGHT = "\u001B[95m"; | |
public static final String FG_CYAN_BRIGHT = "\u001B[96m"; | |
public static final String FG_WHITE_BRIGHT = "\u001B[97m"; | |
public static final String BG_BLACK = "\u001B[40m"; | |
public static final String BG_RED = "\u001B[41m"; | |
public static final String BG_GREEN = "\u001B[42m"; | |
public static final String BG_YELLOW = "\u001B[43m"; | |
public static final String BG_BLUE = "\u001B[44m"; | |
public static final String BG_MAGENTA = "\u001B[45m"; | |
public static final String BG_CYAN = "\u001B[46m"; | |
public static final String BG_WHITE = "\u001B[47m"; | |
public static final String BG_BLACK_BRIGHT = "\u001B[100m"; | |
public static final String BG_RED_BRIGHT = "\u001B[101m"; | |
public static final String BG_GREEN_BRIGHT = "\u001B[102m"; | |
public static final String BG_YELLOW_BRIGHT = "\u001B[103m"; | |
public static final String BG_BLUE_BRIGHT = "\u001B[104m"; | |
public static final String BG_MAGENTA_BRIGHT = "\u001B[105m"; | |
public static final String BG_CYAN_BRIGHT = "\u001B[106m"; | |
public static final String BG_WHITE_BRIGHT = "\u001B[107m"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment