Skip to content

boraboyacioglu-itu/ansilib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages