Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AnsiLib-1.0.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

AnsiLib-1.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file AnsiLib-1.0.2.tar.gz.

File metadata

  • Download URL: AnsiLib-1.0.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for AnsiLib-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6d3a14d600160f0b36cdd035838c4e5b2994996475478adda71aa2c4e7df9ff9
MD5 2e1005c11e0df491e4849669a1a30b63
BLAKE2b-256 1da70ee0f87a85bcca62b8cb49606f2027580e24f34cc8255373a18ef23c9f61

See more details on using hashes here.

File details

Details for the file AnsiLib-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: AnsiLib-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for AnsiLib-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9db390588fe906c00104070489aaac0acfbcea65687343514ba08b780a3575b4
MD5 d4befdf5c6cf0da698d88c4c864ae2c5
BLAKE2b-256 6bac2eccdc8a35eb7b1eec36781e2f33a182f1dccf2bf1275729c6ea6bdefb94

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page