Textfiles

Looking for VT100 documentation, I found a folder of textfiles VT100 animations, including the classic Bambi vs. Godzilla.

Slightly difficult to watch on any modern computer, so save this script: (works on Mac & other Unix-likes, wtf knows what Windows does for clear and reset.)

Use: % slowblade.py ~/Downloads/bambi_godzila.txt 500

slowblade.py: [update 2022-04-18, stdin for "-"]

#!/usr/bin/env python3

import os, sys, time

def slowblade(f, spd):
    try:
        os.system("clear")
        if f == "-":
            text = sys.stdin.read()
        else:
            text = open(f, encoding='Windows-1252').read()
        for c in text:
            sys.stdout.write(c); sys.stdout.flush()
            time.sleep(1.0/spd)
        print("")
    except (IOError, EOFError):
        pass
    finally:
        os.system("sleep 10; reset")

if __name__ == "__main__":
    if len(sys.argv) == 1: raise Exception("Usage: slowblade.py FILENAME [SPEED (default 100)]")
    else: slowblade(sys.argv[1], int(sys.argv[2]) if len(sys.argv) >= 3 else 100)