Skip to main content

A simple ANSI color formatting library for Python.

Project description

colortype

colortype is a simple ANSI color formatting library for Python. It helps you easily apply colors, styles, and cursor controls in terminal applications.

Installation

You can install colortype via pip:

pip install colortype

Features

1. Foreground Colors

  • Standard colors: red, green, blue, yellow, purple, black, white
  • Light colors: light_red, light_green, light_blue, light_yellow, light_magenta, light_black, light_white

2. Background Colors

  • Standard and light background colors available with b_ prefix.

3. Text Styles

  • bold, dim, underline, blink, reverse

4. Cursor Control

  • [up], [down], [left], [right]
  • [delete_line] (New in v5.0a1!)
  • [down_to_first_character] or [dtfc]

5. RGB Support

Use custom RGB colors:

from colortype import rgbcolor
print(rgbcolor(255, 0, 0) + "Red Text" + "\033[0m")

Usage

from colortype import fore, back, style, goto, console

print(fore.red + "This is red text" + style.reset)
print(back.yellow + "This has a yellow background" + style.reset)
print(style.bold + "This is bold text" + style.reset)

Or use [tags] with console():

print(console("[red]This is red text[reset]"))
print(console("[b_yellow]Yellow background[reset]"))

Changelog (v5.0a1)

  • New Features:
    • [delete_line] for clearing current line.
    • [dtfc] moves down to the first character.
    • [dim] text style re-added.
  • Fixes:
    • console() issue resolved.
    • dim was missing and now restored.

Contact

Thank you for using colortype!

Changelog

[5.0.1] - Fix

Fixed

  • The module cannot import: This happen in version 5.0, it's doesn't have __init__.py.
  • NOTE: DON'T INSTALL THE VERSION 5.0.

[5.0] - Stable

Added

  • More SGR options: Now you can control your cursor with a new thing name 'cursor'.
  • 256-color: Add an options for 256-color (color256).

[5.0a1] - Pre-Release

Added

  • [delete_line]: Deletes the entire current line.
  • [down_to_first_character] / [dtfc]: Moves cursor to the first character of the next line.
  • [dim]: Re-added dim text style (previously removed by accident).
  • RGB support for custom foreground and background colors.

Fixed

  • console(): Fixed an issue causing incorrect replacements.
  • dim missing: dim style was accidentally removed and has been restored.
  • Remove duplicate regular: We accidentally add 2 reset (regular and reset).

[4.0] - Previous Release

Added

  • Support for light colors (e.g., light_red, light_blue).
  • Background colors with the b_ prefix (e.g., b_red).
  • console() function for easy text formatting.

Fixed

  • Improved performance of ANSI code replacements.

[3.0] - Major Update

Added

  • More refined color controls for text formatting.
  • Enhanced compatibility with different terminal emulators.

Fixed

  • Optimized performance for better rendering speed.

[3.0a1] - Major Improvements

Added

  • Cursor movement controls: [up], [down], [left], [right].
  • Text styles: bold, underline, blink, reverse, dim.

Fixed

  • Standardized ANSI codes to avoid compatibility issues.

[2.5]

Added

  • Additional text styling options.
  • More control over color formatting.

[2.0a1]

Added

  • Introduced basic ANSI styling features.
  • Implemented initial support for foreground colors.

[1.2]

Fixed

  • Addressed minor compatibility issues.
  • Improved handling of ANSI escape sequences.

[1.0]

Added

  • First stable release with core ANSI formatting features.

[1.0a1]

Added

  • Initial alpha release with basic color formatting.

[0.1a2]

Fixed

  • Early bug fixes and refinements.

[0.1a1]

Added

  • Prototype implementation of color formatting.

Thank you for using colortype! 🚀

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

colortype-5.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colortype-5.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file colortype-5.0.1.tar.gz.

File metadata

  • Download URL: colortype-5.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for colortype-5.0.1.tar.gz
Algorithm Hash digest
SHA256 38d8c3a059b2005ea5ffc33db6298a093bd65cf3e8103eaefc0a752aedde2172
MD5 2a133268163dedc599c446c33ba8579e
BLAKE2b-256 b550cd2b84194816837f434b6c03cefd280fc7aa83a3bebfd9a0d99f8abe2ccf

See more details on using hashes here.

File details

Details for the file colortype-5.0.1-py3-none-any.whl.

File metadata

  • Download URL: colortype-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for colortype-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88051aa2b3e4f527f72ca510fc2ea83e21ed99c4245e87e6032716691961b7b6
MD5 b992e5fb9fc3a4e76439cba7f9ba6a7e
BLAKE2b-256 06de83ecc746d1485e28e353e57b6512ee1935c34530564847285b8c387eb978

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page