ANSItools
Module: terminaltexteffects.utils.ansitools
Collection of functions that generate ANSI escape codes for various terminal formatting effects.
These escape codes can be used to modify the appearance of text in a terminal.
Functions:
Name | Description |
---|---|
parse_ansi_color_sequence |
str) -> int | str: Parse an 8-bit or 24-bit ANSI color sequence. |
dec_save_cursor_position |
Save the cursor position using DEC sequence. |
dec_restore_cursor_position |
Restore the cursor position using DEC sequence. |
hide_cursor |
Hide the cursor. |
show_cursor |
Show the cursor. |
move_cursor_up |
int) -> str: Move the cursor up y lines. |
move_cursor_to_column |
int) -> str: Move the cursor to the specified column. |
reset_all |
Reset all formatting. |
apply_bold |
Apply bold formatting. |
apply_dim |
Apply dim formatting. |
apply_italic |
Apply italic formatting. |
apply_underline |
Apply underline formatting. |
apply_blink |
Apply blink formatting. |
apply_reverse |
Apply reverse formatting. |
apply_hidden |
Apply hidden formatting. |
apply_strikethrough |
Apply strikethrough formatting. |
apply_blink()
apply_bold()
apply_dim()
apply_hidden()
apply_italic()
apply_reverse()
apply_strikethrough()
apply_underline()
dec_restore_cursor_position()
Restore the cursor position using DEC sequence.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
ANSI escape code |
dec_save_cursor_position()
Save the cursor position using DEC sequence.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
ANSI escape code |
hide_cursor()
move_cursor_to_column(x)
Move the cursor to the specified column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
int
|
column number |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
ANSI escape code |
move_cursor_up(y)
Move the cursor up y lines.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y
|
int
|
number of lines to move up |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
ANSI escape code |
parse_ansi_color_sequence(sequence)
Parse an 8-bit or 24-bit ANSI color sequence.
Returns the color code as an integer, in the case of 8-bit, or a hex string in the case of 24-bit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence
|
str
|
ANSI color sequence |
required |
Returns:
Type | Description |
---|---|
int | str
|
int | str: 8-bit color int or 24-bit color str |