Skip to main content

CURSES ANSI PARSER

INSTALLATION

pip install cansi

EXAMPLE

import curses
from cansi import Cansi


def event_loop(stdscr):
    curses.curs_set(0)  # hide the cursor
    cansi = Cansi(stdscr)
    lines = [
        "\033[1;32mThis line is bright GREEN\033[0m",
        "\033[1;31mThis line is bright RED\033[0m",
        "\033[0;32mThis line is GREEN\033[0m",
        "\033[0;31mThis line is RED\033[0m",
        "\033[1mThis line is BOLD\033[0m",
        "\033[4mThis line is BOLD\033[0m",
        "\033[5mThis line BLINKS\033[0m",
        "\033[7mThis line is REVERSE\033[0m",
        "\033[0KmThis line won't be displayed\033[0m",
        "\033[1;37mPress q to quit\033[0m",
    ]
    while True:
        for index, line in enumerate(lines):
            cansi.addstr(index, 0, line)
        if stdscr.getkey() == "q":
            break


curses.wrapper(event_loop)

REFERENCES

https://docs.python.org/3/howto/curses.html

https://docs.python.org/3/library/curses.html

https://www.perlmonks.org/bare/?node_id=215785

http://ascii-table.com/ansi-escape-sequences.php

https://notes.burke.libbey.me/ansi-escape-codes/

https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html

Metadata

Release files for cansi 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cansi 0.0.4
File Size Uploaded
cansi-0.0.4.tar.gz 5.1 kB Details

Release files / cansi-0.0.4.tar.gz

Download URL cansi-0.0.4.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4c1d70583c9042944614d79b5555b921d3f4f0bcc8c79e068b19336b458f811d
BLAKE2b-256 checksum
How to use checksums
02bd6096cf365593a821664ab843a753a8e343777f9e45549df375ff5c2a9515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.10

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page