present.ansi¶
Module contains code relavent to ANSI escape codes
Ansi
¶
Utility methods for ANSI color codes
Source code in /home/runner/work/arc/arc/arc/present/ansi.py
clean(string)
classmethod
¶
len(string)
classmethod
¶
Length of a string, not including escape sequences
Source code in /home/runner/work/arc/arc/arc/present/ansi.py
bg
¶
Background colors
Source code in /home/runner/work/arc/arc/arc/present/ansi.py
ARC_BLUE = '\x1b[48;2;59;192;240m'
class-attribute
instance-attribute
¶
The blue used in arc branding
BLACK = '\x1b[40m'
class-attribute
instance-attribute
¶
Escape code for background ANIS black
BLUE = '\x1b[44m'
class-attribute
instance-attribute
¶
Escape code for background ANIS blue
BRIGHT_BLUE = '\x1b[104m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright blue
BRIGHT_CYAN = '\x1b[106m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright cyan
BRIGHT_GREEN = '\x1b[102m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright green
BRIGHT_MAGENTA = '\x1b[105m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright magenta
BRIGHT_RED = '\x1b[101m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright red
BRIGHT_WHITE = '\x1b[107m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright white
BRIGHT_YELLOW = '\x1b[103m'
class-attribute
instance-attribute
¶
Escape code for background ANIS bright yellow
CYAN = '\x1b[46m'
class-attribute
instance-attribute
¶
Escape code for background ANIS cyan
GREEN = '\x1b[42m'
class-attribute
instance-attribute
¶
Escape code for background ANIS green
GREY = '\x1b[100m'
class-attribute
instance-attribute
¶
Escape code for background ANIS grey
MAGENTA = '\x1b[45m'
class-attribute
instance-attribute
¶
Escape code for background ANIS magenta
RED = '\x1b[41m'
class-attribute
instance-attribute
¶
Escape code for background ANIS red
WHITE = '\x1b[47m'
class-attribute
instance-attribute
¶
Escape code for background ANIS white
YELLOW = '\x1b[43m'
class-attribute
instance-attribute
¶
Escape code for background ANIS yellow
hex(hex_code)
staticmethod
¶
Returns the background escape sequence for the provided hex value
rgb(red=0, green=0, blue=0)
staticmethod
¶
Returns the background escape sequence for the provided rgb values
fg
¶
Foreground colors
Source code in /home/runner/work/arc/arc/arc/present/ansi.py
ARC_BLUE = '\x1b[38;2;59;192;240m'
class-attribute
instance-attribute
¶
The blue used in arc branding
BLACK = '\x1b[30m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI black
BLUE = '\x1b[34m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI blue
BRIGHT_BLUE = '\x1b[94m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI brightblue
BRIGHT_CYAN = '\x1b[96m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI bright cyan
BRIGHT_GREEN = '\x1b[92m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI bright green
BRIGHT_MAGENTA = '\x1b[95m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI bright magenta
BRIGHT_RED = '\x1b[91m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI bright red
BRIGHT_WHITE = '\x1b[97m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI bright white
BRIGHT_YELLOW = '\x1b[93m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI bright yellow
CYAN = '\x1b[36m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI cyan
GREEN = '\x1b[32m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI green
GREY = '\x1b[90m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI grey
MAGENTA = '\x1b[35m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI magenta
RED = '\x1b[31m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI red
WHITE = '\x1b[37m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI white
YELLOW = '\x1b[33m'
class-attribute
instance-attribute
¶
Escape code for foreground ANSI yellow
hex(hex_code)
staticmethod
¶
Returns the foreground escape sequence for the provided hex values
rgb(red=0, green=0, blue=0)
staticmethod
¶
Returns the foreground escape sequence for the provided rgb values
fx
¶
Other effects like CLEAR
or BOLD
.
Support from terminal to terminal may vary
Source code in /home/runner/work/arc/arc/arc/present/ansi.py
colorize(string, *codes, clear=True)
¶
Applies colors / effects to an entire string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
str
|
String to colorize |
required |
*codes |
str
|
colors / effects to apply to the strin |
()
|
clear |
bool
|
Whether or not to append |
True
|
Returns:
Name | Type | Description |
---|---|---|
string |
str
|
The colorized string |