context

class clubsandwich.blt.context.BearLibTerminalContext

A class that acts like clubsandwich.blt.nice_terminal.terminal (you can use Point and Rect instead of separate ints), except:

  • It’s a class, so you have to instantiate it
  • It includes a context manager, translate(), that offsets all position-related calls.
  • Multiple calls to color() and bkcolor() with the same values are ignored, saving time in the C FFI bridge.

Example:

from clubsandwich.blt.context import BearLibTerminalContext
from clubsandwich.geom import Point

ctx = BearLibTerminalContext()
ctx.open()

a = Point(10, 10)
with ctx.translate(a):
  terminal.put(Point(0, 0), 'a')
  terminal.put(Point(1, 1), 'b')
terminal.refresh()
terminal.read()
terminal.close()
translate(offset_delta)

Inside this context manager, all put/print calls are offset by the given amount. If you nest these, they stack.