Skip to main content

ANSI escape sequences to format printed strings

Project description

AnsiFmt

ANSI escape sequences to format strings that are printed to terminal.

Usage

import AnsiFmt as fmt

string = "Hello, world"

# Print the string with underline
print(fmt.underline(string))

# Set it to have red background
print(fmt.bg(string, 1))

# Color can be either an integer, a hex color string or a tuple of (red, green, blue)
print(fmt.fg(string, '#3cde2f'))

# Formats can be nested since each function returns a formatted string
print(fmt.bg(fmt.fg(fmt.bold(string), 4), 15))

preview

Functions

  • bg(str, color)
  • fg(str, color)
  • blink(str)
  • bold(str)
  • dim(str)
  • double_underline(str)
  • hide(str)
  • invert(str)
  • italic(str)
  • overline(str)
  • strike(str)
  • underline(str)

color can either be an integer of ANSI color codes, a hex color string, or a tuple of (red, green, blue) values.

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

ansifmt-0.1.0.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

ansifmt-0.1.0-py3-none-any.whl (3.3 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