Skip to main content

No project description provided

Project description

Termill

A command line utility library to print out multiple lines of text and replace them. It's simple to print out a single line and replace it by using a carriage return:

print("foo", end="\r")
print("bar")

but that doesn't work with multiple lines. But by utilising backspace characters and the width of the terminal, you can actually replace multiple lines.

This library is just to handle that, so that you can print out lines, flush them, then print out new lines ontop of the old ones. A simple demo is included (demo.py) that just prints out the current time for 5 seconds.

This was just thrown together as a proof of concept, so it's likely very buggy. This has also only been tested on my MacOS machine, with ZSH. I have no idea if this works anywhere else.

Why not curses?

I wanted to be able to monitor certain things and print out regular updates to the terminal. As far as I could tell (based on very very limited research) I could do that with curses, but it would have to take over the whole terminal.

I want to be able to print out few lines and update them, without having to take over the terminal, the idea being that I can see the history in my terminal right before running whatever is printing out updates.

Usage

import time

from termill import Termill

t = Termill()

t.write("line one")
t.write("line two")
t.write("line three")
t.flush()
time.sleep(1)
t.writelines(["line one has changed", "there will be no line three"])
t.flush()

Demo

demo.gif

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termill-0.2.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

termill-0.2.0-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file termill-0.2.0.tar.gz.

File metadata

  • Download URL: termill-0.2.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Darwin/19.5.0

File hashes

Hashes for termill-0.2.0.tar.gz
Algorithm Hash digest
SHA256 90118a378fe4a37dc148eebbd740ee6fc3943f0e55e09fb6804a1784fef24d6c
MD5 8b1f83d5a5857e6c382db198bdb9d165
BLAKE2b-256 639fec36738949315503ac02f51fbd23a9e25bd9b4e83312e5475abc29d1305b

See more details on using hashes here.

File details

Details for the file termill-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: termill-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Darwin/19.5.0

File hashes

Hashes for termill-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f058c5a399736955913e858518048ed4085614fb693e9cf614f17f6afd871673
MD5 76f733adcc69e4968a98b37abf8ae3ec
BLAKE2b-256 92209a45f03ffaa1507dc10718e2f069a6f0401bb02eee65ba72ad08361a020d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page