# 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](https://github.com/boraboyacioglu-itu)
## Installation
To install AnsiLib, use pip:
```sh
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
```python
import AnsiLib as al
```
You can use the quick styles and colors to simply format your text.
```python
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.
```python
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.
```python
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()`.
```python
print(al.available())
```
Create an RGB color using `al.color()` function.
```python
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.
```python
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](LICENSE.txt) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/boraboyacioglu-itu/ansilib",
"name": "AnsiLib",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": null,
"keywords": null,
"author": "Bora Boyac\u0131o\u011flu",
"author_email": "boyacioglu20@itu.edu.tr",
"download_url": "https://files.pythonhosted.org/packages/1d/a7/0ee0f87a85bcca62b8cb49606f2027580e24f34cc8255373a18ef23c9f61/AnsiLib-1.0.2.tar.gz",
"platform": null,
"description": "# AnsiLib\n\nAnsiLib is a Python module for handling text style and color shortcuts from ANSI escape codes.\n\n**Author:** Bora Boyac\u0131o\u011flu\n* E-Mail: boyacioglu20@itu.edu.tr\n* GitHub: [@boraboyacioglu-itu](https://github.com/boraboyacioglu-itu)\n\n## Installation\n\nTo install AnsiLib, use pip:\n\n```sh\npip install ansilib\n```\n\nIf you are running Python 3.7 or below, you also need to install `typing_extensions`, which comes as a dependency. \n\n## Usage\n\n```python\nimport AnsiLib as al\n```\n\nYou can use the quick styles and colors to simply format your text.\n\n```python\nprint(al.s(\"This text is bold.\"))\nprint(al.r(\"This text is red.\"))\nprint(al.u(al.b(\"This text is underlined and blue.\")))\n```\n\nAlso you can reach all of the colors using `al.c` class.\n\n```python\nprint(al.c.t.r(\"This text is red.\"))\nprint(al.c.b.c(\"This text has cyan background.\"))\nprint(al.c.t.g_(\"This text is bright green.\"))\n```\n\nTo define styles, use `al.style()` function.\n\n```python\nsty1 = al.style('bold', 'r', 'kb1')\nprint(sty1(\"This text is bold, red and has a background color of bright black.\"))\n```\n\nGet the complete list of styles and colors with `al.available()`.\n\n```python\nprint(al.available())\n```\n\nCreate an RGB color using `al.color()` function.\n\n```python\nmy_color = al.color(56, 12, 74)\nsty2 = al.style('x', 'italic', my_color)\nprint(sty2(\"This text is italic, crossed and has an RGB color of (56, 12, 74).\"))\n```\n\nFinally, you can use the AnsiLib's `prints()` function to print a styled text.\n\n```python\nal.prints(\"This text is bold, red and has a background color of bright black.\", s=['bold', 'r', 'kb1'])\n```\n\n## Contributions\n\nI welcome contributions and suggestions to the AnsiLib Python library! Contact me about the details.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE.txt) file for details.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A library for handling ANSI codes",
"version": "1.0.2",
"project_urls": {
"Homepage": "https://github.com/boraboyacioglu-itu/ansilib"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6bac2eccdc8a35eb7b1eec36781e2f33a182f1dccf2bf1275729c6ea6bdefb94",
"md5": "d4befdf5c6cf0da698d88c4c864ae2c5",
"sha256": "9db390588fe906c00104070489aaac0acfbcea65687343514ba08b780a3575b4"
},
"downloads": -1,
"filename": "AnsiLib-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d4befdf5c6cf0da698d88c4c864ae2c5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5",
"size": 6778,
"upload_time": "2024-08-12T10:40:11",
"upload_time_iso_8601": "2024-08-12T10:40:11.056600Z",
"url": "https://files.pythonhosted.org/packages/6b/ac/2eccdc8a35eb7b1eec36781e2f33a182f1dccf2bf1275729c6ea6bdefb94/AnsiLib-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1da70ee0f87a85bcca62b8cb49606f2027580e24f34cc8255373a18ef23c9f61",
"md5": "2e1005c11e0df491e4849669a1a30b63",
"sha256": "6d3a14d600160f0b36cdd035838c4e5b2994996475478adda71aa2c4e7df9ff9"
},
"downloads": -1,
"filename": "AnsiLib-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "2e1005c11e0df491e4849669a1a30b63",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 6024,
"upload_time": "2024-08-12T10:40:12",
"upload_time_iso_8601": "2024-08-12T10:40:12.979704Z",
"url": "https://files.pythonhosted.org/packages/1d/a7/0ee0f87a85bcca62b8cb49606f2027580e24f34cc8255373a18ef23c9f61/AnsiLib-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-12 10:40:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "boraboyacioglu-itu",
"github_project": "ansilib",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ansilib"
}