ANSI-Project 1.0
Make quick ANSI formats to beautify terminal output
Functions | Variables
ansi Namespace Reference

Functions

def SGR (str)
 Sets colors and style of the characters following this code Example: ansi.SGR("4091") makes RED_HI over BK_BLACK. More...
 
def RGB (r, g, b)
 Specify the Foreground color in RGB. More...
 
def BK_RGB (r, g, b)
 Specify the Background color in RGB. More...
 
def CUU (n)
 Moves the cursor n (default 1) cells up. More...
 
def CUD (n)
 Moves the cursor n (default 1) cells down. More...
 
def CUF (n)
 Moves the cursor n (default 1) cells forwards. More...
 
def CUB (n)
 Moves the cursor n (default 1) cells backwards. More...
 
def CNL (n)
 Moves cursor to beginning of the line n (default 1) lines down. More...
 
def CPL (n)
 Moves cursor to beginning of the line n (default 1) lines up. More...
 
def CHA (n)
 Moves the cursor to column n (default 1) More...
 
def CUP (row, col)
 Moves the cursor to [row, column]. More...
 
def ED (n)
 Clears part of the screen. More...
 
def EL (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. More...
 
def SU (n)
 Scroll whole page up by n (default 1) lines. More...
 
def SD (n)
 Scroll whole page down by n (default 1) lines. More...
 
def HVP (row, 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. More...
 
def custom (str)
 Returns a custom ANSI ESCAPE SEQUENCE. More...
 

Variables

string ESC = "\u001B"
 
string CSI = "\u009B"
 
string DSC = "\u0090"
 
string OSC = "\u009D"
 
string RESET = ESC+"[0m"
 
string BOLD = ESC+"[1m"
 
string FAINT = ESC+"[2m"
 
string ITALIC = ESC+"[3m"
 
string UNDER = ESC+"[4m"
 
string SBLINK = ESC+"[5m"
 
string RBLINK = ESC+"[6m"
 
string REVERSE = ESC+"[7m"
 
string HIDE = ESC+"[8m"
 
string STRIKE = ESC+"[9m"
 
string DEF_FONT = ESC+"[10m"
 Default font. More...
 
string Franktur = ESC+"[20m"
 Rarely supported font. More...
 
string BOLD_OFF = ESC+"[21m"
 
string HI_OFF = ESC+"[22m"
 
string ITALIC_OFF = ESC+"[23m"
 
string UNDER_OFF = ESC+"[24m"
 
string BLINK_OFF = ESC+"[25m"
 
string REVERSE_OFF = ESC+"[27m"
 
string REVEAL = ESC+"[28m"
 
string STRIKE_OFF = ESC+"[29m"
 
string BLACK = ESC+"[30m"
 
string RED = ESC+"[31m"
 
string GREEN = ESC+"[32m"
 
string YELLOW = ESC+"[33m"
 
string BLUE = ESC+"[34m"
 
string PURPLE = ESC+"[35m"
 
string CYAN = ESC+"[36m"
 
string WHITE = ESC+"[37m"
 
string DEFAULT = ESC+"[39m"
 
string BK_BLACK = ESC+"[40m"
 
string BK_RED = ESC+"[41m"
 
string BK_GREEN = ESC+"[42m"
 
string BK_YELLOW = ESC+"[43m"
 
string BK_BLUE = ESC+"[44m"
 
string BK_PURPLE = ESC+"[45m"
 
string BK_CYAN = ESC+"[46m"
 
string BK_WHITE = ESC+"[47m"
 
string BK_DEFAULT = ESC+"[49m"
 
string BLACK_HI = ESC+"[90m"
 
string RED_HI = ESC+"[91m"
 
string GREEN_HI = ESC+"[92m"
 
string YELLOW_HI = ESC+"[93m"
 
string BLUE_HI = ESC+"[94m"
 
string PURPLE_HI = ESC+"[95m"
 
string CYAN_HI = ESC+"[96m"
 
string WHITE_HI = ESC+"[97m"
 
string BK_BLACK_HI = ESC+"[100m"
 
string BK_RED_HI = ESC+"[101m"
 
string BK_GREEN_HI = ESC+"[102m"
 
string BK_YELLOW_HI = ESC+"[103m"
 
string BK_BLUE_HI = ESC+"[104m"
 
string BK_PURPLE_HI = ESC+"[105m"
 
string BK_CYAN_HI = ESC+"[106m"
 
string BK_WHITE_HI = ESC+"[107m"
 
string C0 = ESC+"[11H"
 Place the cursor in top-left corner Same as CUP(1,1) More...
 
string CUU1 = ESC+"[1A"
 Move the cursor 1 row up. More...
 
string CUD1 = ESC+"[1B"
 Move the cursor 1 row down. More...
 
string CUF1 = ESC+"[1C"
 Move the cursor 1 cell forwards. More...
 
string CUB1 = ESC+"[1D"
 Move the cursor 1 cell backwards. More...
 
string CNL1 = ESC+"[1E"
 Moves cursor to beginning of the next line. More...
 
string CPL1 = ESC+"[1F"
 Moves cursor to beginning of the previous line. More...
 
string SU1 = ESC+"[1S"
 Scroll whole page up by 1 line. More...
 
string SD1 = ESC+"[1T"
 Scroll whole page down by 1 line. More...
 
string ED0 = ESC+"[0J"
 Clear from cursor to end of screen. More...
 
string ED1 = ESC+"[1J"
 Clear from cursor to beginning of the screen. More...
 
string ED2 = ESC+"[2J"
 Clear entire screen (and moves cursor to upper left on DOS ANSI.SYS) More...
 
string ED3 = ESC+"[3J"
 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) More...
 
string EL0 = ESC+"[0K"
 Clear from cursor to the end of the line. More...
 
string EL1 = ESC+"[1K"
 Clear from cursor to beginning of the line. More...
 
string EL2 = ESC+"[2K"
 Clear entire line. More...
 
string AUX_PORT_ON = ESC+"[5i"
 Enable aux serial port usually for local serial printer. More...
 
string AUX_PORT_OFF = ESC+"[4i"
 Enable aux serial port usually for local serial printer. More...
 
string DSR = ESC+"[6n"
 Reports the cursor position (CPR) by transmitting ESC[nmR, where n is the row and m is the column. More...
 
string SCP = ESC+"[s"
 Saves 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. More...
 
string RCP = ESC+"[u"
 Restores the cursor position/state in SCO console mode. More...
 

Function Documentation

◆ BK_RGB()

def ansi.BK_RGB (   r,
  g,
  b 
)

Specify the Background color in RGB.

Parameters
r(int) Red value
g(int) Green value
b(int) Blue value
Returns
String to be printed

◆ CHA()

def ansi.CHA (   n)

Moves the cursor to column n (default 1)

Parameters
n(int)
Returns
String to be printed

◆ CNL()

def ansi.CNL (   n)

Moves cursor to beginning of the line n (default 1) lines down.

Parameters
n(int)
Returns
String to be printed

◆ CPL()

def ansi.CPL (   n)

Moves cursor to beginning of the line n (default 1) lines up.

Parameters
n(int)
Returns
String to be printed

◆ CUB()

def ansi.CUB (   n)

Moves the cursor n (default 1) cells backwards.

Parameters
n(int)
Returns
String to be printed

◆ CUD()

def ansi.CUD (   n)

Moves the cursor n (default 1) cells down.

Parameters
n(int)
Returns
String to be printed

◆ CUF()

def ansi.CUF (   n)

Moves the cursor n (default 1) cells forwards.

Parameters
n(int)
Returns
String to be printed

◆ CUP()

def ansi.CUP (   row,
  col 
)

Moves the cursor to [row, column].

The values are 1-based.

Parameters
row(int)
col(int)
Returns
String to be printed

◆ custom()

def ansi.custom (   str)

Returns a custom ANSI ESCAPE SEQUENCE.

Parameters
str(String)
Returns
ESC + "[" + str

◆ CUU()

def ansi.CUU (   n)

Moves the cursor n (default 1) cells up.

Parameters
n(int)
Returns
String to be printed

◆ ED()

def ansi.ED (   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(int)
Returns
String to be printed

◆ EL()

def ansi.EL (   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(int)
Returns
String to be printed

◆ HVP()

def ansi.HVP (   row,
  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(int)
col(int)
Returns
String to be printed

◆ RGB()

def ansi.RGB (   r,
  g,
  b 
)

Specify the Foreground color in RGB.

Parameters
r(int) Red value
g(int) Green value
b(int) Blue value
Returns
String to be printed

◆ SD()

def ansi.SD (   n)

Scroll whole page down by n (default 1) lines.

New lines are added at the top. (not ANSI.SYS)

Parameters
n(int)
Returns
String to be printed

◆ SGR()

def ansi.SGR (   str)

Sets colors and style of the characters following this code Example: ansi.SGR("4091") makes RED_HI over BK_BLACK.

Parameters
str(String)
Returns
String to be printed

◆ SU()

def ansi.SU (   n)

Scroll whole page up by n (default 1) lines.

New lines are added at the bottom. (not ANSI.SYS)

Parameters
n(int)
Returns
String to be printed

Variable Documentation

◆ AUX_PORT_OFF

string ansi.AUX_PORT_OFF = ESC+"[4i"

Enable aux serial port usually for local serial printer.

Returns
ESC [4i

◆ AUX_PORT_ON

string ansi.AUX_PORT_ON = ESC+"[5i"

Enable aux serial port usually for local serial printer.

Returns
ESC [5i

◆ BK_BLACK

string ansi.BK_BLACK = ESC+"[40m"

◆ BK_BLACK_HI

string ansi.BK_BLACK_HI = ESC+"[100m"

◆ BK_BLUE

string ansi.BK_BLUE = ESC+"[44m"

◆ BK_BLUE_HI

string ansi.BK_BLUE_HI = ESC+"[104m"

◆ BK_CYAN

string ansi.BK_CYAN = ESC+"[46m"

◆ BK_CYAN_HI

string ansi.BK_CYAN_HI = ESC+"[106m"

◆ BK_DEFAULT

string ansi.BK_DEFAULT = ESC+"[49m"

◆ BK_GREEN

string ansi.BK_GREEN = ESC+"[42m"

◆ BK_GREEN_HI

string ansi.BK_GREEN_HI = ESC+"[102m"

◆ BK_PURPLE

string ansi.BK_PURPLE = ESC+"[45m"

◆ BK_PURPLE_HI

string ansi.BK_PURPLE_HI = ESC+"[105m"

◆ BK_RED

string ansi.BK_RED = ESC+"[41m"

◆ BK_RED_HI

string ansi.BK_RED_HI = ESC+"[101m"

◆ BK_WHITE

string ansi.BK_WHITE = ESC+"[47m"

◆ BK_WHITE_HI

string ansi.BK_WHITE_HI = ESC+"[107m"

◆ BK_YELLOW

string ansi.BK_YELLOW = ESC+"[43m"

◆ BK_YELLOW_HI

string ansi.BK_YELLOW_HI = ESC+"[103m"

◆ BLACK

string ansi.BLACK = ESC+"[30m"

◆ BLACK_HI

string ansi.BLACK_HI = ESC+"[90m"

◆ BLINK_OFF

string ansi.BLINK_OFF = ESC+"[25m"

◆ BLUE

string ansi.BLUE = ESC+"[34m"

◆ BLUE_HI

string ansi.BLUE_HI = ESC+"[94m"

◆ BOLD

string ansi.BOLD = ESC+"[1m"

◆ BOLD_OFF

string ansi.BOLD_OFF = ESC+"[21m"

◆ C0

string ansi.C0 = ESC+"[11H"

Place the cursor in top-left corner Same as CUP(1,1)

Returns
ESC [11H

◆ CNL1

string ansi.CNL1 = ESC+"[1E"

Moves cursor to beginning of the next line.

Returns
ESC [1E

◆ CPL1

string ansi.CPL1 = ESC+"[1F"

Moves cursor to beginning of the previous line.

Returns
ESC [1F

◆ CSI

string ansi.CSI = "\u009B"

◆ CUB1

string ansi.CUB1 = ESC+"[1D"

Move the cursor 1 cell backwards.

Returns
ESC [1D

◆ CUD1

string ansi.CUD1 = ESC+"[1B"

Move the cursor 1 row down.

Returns
ESC [1B

◆ CUF1

string ansi.CUF1 = ESC+"[1C"

Move the cursor 1 cell forwards.

Returns
ESC [1C

◆ CUU1

string ansi.CUU1 = ESC+"[1A"

Move the cursor 1 row up.

Returns
ESC [1A

◆ CYAN

string ansi.CYAN = ESC+"[36m"

◆ CYAN_HI

string ansi.CYAN_HI = ESC+"[96m"

◆ DEF_FONT

string ansi.DEF_FONT = ESC+"[10m"

Default font.

◆ DEFAULT

string ansi.DEFAULT = ESC+"[39m"

◆ DSC

string ansi.DSC = "\u0090"

◆ DSR

string ansi.DSR = ESC+"[6n"

Reports the cursor position (CPR) by transmitting ESC[nmR, where n is the row and m is the column.

Returns
ESC [6n

◆ ED0

string ansi.ED0 = ESC+"[0J"

Clear from cursor to end of screen.

Returns
ESC [0J

◆ ED1

string ansi.ED1 = ESC+"[1J"

Clear from cursor to beginning of the screen.

Returns
ESC [1J

◆ ED2

string ansi.ED2 = ESC+"[2J"

Clear entire screen (and moves cursor to upper left on DOS ANSI.SYS)

Returns
ESC [2J

◆ ED3

string ansi.ED3 = ESC+"[3J"

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)

Returns
ESC [3J

◆ EL0

string ansi.EL0 = ESC+"[0K"

Clear from cursor to the end of the line.

Returns
ESC [0K

◆ EL1

string ansi.EL1 = ESC+"[1K"

Clear from cursor to beginning of the line.

Returns
ESC [1K

◆ EL2

string ansi.EL2 = ESC+"[2K"

Clear entire line.

Cursor position does not change.

Returns
ESC [2K

◆ ESC

string ansi.ESC = "\u001B"

◆ FAINT

string ansi.FAINT = ESC+"[2m"

◆ Franktur

string ansi.Franktur = ESC+"[20m"

Rarely supported font.

◆ GREEN

string ansi.GREEN = ESC+"[32m"

◆ GREEN_HI

string ansi.GREEN_HI = ESC+"[92m"

◆ HI_OFF

string ansi.HI_OFF = ESC+"[22m"

◆ HIDE

string ansi.HIDE = ESC+"[8m"

◆ ITALIC

string ansi.ITALIC = ESC+"[3m"

◆ ITALIC_OFF

string ansi.ITALIC_OFF = ESC+"[23m"

◆ OSC

string ansi.OSC = "\u009D"

◆ PURPLE

string ansi.PURPLE = ESC+"[35m"

◆ PURPLE_HI

string ansi.PURPLE_HI = ESC+"[95m"

◆ RBLINK

string ansi.RBLINK = ESC+"[6m"

◆ RCP

string ansi.RCP = ESC+"[u"

Restores the cursor position/state in SCO console mode.

Returns
ESC [u

◆ RED

string ansi.RED = ESC+"[31m"

◆ RED_HI

string ansi.RED_HI = ESC+"[91m"

◆ RESET

string ansi.RESET = ESC+"[0m"

◆ REVEAL

string ansi.REVEAL = ESC+"[28m"

◆ REVERSE

string ansi.REVERSE = ESC+"[7m"

◆ REVERSE_OFF

string ansi.REVERSE_OFF = ESC+"[27m"

◆ SBLINK

string ansi.SBLINK = ESC+"[5m"

◆ SCP

string ansi.SCP = ESC+"[s"

Saves 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.

Returns
ESC [s

◆ SD1

string ansi.SD1 = ESC+"[1T"

Scroll whole page down by 1 line.

Returns
ESC [1T

◆ STRIKE

string ansi.STRIKE = ESC+"[9m"

◆ STRIKE_OFF

string ansi.STRIKE_OFF = ESC+"[29m"

◆ SU1

string ansi.SU1 = ESC+"[1S"

Scroll whole page up by 1 line.

Returns
ESC [1S

◆ UNDER

string ansi.UNDER = ESC+"[4m"

◆ UNDER_OFF

string ansi.UNDER_OFF = ESC+"[24m"

◆ WHITE

string ansi.WHITE = ESC+"[37m"

◆ WHITE_HI

string ansi.WHITE_HI = ESC+"[97m"

◆ YELLOW

string ansi.YELLOW = ESC+"[33m"

◆ YELLOW_HI

string ansi.YELLOW_HI = ESC+"[93m"