beamtea_runtime (beamtea v0.1.2)

View Source

The event loop that owns the terminal and drives an Elm program.

This process is the one that initialises prim_tty, so it must be registered (prim_tty derives its reader/writer process names from the owner's registered name). beamtea:start/3 takes care of that.

Lifecycle:

  1. put the tty in raw mode, enter the alternate screen, hide cursor
  2. run init/1, render the first frame, arm the reader
  3. loop: decode input into keys, feed messages to update/2, run the returned commands, repaint
  4. on quit/eof/crash: show cursor, leave the alternate screen and restore cooked mode — always, via after

Summary

Functions

Run Prog to completion in the current (registered) process and return the final model. Called by beamtea:start/3.

Functions

run(Beamtea_prog, Flags, Opts)

-spec run(#beamtea_prog{init :: fun((term()) -> {term(), term()}),
                        update :: fun((term(), term()) -> {term(), term()}),
                        view :: fun((term()) -> iodata())},
          term(),
          map()) ->
             term().

Run Prog to completion in the current (registered) process and return the final model. Called by beamtea:start/3.