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 |
|---|---|
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. |
enter_alternate_screen |
Switch to a cleared alternate screen with the cursor at the top-left. |
exit_alternate_screen |
Return from the alternate screen to the original screen. |
move_cursor_up |
int) -> str: Move the cursor up y lines. |
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 |
enter_alternate_screen()
Switch to the alternate screen buffer, clear it, and move the cursor to the top-left.
The original screen contents and cursor position are restored by exit_alternate_screen().
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ANSI escape code |
Source code in terminaltexteffects/utils/ansitools.py
exit_alternate_screen()
Return from the alternate screen buffer to the original screen.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ANSI escape code |
hide_cursor()
move_cursor_up(y)
Move the cursor up by a relative number of rows.
A distance of 0 is a no-op and returns an empty string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
int
|
Number of rows to move upward from the current cursor position. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
ANSI escape code |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |