Terminal in Colors
Project documentation terminal_in_colors
.
Allows you to customize the style of messages printed on the terminal.
You can set color, bold, italic, single or double underline, strikethrough, blinking, or set background color.
You can choose between 256 colors or use RGB.
Table of Contents
Project Overview
ColorTerminal
Bases: object
Class that provides methods to create formatted, colored sentences.
Allows the use of ANSI and RGB colors in terminal, using numbers, color name, or list of integers to use RGB.
Once the class is initialized, it allows to use the methods:
paint(string, color, bold, italic, underline, strikethrough, doubleunderline, blink, background, opaque)
- Formats the string using the available options, returns a string.find(color, exact)
- Searches by color name, integer, and returns list of matches, optionally, searches for exact matches or returns None.clear()
- Clear the string formatting.print_all()
- Print all 256 colors.
paint(string: str, color: Union[list, str, int] = None, bold: bool = False, italic: bool = False, underline: bool = False, strikethrough: bool = False, doubleunderline: bool = False, blink: str = False, background: Union[list, str, int] = None, opaque: bool = False) -> str
Styles the phrase as indicated and returns it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string |
(str)
|
string to add format. |
required |
color |
(list|str|int)
|
represent a color could be a list [R, G, B] of int, string, or integer. |
None
|
bold |
(bool)
|
enable bold. |
False
|
italic |
(bool)
|
enable italic. |
False
|
underline |
(bool)
|
enable underline. |
False
|
strikethrough |
(bool)
|
enable strikethrough. |
False
|
doubleunderline |
(bool)
|
enable double underline. |
False
|
blink |
(str)
|
set blink slow (recomended) or rapid (could not work). |
False
|
background |
(list|str|int)
|
set background color, could be a list [R, G, B] of int, string, or integer. |
None
|
opaque |
(bool)
|
the color of text is less intense. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
string formatted by options enter. |
clear() -> str
Clear all formats.
Returns str : string without color to apply on message to clean color format.
print_all() -> str
Print all 256 colors combinations.
find(color: str, exact: bool = False) -> list | None
Search for color using a string or integer, and return a list of tuples of all matches. Optional, exact search by string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color |
(str|int)
|
color for search, must be sting or integer. |
required |
exact |
(bool)
|
boolean, set search exactly for color enter, if not matches color return None. |
False
|
Returns:
Type | Description |
---|---|
list | None
|
list | None : return list of tuples with color matches (integer and name of color) or None. |