A curses wrapper that understands ANSI escape code sequences
Project description
cusser 🤬
A curses wrapper that understands ANSI escape code sequences
cusser is a lightweight Python package for teaching curses how to use ANSI escape code sequences. It works by wrapping the curses standard window object and intercepting escape code sequences.
Features
- ♻️ Easily integrate with the
standard
curses
module - 🖍️ Only one dependency: stransi (for actuallly parsing escape code sequences)
- 🐍 Python 3.8+
Installation
$ pip install cusser
Usage
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[22;38;2;{';'.join(map(str, ultra_violet))}m"
...: "cusser"
...: "\033[0m 🤬!"
...: )
...: stdscr.refresh()
...: stdscr.getch()
...:
In [4]: curses.wrapper(app)
Credits
Photo by Gwendal Cottin on Unsplash.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cusser-0.1.0.tar.gz
(7.8 kB
view hashes)
Built Distribution
cusser-0.1.0-py3-none-any.whl
(8.1 kB
view hashes)