Skip to content

Latest commit

 

History

History
120 lines (71 loc) · 3.67 KB

README.md

File metadata and controls

120 lines (71 loc) · 3.67 KB

Coquille

Palestine support banner

Coquille (IPA: /kɔ.kij/, english: 'shell' or 'typo') is a library that wraps terminal escape sequences to easily apply them to a stream.

Notes

Requires Python 3.9 or higher.

This library attempts to cover as many escape sequences as possible ; but it is not an exhaustive list, some might be missing. Also, you might find that few have no effect on your terminal emulator.

This library is based on the following resources:

Applications that use Coquille

Babble

Babble is a pretty visual noise generator TUI application. Its custom rendering engine is designed on top of Coquille!

Examples

Even though the examples are mostly showcasing SGR escape sequences (because they are pretty visible), Coquille can do more! See the documentation.

Coquille context manager

from coquille import Coquille

print("Hello World!")

# By default, the coquille wraps the standard output
with Coquille.new("fg_magenta", "italic") as coquille:
    print("Hello World, but in magenta and italic!")
    coquille.apply("bold")
    print("Now, with a touch of bold :D")

print("Oh, we are back to normal now...")

screenshot.png

Source code: examples/coquille_context/

write()

from coquille import write

print("Hello World!")

write("Hello World, but in magenta and italic!", "fg_magenta", "italic")

with open("examples/write/output.txt", "w") as my_file:
    write("A pretty Hello World in a file!", "fg_blue", "bold", file=my_file)

screenshot.png

Source code: examples/write/

Coquille.write()

from coquille import Coquille
from coquille.sequences import fg_truecolor

print("Normal Hello World!")

coquille = Coquille.new(fg_truecolor(128, 255, 0))
coquille.write("Colorful Hello World!")

screenshot.png

Source code: examples/coquille_write/

Install

Normal installation

pip install coquille

Dev installation

pip install coquille[dev]

This allows you to run the tests:

coverage run -m pytest

Then check the coverage:

coverage report -m

Documentation

Coming soon! 🚧

Related projects

If you like Coquille, you might want to check these projects as well:

  • Colorama: a simple cross-platform colored terminal text in Python, by Jonathan Hartley
  • Rich_: a Python library for rich text and beautiful formatting in the terminal, by Will McGugan
  • Dahlia: a simple text formatting package, inspired by the game Minecraft, by trag1c