https://github.com/getcuia/cusser
🤬 A curses wrapper that understands ANSI escape code sequences
https://github.com/getcuia/cusser
ansi ansi-escape-codes cli command-line console cuia curses cusser ncurses pdcurses python terminal tui
Last synced: about 1 year ago
JSON representation
🤬 A curses wrapper that understands ANSI escape code sequences
- Host: GitHub
- URL: https://github.com/getcuia/cusser
- Owner: getcuia
- License: mit
- Created: 2021-11-22T19:49:25.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-25T19:34:45.000Z (almost 2 years ago)
- Last Synced: 2025-03-28T06:51:07.753Z (about 1 year ago)
- Topics: ansi, ansi-escape-codes, cli, command-line, console, cuia, curses, cusser, ncurses, pdcurses, python, terminal, tui
- Language: Python
- Homepage: https://pypi.org/project/cusser/
- Size: 344 KB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pypi.org/project/cusser/)
[](https://github.com/getcuia/cusser/actions/workflows/python-package.yml)
[](https://github.com/getcuia/cusser/blob/main/LICENSE)
# [cusser](https://github.com/getcuia/cusser#readme) 🤬
> A curses wrapper that understands ANSI escape code sequences
cusser is a lightweight Python package for teaching
[curses](https://docs.python.org/3/library/curses.html) how to use
[ANSI escape code sequences](https://en.wikipedia.org/wiki/ANSI_escape_code). It
works by wrapping the curses standard window object and intercepting escape code
sequences.
## Features
- ♻️ Easily integrate with the
[standard `curses` module](https://docs.python.org/3/library/curses.html)
- 🕹️ Use the same escape code sequences
[as you would with Colorama](https://github.com/tartley/colorama#recognised-ansi-sequences)
- 🖍️ Only one dependency: [stransi](https://github.com/getcuia/stransi) (for
actuallly parsing escape code sequences)
- 🐍 Python 3.8+
## Installation
```console
$ pip install cusser
```
## Usage
```python
In [1]: import curses
In [2]: from cusser import Cusser
In [3]: def app(stdscr) -> None:
...: """Start a new application."""
...: if not isinstance(stdscr, Cusser):
...: stdscr = Cusser(stdscr)
...:
...: ultra_violet = (100, 83, 148)
...: x, y = 34, 12
...: stdscr.addstr(
...: f"\033[2J\033[{x};{y}H"
...: "\033[1;32mHello "
...: f"\033[;3;38;2;{';'.join(map(str, ultra_violet))}m"
...: "cusser"
...: "\033[m 🤬!"
...: )
...: stdscr.refresh()
...: stdscr.getch()
...:
In [4]: curses.wrapper(app)
```

## Credits
[Photo](https://github.com/getcuia/cusser/raw/main/banner.jpg) by
[Gwendal Cottin](https://unsplash.com/@gwendal?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
on
[Unsplash](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText).