Metadata-Version: 2.1
Name: ColorfulOutput
Version: 0.0.1
Summary: Adds colors to your console prints.
Home-page: https://github.com/RasseTheBoy/ColorfulOutput
Author: Rasmus Ohert
Author-email: Rasmus Ohert <rassemichael@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Rasse
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Repository, https://github.com/RasseTheBoy/ColorfulOutput
Keywords: python,console,colors,print
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Education
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.5
Description-Content-Type: text/markdown
License-File: LICENSE

ColorfulOutput
=============

<p align="center">
    <img src="Images/Logo/ColorfulOutputLogo.png" width=500>
</p>

A python library that adds colors to your console prints.

# Author

- [@RasseTheBoy](https://github.com/RasseTheBoy)

# Installation

```bash
pip install ColorfulOutput
# or
pip3 install ColorfulOutput
```

# Usage

The library contains methods that you can use to color your **console** text.  
[**These "colored" strings should only be used for console prints, and not for anything else!**](#known-issues)

```python
import ColorfulOutput as cc

text = cc.HEADER("Hello World!")
print(text)
```

```python
from ColorfulOutput import BLUE, RED

print(BLUE("This is all blue text!"))
print(RED("This is all red text!"))
```

```python
from ColorfulOutput import CYAN, YELLOW, RED, BOLD, UNDERLINE

text = f'{BOLD("Never")} {YELLOW("gonna")} {UNDERLINE("give")} {RED("you")} {CYAN("up")}!'

print(text)
```

# Methods

- `HEADER(text)`
- `BLUE(text)`
- `CYAN(text)`
- `GREEN(text)`
- `YELLOW(text)`
- `RED(text)`
- `BOLD(text)`
- `UNDERLINE(text)`

# Known issues!

## Repr

The methods will return a text string that seems like a normal text to the console, but it is actually a string with special characters that makes the text colored. This means that when you use the `repr()` function, it will return a string with special characters instead of the actual text.

This also means that when you use the `!r` format specifier, it will return a string with special characters instead of the actual text.

```python
from ColorfulOutput import BLUE

clean_text = "Hello World!"
color_text = BLUE(clean_text)

print(repr(clean_text))
# Output: 'Hello World!'

print(f'{clean_text!r}')
# Output: 'Hello World!'

print(repr(color_text))
# Output: '\x1b[94mHello World!\x1b[0m'

print(f'{color_text!r}')
# Output: '\x1b[94mHello World!\x1b[0m'
```

## Writing to files

When you write the colored text to a file, it will write the special characters to the file instead of the actual text.

```python
from ColorfulOutput import BLUE

clean_text = "Hello World!"
color_text = BLUE(clean_text)

with open("file.txt", "w") as file:
    file.write(clean_text)
    file.write(color_text)
```

`file.txt:`
```
Hello World!
[94mHello World![0m
```

## Length

The special characters will also be counted as characters when you use the `len()` function.

```python
from ColorfulOutput import BLUE

clean_text = "Hello World!"
color_text = BLUE(clean_text)

print(len(clean_text))
# Output: 12

print(len(color_text))
# Output: 21
```

## Adding multiple colors and styles

When you add multiple colors and styles to a string, it will not work as expected.

```python
from ColorfulOutput import BLUE, BOLD, UNDERLINE

text = BLUE("Hello ")
text += BOLD("World!")

full_text = UNDERLINE(text)

print(full_text)
```

`Console output:`  
![Console output](Images/Other/invalid_output.png)


# Workarounds

The only workaround for most of these issues is to create a "clean" string that only contains the text (as shown in the examples above).  
Then a separate "color" string that contains the text with the colors and styles.

# Future

All of these issues will be fixed in the future, but for now, you will have to use the workarounds.

If you any suggestions or issues, please let me know!
