Name | khx-colory JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | A rich terminal printing library for colorful text, lines, banners, and highlights |
upload_time | 2025-09-03 03:21:34 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT |
keywords |
color
console
rich
styling
terminal
text
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# KHX Colory ๐
A lightweight, user-friendly Python library for creating colorful and styled terminal output with minimal dependencies and high performance.
[](https://www.python.org/downloads/)
[](LICENSE)
[](https://pypi.org/project/khx-colory/)
## โจ Features
- **๐จ Rich Color Support**: Standard ANSI colors, bright colors, and full RGB (24-bit) color support
- **๐ซ Text Styling**: Bold, italic, underline, strikethrough, and more
- **๐ Style Combinations**: Mix multiple styles together (e.g., bold + italic + underline)
- **๐ High Performance**: Lightweight with minimal dependencies
- **๐ Cross-Platform**: Works on Windows, macOS, and Linux
- **๐ฏ User-Friendly API**: Intuitive and easy-to-use interface
- **๐ Well Documented**: Comprehensive documentation and examples
- **๐งช Fully Tested**: Extensive test coverage
- **๐ง Extensible**: Easy to customize and extend
## ๐ Quick Start
### Installation
```bash
pip install khx-colory
```
### Basic Usage
```python
from khx_colory import colored, print_colored
# Simple colored text
print(colored("Hello World!", "red"))
# Styled text
print(colored("Bold text", style="bold"))
# Combine color and style
print(colored("Bold red text", "red", style="bold"))
# Background colors
print(colored("Text with background", "white", bg_color="blue"))
# Print directly
print_colored("This prints directly in green", "green")
# RGB colors
print(colored("RGB color text", color=(255, 100, 50)))
# Multiple styles
print(colored("Bold italic underlined", style="bold+italic+underline"))
```
### Using the Main Class
```python
from khx_colory import Colory
# Create a Colory instance
colory = Colory()
# Print colored text
colory.print_text("Hello!", "blue", style="bold")
# Get colored string
text = colory.colored_text("Styled text", "green", style="italic")
print(text)
# Create ColorText objects
color_text = colory.create_text("Custom text", "magenta", style="underline")
print(color_text)
```
## ๐จ Available Colors
### Standard Colors
- `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
### Bright Colors
- `bright_black`, `bright_red`, `bright_green`, `bright_yellow`
- `bright_blue`, `bright_magenta`, `bright_cyan`, `bright_white`
### RGB Colors
```python
# Using RGB tuples
colored("RGB text", color=(255, 0, 128))
# Using hex colors
from khx_colory import ColorRGB
rgb_color = ColorRGB.from_hex("#FF0080")
colored("Hex color text", color=rgb_color)
```
## ๐ซ Available Styles
- `normal` - Reset to normal text
- `bold` - Bold/bright text
- `dim` - Dimmed text
- `italic` - Italic text (not supported on all terminals)
- `underline` - Underlined text
- `blink` - Blinking text
- `reverse` - Reverse/invert colors
- `strikethrough` - Strikethrough text
### Style Combinations
```python
# Multiple styles can be combined with '+' or spaces
colored("Multi-styled text", style="bold+italic+underline")
colored("Multi-styled text", style="bold italic underline")
```
## ๐ง Advanced Usage
### ColorText Objects
```python
from khx_colory import ColorText
# Create ColorText objects for more control
text = ColorText("Hello", fg_color="red", bg_color="yellow", style="bold")
print(text.render())
# Concatenate ColorText objects
text1 = ColorText("Hello ", "red")
text2 = ColorText("World!", "blue")
combined = text1 + text2
print(combined)
# Copy and modify
modified = text.copy(text="Modified", fg_color="green")
print(modified)
```
### Convenience Functions
```python
from khx_colory import red, green, blue, bold, italic, underline
# Color convenience functions
print(red("Red text"))
print(green("Green text"))
print(blue("Blue text", style="bold"))
# Style convenience functions
print(bold("Bold text"))
print(italic("Italic text"))
print(underline("Underlined text", color="red"))
```
### Color Detection and Control
```python
from khx_colory import Colory, set_color_enabled, is_color_enabled
# Check if colors are supported
colory = Colory()
print(f"Color supported: {colory.is_color_enabled()}")
# Disable colors globally
set_color_enabled(False)
# Force enable colors
colory = Colory(force_color=True)
```
## ๐ฅ๏ธ Command Line Interface
KHX Colory includes a CLI for testing and demonstration:
```bash
# Show all available colors and styles
colory demo
# Show only colors
colory demo --colors
# Show only styles
colory demo --styles
# Print colored text
colory print "Hello World" red
colory print "Bold text" blue bold
colory print "Background" white --bg-color red
# List available colors or styles
colory list colors
colory list styles
# Disable colors
colory --no-color demo
```
## ๐ API Reference
### Core Classes
#### `Colory`
Main class for colorful terminal output.
```python
Colory(auto_reset=True, force_color=None)
```
**Methods:**
- `colored_text(text, color=None, bg_color=None, style=None)` - Create colored text string
- `print_text(text, color=None, bg_color=None, style=None, **kwargs)` - Print colored text
- `create_text(text, color=None, bg_color=None, style=None)` - Create ColorText object
- `get_available_colors()` - Get list of available colors
- `get_available_styles()` - Get list of available styles
- `demo_all()` - Show comprehensive demo
#### `ColorText`
Represents colored and styled text.
```python
ColorText(text, fg_color=None, bg_color=None, style=None)
```
**Methods:**
- `render()` - Get text with ANSI escape sequences
- `copy(**kwargs)` - Create a copy with modifications
- `__str__()` - Returns rendered text
- `__len__()` - Returns length of text content
#### `Color`
Standard ANSI color representation.
```python
Color(name) # e.g., Color("red")
```
**Methods:**
- `fg()` - Get foreground color escape sequence
- `bg()` - Get background color escape sequence
- `available_colors()` - Class method to get available colors
#### `ColorRGB`
RGB color representation for 24-bit color.
```python
ColorRGB(r, g, b) # e.g., ColorRGB(255, 0, 128)
```
**Methods:**
- `fg()` - Get RGB foreground escape sequence
- `bg()` - Get RGB background escape sequence
- `to_hex()` - Convert to hex string
- `from_hex(hex_color)` - Class method to create from hex
### Utility Functions
- `colored(text, color=None, bg_color=None, style=None)` - Create colored text string
- `print_colored(text, color=None, bg_color=None, style=None, **kwargs)` - Print colored text
- `get_available_colors()` - Get list of available colors
- `get_available_styles()` - Get list of available styles
- `strip_ansi(text)` - Remove ANSI escape sequences from text
- `get_text_length(text)` - Get display length ignoring ANSI codes
## ๐งช Testing
Run the test suite:
```bash
# Install development dependencies
pip install -e .[dev]
# Run tests
pytest
# Run tests with coverage
pytest --cov=khx_colory
# Run specific tests
pytest tests/test_text.py -v
```
## ๐ค Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
### Development Setup
```bash
# Clone the repository
git clone https://github.com/KHADER/khx-colory.git
cd khx-colory
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in development mode
pip install -e .[dev]
# Run tests
pytest
# Format code
black src tests
isort src tests
# Type checking
mypy src
```
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- Inspired by the need for simple, lightweight terminal coloring
- Thanks to the Python community for excellent tools and libraries
- Special thanks to contributors and users who provide feedback
## ๐ Support
- ๐ง **Email**: khader@example.com
- ๐ **Issues**: [GitHub Issues](https://github.com/KHADER/khx-colory/issues)
- ๐ฌ **Discussions**: [GitHub Discussions](https://github.com/KHADER/khx-colory/discussions)
---
Made with โค๏ธ by KHADER
Raw data
{
"_id": null,
"home_page": null,
"name": "khx-colory",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "color, console, rich, styling, terminal, text",
"author": null,
"author_email": "KHADER <khader@example.com>",
"download_url": "https://files.pythonhosted.org/packages/d0/d7/fd86a111218e36ae470be566fe4dc6534140b9f5a278ace6b31a58c8e392/khx_colory-0.1.0.tar.gz",
"platform": null,
"description": "# KHX Colory \ud83c\udf08\n\nA lightweight, user-friendly Python library for creating colorful and styled terminal output with minimal dependencies and high performance.\n\n[](https://www.python.org/downloads/)\n[](LICENSE)\n[](https://pypi.org/project/khx-colory/)\n\n## \u2728 Features\n\n- **\ud83c\udfa8 Rich Color Support**: Standard ANSI colors, bright colors, and full RGB (24-bit) color support\n- **\ud83d\udcab Text Styling**: Bold, italic, underline, strikethrough, and more\n- **\ud83d\udd17 Style Combinations**: Mix multiple styles together (e.g., bold + italic + underline)\n- **\ud83d\ude80 High Performance**: Lightweight with minimal dependencies\n- **\ud83c\udf0d Cross-Platform**: Works on Windows, macOS, and Linux\n- **\ud83c\udfaf User-Friendly API**: Intuitive and easy-to-use interface\n- **\ud83d\udcda Well Documented**: Comprehensive documentation and examples\n- **\ud83e\uddea Fully Tested**: Extensive test coverage\n- **\ud83d\udd27 Extensible**: Easy to customize and extend\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\npip install khx-colory\n```\n\n### Basic Usage\n\n```python\nfrom khx_colory import colored, print_colored\n\n# Simple colored text\nprint(colored(\"Hello World!\", \"red\"))\n\n# Styled text\nprint(colored(\"Bold text\", style=\"bold\"))\n\n# Combine color and style\nprint(colored(\"Bold red text\", \"red\", style=\"bold\"))\n\n# Background colors\nprint(colored(\"Text with background\", \"white\", bg_color=\"blue\"))\n\n# Print directly\nprint_colored(\"This prints directly in green\", \"green\")\n\n# RGB colors\nprint(colored(\"RGB color text\", color=(255, 100, 50)))\n\n# Multiple styles\nprint(colored(\"Bold italic underlined\", style=\"bold+italic+underline\"))\n```\n\n### Using the Main Class\n\n```python\nfrom khx_colory import Colory\n\n# Create a Colory instance\ncolory = Colory()\n\n# Print colored text\ncolory.print_text(\"Hello!\", \"blue\", style=\"bold\")\n\n# Get colored string\ntext = colory.colored_text(\"Styled text\", \"green\", style=\"italic\")\nprint(text)\n\n# Create ColorText objects\ncolor_text = colory.create_text(\"Custom text\", \"magenta\", style=\"underline\")\nprint(color_text)\n```\n\n## \ud83c\udfa8 Available Colors\n\n### Standard Colors\n- `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`\n\n### Bright Colors \n- `bright_black`, `bright_red`, `bright_green`, `bright_yellow`\n- `bright_blue`, `bright_magenta`, `bright_cyan`, `bright_white`\n\n### RGB Colors\n```python\n# Using RGB tuples\ncolored(\"RGB text\", color=(255, 0, 128))\n\n# Using hex colors\nfrom khx_colory import ColorRGB\nrgb_color = ColorRGB.from_hex(\"#FF0080\")\ncolored(\"Hex color text\", color=rgb_color)\n```\n\n## \ud83d\udcab Available Styles\n\n- `normal` - Reset to normal text\n- `bold` - Bold/bright text\n- `dim` - Dimmed text\n- `italic` - Italic text (not supported on all terminals)\n- `underline` - Underlined text\n- `blink` - Blinking text\n- `reverse` - Reverse/invert colors\n- `strikethrough` - Strikethrough text\n\n### Style Combinations\n```python\n# Multiple styles can be combined with '+' or spaces\ncolored(\"Multi-styled text\", style=\"bold+italic+underline\")\ncolored(\"Multi-styled text\", style=\"bold italic underline\")\n```\n\n## \ud83d\udd27 Advanced Usage\n\n### ColorText Objects\n\n```python\nfrom khx_colory import ColorText\n\n# Create ColorText objects for more control\ntext = ColorText(\"Hello\", fg_color=\"red\", bg_color=\"yellow\", style=\"bold\")\nprint(text.render())\n\n# Concatenate ColorText objects\ntext1 = ColorText(\"Hello \", \"red\")\ntext2 = ColorText(\"World!\", \"blue\")\ncombined = text1 + text2\nprint(combined)\n\n# Copy and modify\nmodified = text.copy(text=\"Modified\", fg_color=\"green\")\nprint(modified)\n```\n\n### Convenience Functions\n\n```python\nfrom khx_colory import red, green, blue, bold, italic, underline\n\n# Color convenience functions\nprint(red(\"Red text\"))\nprint(green(\"Green text\"))\nprint(blue(\"Blue text\", style=\"bold\"))\n\n# Style convenience functions\nprint(bold(\"Bold text\"))\nprint(italic(\"Italic text\"))\nprint(underline(\"Underlined text\", color=\"red\"))\n```\n\n### Color Detection and Control\n\n```python\nfrom khx_colory import Colory, set_color_enabled, is_color_enabled\n\n# Check if colors are supported\ncolory = Colory()\nprint(f\"Color supported: {colory.is_color_enabled()}\")\n\n# Disable colors globally\nset_color_enabled(False)\n\n# Force enable colors\ncolory = Colory(force_color=True)\n```\n\n## \ud83d\udda5\ufe0f Command Line Interface\n\nKHX Colory includes a CLI for testing and demonstration:\n\n```bash\n# Show all available colors and styles\ncolory demo\n\n# Show only colors\ncolory demo --colors\n\n# Show only styles \ncolory demo --styles\n\n# Print colored text\ncolory print \"Hello World\" red\ncolory print \"Bold text\" blue bold\ncolory print \"Background\" white --bg-color red\n\n# List available colors or styles\ncolory list colors\ncolory list styles\n\n# Disable colors\ncolory --no-color demo\n```\n\n## \ud83d\udcd6 API Reference\n\n### Core Classes\n\n#### `Colory`\nMain class for colorful terminal output.\n\n```python\nColory(auto_reset=True, force_color=None)\n```\n\n**Methods:**\n- `colored_text(text, color=None, bg_color=None, style=None)` - Create colored text string\n- `print_text(text, color=None, bg_color=None, style=None, **kwargs)` - Print colored text\n- `create_text(text, color=None, bg_color=None, style=None)` - Create ColorText object\n- `get_available_colors()` - Get list of available colors\n- `get_available_styles()` - Get list of available styles\n- `demo_all()` - Show comprehensive demo\n\n#### `ColorText`\nRepresents colored and styled text.\n\n```python\nColorText(text, fg_color=None, bg_color=None, style=None)\n```\n\n**Methods:**\n- `render()` - Get text with ANSI escape sequences\n- `copy(**kwargs)` - Create a copy with modifications\n- `__str__()` - Returns rendered text\n- `__len__()` - Returns length of text content\n\n#### `Color`\nStandard ANSI color representation.\n\n```python\nColor(name) # e.g., Color(\"red\")\n```\n\n**Methods:**\n- `fg()` - Get foreground color escape sequence\n- `bg()` - Get background color escape sequence\n- `available_colors()` - Class method to get available colors\n\n#### `ColorRGB`\nRGB color representation for 24-bit color.\n\n```python\nColorRGB(r, g, b) # e.g., ColorRGB(255, 0, 128)\n```\n\n**Methods:**\n- `fg()` - Get RGB foreground escape sequence\n- `bg()` - Get RGB background escape sequence\n- `to_hex()` - Convert to hex string\n- `from_hex(hex_color)` - Class method to create from hex\n\n### Utility Functions\n\n- `colored(text, color=None, bg_color=None, style=None)` - Create colored text string\n- `print_colored(text, color=None, bg_color=None, style=None, **kwargs)` - Print colored text\n- `get_available_colors()` - Get list of available colors\n- `get_available_styles()` - Get list of available styles\n- `strip_ansi(text)` - Remove ANSI escape sequences from text\n- `get_text_length(text)` - Get display length ignoring ANSI codes\n\n## \ud83e\uddea Testing\n\nRun the test suite:\n\n```bash\n# Install development dependencies\npip install -e .[dev]\n\n# Run tests\npytest\n\n# Run tests with coverage\npytest --cov=khx_colory\n\n# Run specific tests\npytest tests/test_text.py -v\n```\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.\n\n### Development Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/KHADER/khx-colory.git\ncd khx-colory\n\n# Create virtual environment\npython -m venv .venv\nsource .venv/bin/activate # On Windows: .venv\\Scripts\\activate\n\n# Install in development mode\npip install -e .[dev]\n\n# Run tests\npytest\n\n# Format code\nblack src tests\nisort src tests\n\n# Type checking\nmypy src\n```\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- Inspired by the need for simple, lightweight terminal coloring\n- Thanks to the Python community for excellent tools and libraries\n- Special thanks to contributors and users who provide feedback\n\n## \ud83d\udcde Support\n\n- \ud83d\udce7 **Email**: khader@example.com\n- \ud83d\udc1b **Issues**: [GitHub Issues](https://github.com/KHADER/khx-colory/issues)\n- \ud83d\udcac **Discussions**: [GitHub Discussions](https://github.com/KHADER/khx-colory/discussions)\n\n---\n\nMade with \u2764\ufe0f by KHADER\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A rich terminal printing library for colorful text, lines, banners, and highlights",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/KHADER/khx-colory#readme",
"Homepage": "https://github.com/KHADER/khx-colory",
"Issues": "https://github.com/KHADER/khx-colory/issues",
"Repository": "https://github.com/KHADER/khx-colory"
},
"split_keywords": [
"color",
" console",
" rich",
" styling",
" terminal",
" text"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "fcd90077add82b5dec4c2bf79bbf2f84b5a45e1d26cfcf4199f58c4f75826305",
"md5": "04bcac558905b462aa6a862e836d9a39",
"sha256": "d9b57e5c4c00fa69f81e16de4e08c764d831ae3f5c5536d4a225095068407631"
},
"downloads": -1,
"filename": "khx_colory-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "04bcac558905b462aa6a862e836d9a39",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 16568,
"upload_time": "2025-09-03T03:21:33",
"upload_time_iso_8601": "2025-09-03T03:21:33.760329Z",
"url": "https://files.pythonhosted.org/packages/fc/d9/0077add82b5dec4c2bf79bbf2f84b5a45e1d26cfcf4199f58c4f75826305/khx_colory-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d0d7fd86a111218e36ae470be566fe4dc6534140b9f5a278ace6b31a58c8e392",
"md5": "9e7906fadc0be29f43dfa387606fff90",
"sha256": "4b304eb315078ca44a417587a6578ee248855094ff8a75c3b2dfcf47c9490386"
},
"downloads": -1,
"filename": "khx_colory-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "9e7906fadc0be29f43dfa387606fff90",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 24101,
"upload_time": "2025-09-03T03:21:34",
"upload_time_iso_8601": "2025-09-03T03:21:34.828066Z",
"url": "https://files.pythonhosted.org/packages/d0/d7/fd86a111218e36ae470be566fe4dc6534140b9f5a278ace6b31a58c8e392/khx_colory-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-03 03:21:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "KHADER",
"github_project": "khx-colory#readme",
"github_not_found": true,
"lcname": "khx-colory"
}