Package ansi
Class ANSI
java.lang.Object
ansi.ANSI
public class ANSI
extends java.lang.Object
Make quick ANSI formats to beautify terminal output
- Since:
- January 2022
- Version:
- 1.0
- Author:
- Bruno Castro
- See Also:
- https://github.com/bruneo32/ANSI-Project, https://en.wikipedia.org/wiki/ANSI_escape_code
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUX_PORT_OFFEnable aux serial port usually for local serial printerstatic java.lang.StringAUX_PORT_ONEnable aux serial port usually for local serial printerstatic java.lang.StringBK_BLACKstatic java.lang.StringBK_BLACK_HIstatic java.lang.StringBK_BLUEstatic java.lang.StringBK_BLUE_HIstatic java.lang.StringBK_CYANstatic java.lang.StringBK_CYAN_HIstatic java.lang.StringBK_DEFAULTstatic java.lang.StringBK_GREENstatic java.lang.StringBK_GREEN_HIstatic java.lang.StringBK_PURPLEstatic java.lang.StringBK_PURPLE_HIstatic java.lang.StringBK_REDstatic java.lang.StringBK_RED_HIstatic java.lang.StringBK_WHITEstatic java.lang.StringBK_WHITE_HIstatic java.lang.StringBK_YELLOWstatic java.lang.StringBK_YELLOW_HIstatic java.lang.StringBLACKstatic java.lang.StringBLACK_HIstatic java.lang.StringBLINK_OFFstatic java.lang.StringBLUEstatic java.lang.StringBLUE_HIstatic java.lang.StringBOLDstatic java.lang.StringBOLD_OFFstatic java.lang.StringC0Place the cursor in top-left corner Same as CUP(1,1)static java.lang.StringCNL1Moves cursor to beginning of the next linestatic java.lang.StringCPL1Moves cursor to beginning of the previous linestatic java.lang.StringCSIstatic java.lang.StringCUB1Move the cursor 1 cell backwardsstatic java.lang.StringCUD1Move the cursor 1 row downstatic java.lang.StringCUF1Move the cursor 1 cell forwardsstatic java.lang.StringCUU1Move the cursor 1 row upstatic java.lang.StringCYANstatic java.lang.StringCYAN_HIstatic java.lang.StringDEF_FONTDefault fontstatic java.lang.StringDEFAULTstatic java.lang.StringDSCstatic java.lang.StringDSRReports the cursor position (CPR) by transmitting ESC[n;mR, where n is the row and m is the column.static java.lang.StringED0Clear from cursor to end of screen.static java.lang.StringED1Clear from cursor to beginning of the screenstatic java.lang.StringED2Clear entire screen (and moves cursor to upper left on DOS ANSI.SYS)static java.lang.StringED3Clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications)static java.lang.StringEL0Clear from cursor to the end of the linestatic java.lang.StringEL1Clear from cursor to beginning of the linestatic java.lang.StringEL2Clear entire line.static java.lang.StringESCstatic java.lang.StringFAINTstatic java.lang.StringFrankturRarely supported fontstatic java.lang.StringGREENstatic java.lang.StringGREEN_HIstatic java.lang.StringHI_OFFstatic java.lang.StringHIDEstatic java.lang.StringITALICstatic java.lang.StringITALIC_OFFstatic java.lang.StringOSCstatic java.lang.StringPURPLEstatic java.lang.StringPURPLE_HIstatic java.lang.StringRBLINKstatic java.lang.StringRCPRestores the cursor position/state in SCO console mode.static java.lang.StringREDstatic java.lang.StringRED_HIstatic java.lang.StringRESETstatic java.lang.StringREVEALstatic java.lang.StringREVERSEstatic java.lang.StringREVERSE_OFFstatic java.lang.StringSBLINKstatic java.lang.StringSCPSaves the cursor position/state in SCO console mode In vertical split screen mode, instead used to set (as CSI n ; n s) or reset left and right margins.static java.lang.StringSD1Scroll whole page down by 1 linestatic java.lang.StringSTRIKEstatic java.lang.StringSTRIKE_OFFstatic java.lang.StringSU1Scroll whole page up by 1 linestatic java.lang.StringUNDERstatic java.lang.StringUNDER_OFFstatic java.lang.StringWHITEstatic java.lang.StringWHITE_HIstatic java.lang.StringYELLOWstatic java.lang.StringYELLOW_HI -
Constructor Summary
Constructors Constructor Description ANSI() -
Method Summary
Modifier and Type Method Description static java.lang.StringBK_RGB(int r, int g, int b)Specify the Background color in RGBstatic java.lang.StringCHA(int n)Moves the cursor to column n (default 1)static java.lang.StringCNL(int n)Moves cursor to beginning of the line n (default 1) lines down.static java.lang.StringCPL(int n)Moves cursor to beginning of the line n (default 1) lines up.static java.lang.StringCUB(int n)Moves the cursor n (default 1) cells backwardsstatic java.lang.StringCUD(int n)Moves the cursor n (default 1) cells downstatic java.lang.StringCUF(int n)Moves the cursor n (default 1) cells forwardsstatic java.lang.StringCUP(int row, int col)Moves the cursor to [row, column].static java.lang.Stringcustom(java.lang.String str)Returns a custom ANSI ESCAPE SEQUENCEstatic java.lang.StringCUU(int n)Moves the cursor n (default 1) cells upstatic java.lang.StringED(int n)Clears part of the screen.static java.lang.StringEL(int n)Erases part of the line If n is 0 (or missing), clear from cursor to the end of the line If n is 1, clear from cursor to beginning of the line If n is 2, clear entire line.static java.lang.StringHVP(int row, int col)Same as CUP, but counts as a format effector function (like CR or LF) rather than an editor function (like CUD or CNL) This can lead to different handling in certain terminal modesstatic java.lang.StringRGB(int r, int g, int b)Specify the Foreground color in RGBstatic java.lang.StringSD(int n)Scroll whole page down by n (default 1) lines.static java.lang.StringSGR(java.lang.String str)Sets colors and style of the characters following this code Example: ANSI.SGR("40;91") makes RED_HI over BK_BLACKstatic java.lang.StringSU(int n)Scroll whole page up by n (default 1) lines.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
ESC
public static java.lang.String ESC -
CSI
public static java.lang.String CSI -
DSC
public static java.lang.String DSC -
OSC
public static java.lang.String OSC -
RESET
public static java.lang.String RESET -
BOLD
public static java.lang.String BOLD -
FAINT
public static java.lang.String FAINT -
ITALIC
public static java.lang.String ITALIC -
UNDER
public static java.lang.String UNDER -
SBLINK
public static java.lang.String SBLINK -
RBLINK
public static java.lang.String RBLINK -
REVERSE
public static java.lang.String REVERSE -
HIDE
public static java.lang.String HIDE -
STRIKE
public static java.lang.String STRIKE -
DEF_FONT
public static java.lang.String DEF_FONTDefault font -
Franktur
public static java.lang.String FrankturRarely supported font -
BOLD_OFF
public static java.lang.String BOLD_OFF -
HI_OFF
public static java.lang.String HI_OFF -
ITALIC_OFF
public static java.lang.String ITALIC_OFF -
UNDER_OFF
public static java.lang.String UNDER_OFF -
BLINK_OFF
public static java.lang.String BLINK_OFF -
REVERSE_OFF
public static java.lang.String REVERSE_OFF -
REVEAL
public static java.lang.String REVEAL -
STRIKE_OFF
public static java.lang.String STRIKE_OFF -
BLACK
public static java.lang.String BLACK -
RED
public static java.lang.String RED -
GREEN
public static java.lang.String GREEN -
YELLOW
public static java.lang.String YELLOW -
BLUE
public static java.lang.String BLUE -
PURPLE
public static java.lang.String PURPLE -
CYAN
public static java.lang.String CYAN -
WHITE
public static java.lang.String WHITE -
DEFAULT
public static java.lang.String DEFAULT -
BK_BLACK
public static java.lang.String BK_BLACK -
BK_RED
public static java.lang.String BK_RED -
BK_GREEN
public static java.lang.String BK_GREEN -
BK_YELLOW
public static java.lang.String BK_YELLOW -
BK_BLUE
public static java.lang.String BK_BLUE -
BK_PURPLE
public static java.lang.String BK_PURPLE -
BK_CYAN
public static java.lang.String BK_CYAN -
BK_WHITE
public static java.lang.String BK_WHITE -
BK_DEFAULT
public static java.lang.String BK_DEFAULT -
BLACK_HI
public static java.lang.String BLACK_HI -
RED_HI
public static java.lang.String RED_HI -
GREEN_HI
public static java.lang.String GREEN_HI -
YELLOW_HI
public static java.lang.String YELLOW_HI -
BLUE_HI
public static java.lang.String BLUE_HI -
PURPLE_HI
public static java.lang.String PURPLE_HI -
CYAN_HI
public static java.lang.String CYAN_HI -
WHITE_HI
public static java.lang.String WHITE_HI -
BK_BLACK_HI
public static java.lang.String BK_BLACK_HI -
BK_RED_HI
public static java.lang.String BK_RED_HI -
BK_GREEN_HI
public static java.lang.String BK_GREEN_HI -
BK_YELLOW_HI
public static java.lang.String BK_YELLOW_HI -
BK_BLUE_HI
public static java.lang.String BK_BLUE_HI -
BK_PURPLE_HI
public static java.lang.String BK_PURPLE_HI -
BK_CYAN_HI
public static java.lang.String BK_CYAN_HI -
BK_WHITE_HI
public static java.lang.String BK_WHITE_HI -
C0
public static java.lang.String C0Place the cursor in top-left corner Same as CUP(1,1) -
CUU1
public static java.lang.String CUU1Move the cursor 1 row up -
CUD1
public static java.lang.String CUD1Move the cursor 1 row down -
CUF1
public static java.lang.String CUF1Move the cursor 1 cell forwards -
CUB1
public static java.lang.String CUB1Move the cursor 1 cell backwards -
CNL1
public static java.lang.String CNL1Moves cursor to beginning of the next line -
CPL1
public static java.lang.String CPL1Moves cursor to beginning of the previous line -
SU1
public static java.lang.String SU1Scroll whole page up by 1 line -
SD1
public static java.lang.String SD1Scroll whole page down by 1 line -
ED0
public static java.lang.String ED0Clear from cursor to end of screen. -
ED1
public static java.lang.String ED1Clear from cursor to beginning of the screen -
ED2
public static java.lang.String ED2Clear entire screen (and moves cursor to upper left on DOS ANSI.SYS) -
ED3
public static java.lang.String ED3Clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications) -
EL0
public static java.lang.String EL0Clear from cursor to the end of the line -
EL1
public static java.lang.String EL1Clear from cursor to beginning of the line -
EL2
public static java.lang.String EL2Clear entire line. Cursor position does not change. -
AUX_PORT_ON
public static java.lang.String AUX_PORT_ONEnable aux serial port usually for local serial printer -
AUX_PORT_OFF
public static java.lang.String AUX_PORT_OFFEnable aux serial port usually for local serial printer -
DSR
public static java.lang.String DSRReports the cursor position (CPR) by transmitting ESC[n;mR, where n is the row and m is the column. -
SCP
public static java.lang.String SCPSaves the cursor position/state in SCO console mode In vertical split screen mode, instead used to set (as CSI n ; n s) or reset left and right margins. -
RCP
public static java.lang.String RCPRestores the cursor position/state in SCO console mode.
-
-
Constructor Details
-
ANSI
public ANSI()
-
-
Method Details
-
SGR
public static java.lang.String SGR(java.lang.String str)Sets colors and style of the characters following this code Example: ANSI.SGR("40;91") makes RED_HI over BK_BLACK- Parameters:
str-- Returns:
- String to be printed
-
RGB
public static java.lang.String RGB(int r, int g, int b)Specify the Foreground color in RGB- Parameters:
r- Red valueg- Green valueb- Blue value- Returns:
- String to be printed
-
BK_RGB
public static java.lang.String BK_RGB(int r, int g, int b)Specify the Background color in RGB- Parameters:
r- Red valueg- Green valueb- Blue value- Returns:
- String to be printed
-
CUU
public static java.lang.String CUU(int n)Moves the cursor n (default 1) cells up- Parameters:
n-- Returns:
- String to be printed
-
CUD
public static java.lang.String CUD(int n)Moves the cursor n (default 1) cells down- Parameters:
n-- Returns:
- String to be printed
-
CUF
public static java.lang.String CUF(int n)Moves the cursor n (default 1) cells forwards- Parameters:
n-- Returns:
- String to be printed
-
CUB
public static java.lang.String CUB(int n)Moves the cursor n (default 1) cells backwards- Parameters:
n-- Returns:
- String to be printed
-
CNL
public static java.lang.String CNL(int n)Moves cursor to beginning of the line n (default 1) lines down.- Parameters:
n-- Returns:
- String to be printed
-
CPL
public static java.lang.String CPL(int n)Moves cursor to beginning of the line n (default 1) lines up.- Parameters:
n-- Returns:
- String to be printed
-
CHA
public static java.lang.String CHA(int n)Moves the cursor to column n (default 1)- Parameters:
n-- Returns:
- String to be printed
-
CUP
public static java.lang.String CUP(int row, int col)Moves the cursor to [row, column]. The values are 1-based.- Parameters:
row-col-- Returns:
- String to be printed
-
ED
public static java.lang.String ED(int n)Clears part of the screen. If n is 0 (or missing), clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS). If n is 3, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for xterm and is supported by other terminal applications).- Parameters:
n-- Returns:
- String to be printed
-
EL
public static java.lang.String EL(int n)Erases part of the line If n is 0 (or missing), clear from cursor to the end of the line If n is 1, clear from cursor to beginning of the line If n is 2, clear entire line. Cursor position does not change.- Parameters:
n-- Returns:
- String to be printed
-
SU
public static java.lang.String SU(int n)Scroll whole page up by n (default 1) lines. New lines are added at the bottom. (not ANSI.SYS)- Parameters:
n-- Returns:
- String to be printed
-
SD
public static java.lang.String SD(int n)Scroll whole page down by n (default 1) lines. New lines are added at the top. (not ANSI.SYS)- Parameters:
n-- Returns:
- String to be printed
-
HVP
public static java.lang.String HVP(int row, int col)Same as CUP, but counts as a format effector function (like CR or LF) rather than an editor function (like CUD or CNL) This can lead to different handling in certain terminal modes- Parameters:
row-col-- Returns:
- String to be printed
-
custom
public static java.lang.String custom(java.lang.String str)Returns a custom ANSI ESCAPE SEQUENCE- Parameters:
str-- Returns:
- ESC + "[" + str
-