Metadata-Version: 2.5
Name: colook
Version: 1.1.3
Summary: Basic terminal printing: colors, RGB, styles, formatting, and encrypted printing.
Author-email: gotadijo <gotadijo@gmail.com>
License: MIT
Keywords: ansi,color,colorama,format,print,rgb,terminal
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Terminals
Requires-Python: >=3.8
Requires-Dist: basic-crypt
Requires-Dist: colorama
Description-Content-Type: text/markdown

# colook

Basic terminal printing: named colors, 24-bit RGB, text styles, an
extended `format()` helper, and encrypted printing.

## Installation

```bash
pip install colook
```

## Quickstart

```python
import colook as ck

# print with named colors and styles
ck.print("hello", color="green", styles=["bold", "underline"])
ck.print("warning!", color=ck.Color.BRIGHT_YELLOW)

# 24-bit RGB foreground / background
ck.print("hot pink", color="rgb(255, 105, 180)")
ck.print("highlight", bg=ck.bg_rgb(255, 200, 0))

# raw escape helpers
print(ck.fg(ck.Color.CYAN) + "cyan" + ck.RESET)

# formatted templating with style suffixes
print(ck.format("{name:bold+red} scored {points:>6:cyan}", name="ada", points=42))

# encrypted printing (via basic_crypt)
ck.secure_print("top secret", key="hunter2")          # e.g. 8f3ac2e4...
ck.decrypt_print("8f3ac2e4...", key="hunter2")        # top secret
```

## Colors

`Color` is an `IntEnum` of the standard ANSI palette: `BLACK`, `RED`,
`GREEN`, `YELLOW`, `BLUE`, `MAGENTA`, `CYAN`, `WHITE` plus the
`BRIGHT_*` variants. Colors are accepted everywhere as a `Color`
member, a name string (`"red"`, `"bright-red"`), an
`"rgb(r, g, b)"` string, or a raw SGR code.

| Function | Description |
|---|---|
| `fg(color)` | Foreground sequence for a named color or code |
| `bg(color)` | Background sequence (31 -> 41, 91 -> 101) |
| `fg_rgb(r, g, b)` | 24-bit foreground sequence (`38;2`) |
| `bg_rgb(r, g, b)` | 24-bit background sequence (`48;2`) |
| `RESET` | Reset-everything escape string |

Components outside 0-255 raise `ValueError`.

## Styles

`Style` is an `IntEnum` with `BOLD`, `DIM`, `ITALIC`, `UNDERLINE`,
`BLINK`, `REVERSE`, `HIDDEN`, and `STRIKETHROUGH`.

| Function | Description |
|---|---|
| `style(*styles)` | Combined sequence, e.g. `style("bold", Style.UNDERLINE)` -> `ESC[1;4m` |

## Formatting

`styled(text, *, color=None, bg=None, styles=None)` wraps a string in
escape sequences and appends `RESET`; with no arguments it returns the
text unchanged.

`format(template, ...)` works exactly like `str.format` plus an
optional style suffix after an extra colon in the format spec. Tokens
are joined with `+` and may be color names, style names, or
`rgb(r, g, b)`:

```python
ck.format("{value}", value=1)                    # "1"
ck.format("{msg:red}", msg="hi")                 # red "hi"
ck.format("{n:>6:bold+cyan}", n=42)              # right-aligned, bold cyan
ck.format("{hex:rgb(255, 105, 180)}", hex="ff69b4")
```

Specs that only look like styles (e.g. `"{t:%H:%M}"` for datetimes)
are left untouched. `print(...)` mirrors `builtins.print` and accepts
the same `color` / `bg` / `styles` keywords as `styled`.

On Windows, importing `colook` fixes up the console via
[colorama](https://pypi.org/project/colorama/)'s
`just_fix_windows_console()`: it enables virtual-terminal processing
on modern consoles and translates ANSI sequences into Win32 calls on
legacy ones, so colors render everywhere including PowerShell 5.1
(`enable_vt()` is also exported for manual use).

## Encrypted printing

Built on `basic_crypt` symmetric ciphers; ciphertext is printed as
hex so it always survives a terminal:

| Function | Description |
|---|---|
| `encrypt_line(text, key, cipher="rc4")` | Encrypt and return hex |
| `decrypt_line(blob, key, cipher="rc4")` | Decrypt hex back to text |
| `secure_print(text, key, ...)` | Encrypt, then print the hex line |
| `decrypt_print(blob, key, ...)` | Decrypt, then print the plaintext |

`cipher` may be `"rc4"` or `"xor"`; keys may be `str` or bytes-like.
Both print helpers accept the usual `color` / `bg` / `styles` / `file`
keywords.

## API overview

| Name | Kind |
|---|---|
| `Color`, `Style` | `IntEnum` palettes |
| `fg`, `bg`, `fg_rgb`, `bg_rgb`, `style`, `RESET` | escape-sequence helpers |
| `styled`, `format`, `print` | formatting helpers |
| `secure_print`, `decrypt_print`, `encrypt_line`, `decrypt_line` | encrypted printing |

Everything is re-exported at the package root: `import colook as ck`.

