loop

If you’re using the state management features of clubsandwich, you might want to look at DirectorLoop instead. This is its superclass.

class clubsandwich.blt.loop.BearLibTerminalEventLoop(fps=72)
Parameters:fps (Real) – After each loop iteration, BearLibTerminalEventLoop waits 1/fps seconds before checking for input and updating again.

Simple wrapper around BearLibTerminal and asyncio.

Subclass terminal_init(), terminal_read(), and terminal_update(). Instantiate your class and call its run() method.

Example:

from bearlibterminal import terminal
from clubsandwich.blt.loop import BearLibTerminalEventLoop
i = 0
j = 0
class MyDemo(BearLibTerminalEventLoop):
    def terminal_update(self):
        global i
        global j
        terminal.put(j, 0, str(i))
        i = (i + 1) % 10
        j = (j + 1) % 11
        return True  # this is important!

MyDemo().run()
loop_until_terminal_exits()
run()

Start the event loop.

run_loop_iteration()
terminal_init()

Terminal has just been opened. You should configure it with terminal.set().

terminal_read(char)
Parameters:char (str) – Return value of BearLibTerminal.terminal.read()

Called whenever new input is available.

terminal_update()
Returns:True if another loop should be run, False if the loop should exit

Update the view. Fires once per frame regardless of whether there was any input. Make sure you return True to continue each loop iteration! (If you are using DirectorLoop, this is already taken care of.)