Ratatouille v0.2.0 Ratatouille.Window View Source

A GenServer to manage the terminal window, along with a client API to perform updates and retrieve window information.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Closes the window by stopping the GenServer. Prior to this, termbox is de-initialized so that the terminal is restored to its previous state

Fetches an attribute for the window. This is currently limited to the window dimensions, which can be useful when laying out content

Starts the gen_server representing the window

Updates the window by rendering the given view to the termbox buffer and presenting it

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

close(pid \\ __MODULE__) View Source
close(pid()) :: :ok

Closes the window by stopping the GenServer. Prior to this, termbox is de-initialized so that the terminal is restored to its previous state.

Link to this function

fetch(pid \\ __MODULE__, attr) View Source
fetch(pid(), atom()) :: any()

Fetches an attribute for the window. This is currently limited to the window dimensions, which can be useful when laying out content.

Examples

iex> Window.fetch(:height)
{:ok, 124}
iex> Window.fetch(:width)
{:ok, 50}
iex> Window.fetch(:foo)
{:error, :unknown_attribute}
Link to this function

start_link(opts \\ []) View Source
start_link(Keyword.t()) :: :ok

Starts the gen_server representing the window.

The window is intended to be run as a singleton gen_server process, as initializing the underlying termbox library multiple times on the same TTY can lead to undefined behavior.

Options

Link to this function

update(pid \\ __MODULE__, view) View Source
update(pid(), Ratatouille.Renderer.Element.t()) :: :ok

Updates the window by rendering the given view to the termbox buffer and presenting it.