Skip to main content

A terminal interface that abstracts it into a tilemap with 3 bit rgb support for charecter fore/background.

Project description

PyTerm

This is a cross-platform terminal abstraction that converts a tile map to a non-flickering terminal output with 3 bit rgb support using escape codes. It also has significant amounts of input automation for things like typing and movement. It clocks in at around 26.5k bytes (k is 1024) and has no significant dependencies outside of the Python Standard Library (other than evdev for linux input but it handles the lack of this automatically).


  • Install with "pip install PyTermint"
  • Import as "import PyTerm"
  • Create a init() function that takes screen and returns the inital state of the tile map (a list of lists addresable as arr[y][x] or [y0 [x0, x1, x2...], y1 [x0, x1, x2...]...]), a dictionary holding all variables that should persist after the end of a frame and a optional command string
  • Create a tick() command that takes as inputs tick(screen, vars, keys). Screen is an array, vars is the dict you initialized in init and keys which is a set of every key thats pressed
  • Call the run(tick_func, init_func)

mport PyTerm as pt
from PyTerm import clear, blit, color, TILE_SET, HEIGHT, WIDTH, pressed

def init(screen):
    return (screen, {
        'text': '', 
        'cpos': (0, 0),  
    })

def tick(screen, v, keys):
    pt.clear(screen, pt.color(0, bg=1)) 
    pt.handle_input(v, keys)
    if "alt" in keys and "q" in keys: return "quit"
    pt.blit(screen, pt.str_to_arr(v["text"], pt.color(0)), 0, 0)
    # Cursor rendering
    x, y = v['cpos']
    if pt.inside(screen, (x, y)):
        screen[y][x] = pt.color(8, fg=1, bg=2)

if __name__ == "__main__":
    pt.run(tick, init, False)
  • A small text editor for PyTerm

GitHub Home page link

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

pytermint-0.0.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytermint-0.0.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file pytermint-0.0.2.tar.gz.

File metadata

  • Download URL: pytermint-0.0.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pytermint-0.0.2.tar.gz
Algorithm Hash digest
SHA256 09bc69e6995cf6dae566e3e41e31eeeb364b5be876f33c1983fc7c3aa5da1046
MD5 ca24b0ed935a606d213d95d7d4ebcf4e
BLAKE2b-256 51ac0b4748a23a368521134a67b012f3147d7b0f21c120514f66e27d36ed0508

See more details on using hashes here.

File details

Details for the file pytermint-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pytermint-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pytermint-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 76c91090c4ce07c9f9a50d3556b60ab40cd3734a3a2b0094170666589ad4e186
MD5 d342b8960cbc015c2d7f99a749b3491e
BLAKE2b-256 3c4fe9ccef13f5cb30f0dd00820e14f1e7d9e7699bfc622cda90c9399003a7ae

See more details on using hashes here.

Supported by

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