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
child_spec(init_arg) View Source
Returns a specification to start this module under a supervisor.
See Supervisor
.
close(pid \\ __MODULE__)
View Source
close(pid()) :: :ok
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.
fetch(pid \\ __MODULE__, attr) View Source
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}
start_link(opts \\ [])
View Source
start_link(Keyword.t()) :: :ok
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
:name
- Override the name passed toGenServer.start_link/3
. By default,name: Ratatouille.Window
is passed in order to protect against accidental double initialization, but this can be overridden by passingnil
or an alternate value.:input_mode
- Configure the input mode. SeeRatatouille.Constants.input_mode/1
for possible values.:output_mode
- Configure the output mode. SeeRatatouille.Constants.output_mode/1
for possible values.
update(pid \\ __MODULE__, view)
View Source
update(pid(), Ratatouille.Renderer.Element.t()) :: :ok
update(pid(), Ratatouille.Renderer.Element.t()) :: :ok
Updates the window by rendering the given view to the termbox buffer and presenting it.