Python package and CLI tool for creating and interpreting ANSI escape codes
Project description
ansiscape
ansiscape
is a Python package for interpreting and creating ANSI escape codes.
Highlights
Create formatted text, with support for nested colours and custom RGB:
from ansiscape import Sequence, green, foreground
text = Sequence(
green("This is ", foreground((1.0, 0.5, 0.0, 1.0), "heavy"), ", Doc,"),
" said Marty.",
)
print(text)
Convert a string with embedded escape codes into a list of strings and explanatory dictionaries:
from ansiscape import Sequence
Sequence("Hello world, and \033[3myou\033[23m in particular!").resolved
[
"Hello world, and ",
{"calligraphy": Calligraphy.ITALIC},
"you",
{"calligraphy": Calligraphy.NONE},
" in particular!",
]
Installation
ansiscape
requires Python 3.8 or later.
pip install ansiscape
Discovering terminal support
To see examples of the formatting supported by your terminal, run:
ansiscape
The project
The source for ansiscape
is available at github.com/cariad/ansiscape under the MIT licence.
And, hello! I'm Cariad Eccleston and I'm an independent/freelance software engineer. If my work has value to you, please consider sponsoring.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for ansiscape-1.0.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbe5d216677ce28d4f3ac09d1cc9c8fe8460da5312374377901b0b3c12ec3ba3 |
|
MD5 | 226ee6a006f383c21f5a738ec1e5c093 |
|
BLAKE2b-256 | 01f207d647794b7b41c7dc2422b1330fbb46d06e9e28497039bc139fc096836b |