Skip to main content

256 Color Terminal Text Formatter

Project description

bruhcolor

Supported Python versions

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))

sample-run

  • Color Codes: 0 - 255
  • Highlight Codes: 0 - 255
  • Attributes: blink, reverse, bold, crossed-out, italic, underline, dark, concealed

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

bruhcolor-0.0.56.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

bruhcolor-0.0.56-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

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