256 Color Terminal Text Formatter
Project description
bruhcolor
What is bruhcolor you may ask?
bruhcolor is a terminal coloring package similar to termcolor with some differences.
First, bruhcolor supports 256 colors (given your terminal can supoprt that). Along with this, it offers a few more options for customizing the text compared to termcolor.
Another major difference is the the use of a wrapper class, rather than returning the escape-sequenced string. When using python's len()
method on this color-coded strings, it would return a length that included the escape charcaters. Perhaps this is intended in one use case, but for mine it was not. Thus, a wrapper class was made. This wrapper class can give back the length of the pre-colored text when using python's len()
method. ALong with this, using something like a f-string
could be trouble some . . . again given the fact the length of a colored string is significantly longer than the orginal text. The wrapper class allows for better formatting with f-strings
, allowing the formatter to treat the colored text the same as it would the original, unmodified version.
Installation
From PyPI
python -m pip install --upgrade bruhcolor
From source
git clone https://github.com/ethanlchristensen/bruhcolor
cd bruhcolor
python -m pip install .
Example / Usage
import bruhcolor
# Display all of the color codes
bruhcolor.colors()
# Simple test message
test_1 = bruhcolor.bruhcolored("Hello World from bruhcolor!", color=24)
print(test_1)
# Support mult repition
print(test_1 * 5)
print()
# More in depth example
test_2 = bruhcolor.bruhcolored("Hello World from bruhcolor!", color=24, on_color=196, attrs=['blink', 'reverse', 'italic'])
print(test_2)
print()
test_3 = test_1 + test_2
print(test_3)
test_3 += "How are you doing?"
print(test_3)
print()
# Getting lengths
print(len(test_1))
print(len(test_2))
print(len(test_3))
- Color Codes: 0 - 255
- Highlight Codes: 0 - 255
- Attributes: blink, reverse, bold, crossed-out, italic, underline, dark, concealed
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
Hashes for bruhcolor-0.0.47-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31a913f00dcc86fca913e531fdd13de1c903eb0c77180e495b19027c7fe16b19 |
|
MD5 | 16faa2fcbd79ff49f18a5e8cf31bb03d |
|
BLAKE2b-256 | bf6aad86589b11c84d9e741eb4d9d0e82372a56441ca20bd3cba6bdabae01319 |