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)

import 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.3.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.3-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytermint-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4701b26ee563a9312e6a6ef79fe9a3b90fee484ef6804eccf759a296ba1a5f64
MD5 5588a4d802d84c750dee98303e50f91f
BLAKE2b-256 3de3aa286a2b41da8589825320baea59fe1c1b904e34a5f46becf8529de43a1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytermint-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32c0ed2e8c4bbf7e2f91ce934e61425b4b3bd81e596c3227045220cf90fa2f55
MD5 c8466992ca73a6379a7aac5ba8e38919
BLAKE2b-256 0a9ceb5f7065768afcbecd9fc99665364ee685016c3c199b9e57025a599b7a73

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