A library for handling ANSI codes
Project description
AnsiLib
AnsiLib is a Python module for handling text style and color shortcuts from ANSI escape codes.
Author: Bora Boyacıoğlu
- E-Mail: boyacioglu20@itu.edu.tr
- GitHub: @boraboyacioglu-itu
Installation
To install AnsiLib, use pip:
pip install ansilib
If you are running Python 3.7 or below, you also need to install typing_extensions
, which comes as a dependency.
Usage
import AnsiLib as al
You can use the quick styles and colors to simply format your text.
print(al.s("This text is bold."))
print(al.r("This text is red."))
print(al.u(al.b("This text is underlined and blue.")))
Also you can reach all of the colors using al.c
class.
print(al.c.t.r("This text is red."))
print(al.c.b.c("This text has cyan background."))
print(al.c.t.g_("This text is bright green."))
To define styles, use al.style()
function.
sty1 = al.style('bold', 'r', 'kb1')
print(sty1("This text is bold, red and has a background color of bright black."))
Get the complete list of styles and colors with al.available()
.
print(al.available())
Create an RGB color using al.color()
function.
my_color = al.color(56, 12, 74)
sty2 = al.style('x', 'italic', my_color)
print(sty2("This text is italic, crossed and has an RGB color of (56, 12, 74)."))
Finally, you can use the AnsiLib's prints()
function to print a styled text.
al.prints("This text is bold, red and has a background color of bright black.", s=['bold', 'r', 'kb1'])
Contributions
I welcome contributions and suggestions to the AnsiLib Python library! Contact me about the details.
License
This project is licensed under the MIT License. See the LICENSE file for details.
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 Distribution
Built Distribution
File details
Details for the file ansilib-1.0.0.tar.gz
.
File metadata
- Download URL: ansilib-1.0.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66d77158fb8e7de2ea90d0383c61b104a59d54407b585e0288e248bdbdb7fa2 |
|
MD5 | c735d3a7fbb9528f23558fa2fb75730e |
|
BLAKE2b-256 | b54815ec90228edb0e93fe6e02ab85d6ef74b5ba84d7e01999d8123accccf1ed |
File details
Details for the file AnsiLib-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: AnsiLib-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aca4efc51d8a270c311238862e2891ae9f6bdf9102339e1b7779a3089c1518d |
|
MD5 | cdd4d7be03b6a40b22ad725fdf1c793b |
|
BLAKE2b-256 | 9623459368910a08020e16fa6e5bb2c842e96a6f37ba234c14edc25dcfee9d56 |