

API Reference — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

 API Reference

==================================

 Modules

----------

[Ratatouille](Ratatouille.html)

Ratatouille is a framework for building terminal UIs.

[Ratatouille.App](Ratatouille.App.html)

Defines the [`Ratatouille.App`](#content) behaviour. It provides the structure for

architecting both large and small terminal applications. This structure

allows you to render views and update them over time or in response to user

input.

[Ratatouille.Constants](Ratatouille.Constants.html)

A convenience wrapper of [`ExTermbox.Constants`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html).

[Ratatouille.EventManager](Ratatouille.EventManager.html)

A wrapper of [`ExTermbox.EventManager`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.EventManager.html) so that Ratatouille applications don't

need to use or depend on ex\_termbox directly.

[Ratatouille.Renderer](Ratatouille.Renderer.html)

Logic to render a view tree.

[Ratatouille.Renderer.Attributes](Ratatouille.Renderer.Attributes.html)

Functions for working with element attributes

[Ratatouille.Renderer.Border](Ratatouille.Renderer.Border.html)

Primitives for rendering borders

[Ratatouille.Renderer.Box](Ratatouille.Renderer.Box.html)

This defines the internal representation of a rectangular region---a box---for

rendering, as well as logic for transforming these boxes.

[Ratatouille.Renderer.Canvas](Ratatouille.Renderer.Canvas.html)

A canvas represents a terminal window, a subvision of it for rendering, and a

sparse mapping of positions to cells.

[Ratatouille.Renderer.Cells](Ratatouille.Renderer.Cells.html)

Functions for working with canvas cells.

[Ratatouille.Renderer.Line](Ratatouille.Renderer.Line.html)

Primitives for rendering lines

[Ratatouille.Renderer.Text](Ratatouille.Renderer.Text.html)

Primitives for rendering text

[Ratatouille.Runtime](Ratatouille.Runtime.html)

A runtime for apps implementing the [`Ratatouille.App`](Ratatouille.App.html) behaviour. See

[`Ratatouille.App`](Ratatouille.App.html) for details on how to build apps.

[Ratatouille.Runtime.Command](Ratatouille.Runtime.Command.html)

Commands provide a way to start an expensive call in the background and get

the result back via [`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2).

[Ratatouille.Runtime.State](Ratatouille.Runtime.State.html)

Defines a struct to store the runtime loop's state.

[Ratatouille.Runtime.Subscription](Ratatouille.Runtime.Subscription.html)

Subscriptions provide a way for the app to be notified via

[`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2) when something interesting happens.

[Ratatouille.Runtime.Supervisor](Ratatouille.Runtime.Supervisor.html)

A supervisor to run the application runtime and its dependencies.

[Ratatouille.View](Ratatouille.View.html)

In Ratatouille, a view is simply a tree of elements. Each element in the tree

holds an attributes map and a list of zero or more child nodes. Visually, it

looks like something this

[Ratatouille.Window](Ratatouille.Window.html)

A GenServer to manage the terminal window, along with a client API to perform

updates and retrieve window information.





Ratatouille — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille.ex#L1 "View Source")

========================================================================================================================================

Ratatouille is a framework for building terminal UIs.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[run(application, opts \\ [])](#run/2)

Starts an application under a supervised runtime, given a module implementing

the `Ratatouille.Application` behaviour. This call blocks until the

application is quit (or it crashes).

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#run/2 "Link to this function")

run(application, opts \\ [])

============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille.ex#L45 "View Source")

Starts an application under a supervised runtime, given a module implementing

the `Ratatouille.Application` behaviour. This call blocks until the

application is quit (or it crashes).

This is intended as a way to easily run simple apps and examples. For more

complex apps depending on other processes, it's recommended to define an OTP

application and start the [`Ratatouille.Runtime.Supervisor`](Ratatouille.Runtime.Supervisor.html) as a child of your

application supervisor.

### 

 Example

```

defmodule Counter do

 @behaviour Ratatouille.App

 import Ratatouille.View

 def init(\_context), do: 0

 def update(model, msg) do

 case msg do

 {:event, %{ch: ?+}} -> model + 1

 {:event, %{ch: ?-}} -> model - 1

 \_ -> model

 end

 end

 def render(model) do

 view do

 label(content: "Counter is #{model} (+/-)")

 end

 end

end

Ratatouille.run(Counter)

```





Ratatouille.App — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.App behaviour [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L1 "View Source")

==========================================================================================================================================================

Defines the [`Ratatouille.App`](#content) behaviour. It provides the structure for

architecting both large and small terminal applications. This structure

allows you to render views and update them over time or in response to user

input.

 A Simple Example

-------------------

```

defmodule Counter.App do

 @behaviour Ratatouille.App

 def model(\_context), do: 0

 def update(model, msg) do

 case msg do

 {:event, %{ch: ?+}} -> model + 1

 {:event, %{ch: ?-}} -> model - 1

 \_ -> model

 end

 end

 def render(model) do

 view do

 label(content: "Counter is #{model} (+/-)")

 end

 end

end

```

 Architecture

---------------

You may have recognized this pattern from [the Elm Architecture](https://guide.elm-lang.org/architecture/). That's because

[`Ratatouille.App`](#content) is just a close translation of this architecture to Elixir.

Because Elixir and Elm are both functional programming languages, the pattern

also works very well in Elixir. It helps to centralize state,

The architecture cleanly separates logic into the following three parts:

* **Model:** the state of your application

* **Update:** a way to update your state

* **View:** a way to view your state as a `%Ratatouille.Element{}` tree (think

HTML).

The behaviour callbacks map to these three parts:

* [`init/1`](#c:init/1) defines your initial model, using provided context if needed.

* [`update/2`](#c:update/2) handles a message and retuns a new model.

* [`render/1`](#c:render/1) receives a model and builds a view (an element tree) to view it.

See the documentation for each callback below for additional details.

 Runtime

----------

As long as you implement the behaviour callbacks, Ratatouille can handle the

rest. It provides a runtime ([`Ratatouille.Runtime`](Ratatouille.Runtime.html)), which will handle

actually running your application. That means setting up the window, rendering

the view, subscribing to events and passing these on to the application's

`update/2` callback, and making sure the view is always re-rendered when the

application's model changes.

 Fetching Data & Other Expensive Calls

----------------------------------------

A good rule of thumb for developing responsive UIs in any language is to never

block the UI thread. Here, we have a runtime process, but the same rule

applies.

In Ratatouille, your application should use [`Ratatouille.Runtime.Command`](Ratatouille.Runtime.Command.html) in

order to start asynchronous tasks and get the result in the `update/2`

callback once finished.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[context()](#t:context/0)

[model()](#t:model/0)

[msg()](#t:msg/0)

[Callbacks](#callbacks)

------------------------

[init(context)](#c:init/1)

The `init/1` callback defines the initial model. This model can be defined

based on the runtime context. See the "Runtime Context" section under

[`Ratatouille.Runtime`](Ratatouille.Runtime.html) for details on what context is provided.

[render(model)](#c:render/1)

The `render/1` callback defines how to render the model as a view.

[subscribe(model)](#c:subscribe/1)

The optional `subscribe/1` callback defines a subscription for the application

given the initial model. Subscriptions are fulfilled via the `update/2`

callback.

[update(model, msg)](#c:update/2)

The `update/2` callback defines how to update the model in reaction to a

message (for example, an event or a tick).

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:context/0 "Link to this type")

context()

=========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L78 "View Source")

```

context() :: [map](https://hexdocs.pm/elixir/typespecs.html#basic-types)()

```

[Link to this type](#t:model/0 "Link to this type")

model()

=======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L79 "View Source")

```

model() :: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

[Link to this type](#t:msg/0 "Link to this type")

msg()

=====

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L80 "View Source")

```

msg() :: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

[Link to this section](#callbacks)

Callbacks

=============================================

[Link to this callback](#c:init/1 "Link to this callback")

init(context)

=============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L87 "View Source")

```

init([context](#t:context/0)()) :: [model](#t:model/0)() | {[model](#t:model/0)(), Command.t()}

```

The `init/1` callback defines the initial model. This model can be defined

based on the runtime context. See the "Runtime Context" section under

[`Ratatouille.Runtime`](Ratatouille.Runtime.html) for details on what context is provided.

[Link to this callback](#c:render/1 "Link to this callback")

render(model)

=============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L136 "View Source")

```

render([model](#t:model/0)()) :: Ratatouille.Renderer.Element.t()

```

The `render/1` callback defines how to render the model as a view.

It should return a `%Ratatouille.Element{}` with the `:view` tag. For example:

```

@impl true

def render(model) do

 view do

 label(content: "Hello, #{model.name}!")

 end

end

```

[Link to this callback](#c:subscribe/1 "Link to this callback")

subscribe(model)

================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L121 "View Source")

(optional)

```

subscribe([model](#t:model/0)()) :: Subscription.t()

```

The optional `subscribe/1` callback defines a subscription for the application

given the initial model. Subscriptions are fulfilled via the `update/2`

callback.

For example, a subscription can be used to update the view every second (see

[`Ratatouille.Runtime.Subscription.interval/2`](Ratatouille.Runtime.Subscription.html#interval/2)):

```

@impl true

def subscribe(\_model) do

 Subscription.interval(1\_000, :tick)

end

```

It's also possible to subscribe to multiple things via

[`Ratatouille.Runtime.Subscription.batch/1`](Ratatouille.Runtime.Subscription.html#batch/1). See

[`Ratatouille.Runtime.Subscription`](Ratatouille.Runtime.Subscription.html) for more details.

[Link to this callback](#c:update/2 "Link to this callback")

update(model, msg)

==================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/app.ex#L102 "View Source")

```

update([model](#t:model/0)(), [msg](#t:msg/0)()) :: [model](#t:model/0)() | {[model](#t:model/0)(), Command.t()}

```

The `update/2` callback defines how to update the model in reaction to a

message (for example, an event or a tick).

The following messages are currently passed to `update/2` by the runtime:

* `{:event, event}` - A keyboard or click event.

* `{:refresh, event}` - A resize event.

The callback should always return the model. It can be the same model or an

updated one. If the model changes, the runtime will know to re-render the

model and update the window.





Ratatouille.Constants — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Constants [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L1 "View Source")

============================================================================================================================================================

A convenience wrapper of [`ExTermbox.Constants`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html).

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[attribute(name)](#attribute/1)

See [`ExTermbox.Constants.attribute/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#attribute/1).

[attributes()](#attributes/0)

See [`ExTermbox.Constants.attributes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#attributes/0).

[color(name)](#color/1)

See [`ExTermbox.Constants.color/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#color/1).

[colors()](#colors/0)

See [`ExTermbox.Constants.colors/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#colors/0).

[error\_code(name)](#error_code/1)

See [`ExTermbox.Constants.error_code/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#error_code/1).

[error\_codes()](#error_codes/0)

See [`ExTermbox.Constants.error_codes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#error_codes/0).

[event\_type(name)](#event_type/1)

See [`ExTermbox.Constants.event_type/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#event_type/1).

[event\_types()](#event_types/0)

See [`ExTermbox.Constants.event_types/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#event_types/0).

[input\_mode(name)](#input_mode/1)

See [`ExTermbox.Constants.input_mode/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#input_mode/1).

[input\_modes()](#input_modes/0)

See [`ExTermbox.Constants.input_modes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#input_modes/0).

[key(name)](#key/1)

See [`ExTermbox.Constants.key/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#key/1).

[keys()](#keys/0)

See [`ExTermbox.Constants.keys/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#keys/0).

[output\_mode(name)](#output_mode/1)

See [`ExTermbox.Constants.output_mode/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#output_mode/1).

[output\_modes()](#output_modes/0)

See [`ExTermbox.Constants.output_modes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#output_modes/0).

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#attribute/1 "Link to this function")

attribute(name)

===============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.attribute/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#attribute/1).

[Link to this function](#attributes/0 "Link to this function")

attributes()

============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.attributes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#attributes/0).

[Link to this function](#color/1 "Link to this function")

color(name)

===========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.color/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#color/1).

[Link to this function](#colors/0 "Link to this function")

colors()

========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.colors/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#colors/0).

[Link to this function](#error_code/1 "Link to this function")

error\_code(name)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.error_code/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#error_code/1).

[Link to this function](#error_codes/0 "Link to this function")

error\_codes()

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.error_codes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#error_codes/0).

[Link to this function](#event_type/1 "Link to this function")

event\_type(name)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.event_type/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#event_type/1).

[Link to this function](#event_types/0 "Link to this function")

event\_types()

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.event_types/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#event_types/0).

[Link to this function](#input_mode/1 "Link to this function")

input\_mode(name)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.input_mode/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#input_mode/1).

[Link to this function](#input_modes/0 "Link to this function")

input\_modes()

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.input_modes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#input_modes/0).

[Link to this function](#key/1 "Link to this function")

key(name)

=========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.key/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#key/1).

[Link to this function](#keys/0 "Link to this function")

keys()

======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.keys/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#keys/0).

[Link to this function](#output_mode/1 "Link to this function")

output\_mode(name)

==================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L22 "View Source")

See [`ExTermbox.Constants.output_mode/1`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#output_mode/1).

[Link to this function](#output_modes/0 "Link to this function")

output\_modes()

===============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/constants.ex#L27 "View Source")

See [`ExTermbox.Constants.output_modes/0`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Constants.html#output_modes/0).





Ratatouille.EventManager — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.EventManager [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/event_manager.ex#L1 "View Source")

===================================================================================================================================================================

A wrapper of [`ExTermbox.EventManager`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.EventManager.html) so that Ratatouille applications don't

need to use or depend on ex\_termbox directly.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[child\_spec(opts)](#child_spec/1)

Provides a child specification to use when starting the event manager under a

supervisor.

[start\_link(opts \\ [])](#start_link/1)

Starts the [`ExTermbox.EventManager`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.EventManager.html) gen\_server.

[stop(pid \\ \_\_MODULE\_\_)](#stop/1)

Stops the event manager server.

[subscribe(pid \\ \_\_MODULE\_\_, subscriber\_pid)](#subscribe/2)

Subscribes the given pid to future event notifications.

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#child_spec/1 "Link to this function")

child\_spec(opts)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/event_manager.ex#L33 "View Source")

Provides a child specification to use when starting the event manager under a

supervisor.

[Link to this function](#start_link/1 "Link to this function")

start\_link(opts \\ [])

=======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/event_manager.ex#L11 "View Source")

```

start_link([Keyword.t](https://hexdocs.pm/elixir/Keyword.html#t:t/0)()) :: [GenServer.on\_start](https://hexdocs.pm/elixir/GenServer.html#t:on_start/0)()

```

Starts the [`ExTermbox.EventManager`](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.EventManager.html) gen\_server.

[Link to this function](#stop/1 "Link to this function")

stop(pid \\ \_\_MODULE\_\_)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/event_manager.ex#L26 "View Source")

Stops the event manager server.

[Link to this function](#subscribe/2 "Link to this function")

subscribe(pid \\ \_\_MODULE\_\_, subscriber\_pid)

=================================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/event_manager.ex#L20 "View Source")

Subscribes the given pid to future event notifications.





Ratatouille.Renderer — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer behaviour [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L1 "View Source")

====================================================================================================================================================================

Logic to render a view tree.

This API is still under development.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[child\_element()](#t:child_element/0)

[child\_tag()](#t:child_tag/0)

[root\_element()](#t:root_element/0)

[Functions](#functions)

------------------------

[render(canvas, root)](#render/2)

Renders a view tree to canvas, given a canvas and a root element (an element

with the `:view` tag).

[render\_tree(canvas, elements)](#render_tree/2)

[validate\_tree(element)](#validate_tree/1)

Validates the hierarchy of a view tree given the root element.

[Callbacks](#callbacks)

------------------------

[render(arg1, arg2, function)](#c:render/3)

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:child_element/0 "Link to this type")

child\_element()

================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L31 "View Source")

```

child_element() :: %Ratatouille.Renderer.Element{

  attributes: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  children: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  tag: [child\_tag](#t:child_tag/0)()

}

```

[Link to this type](#t:child_tag/0 "Link to this type")

child\_tag()

============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L15 "View Source")

```

child_tag() ::

  :bar

  | :chart

  | :column

  | :label

  | :overlay

  | :panel

  | :row

  | :sparkline

  | :table

  | :table_cell

  | :table_row

  | :text

  | :tree

  | :tree_node

```

[Link to this type](#t:root_element/0 "Link to this type")

root\_element()

===============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L10 "View Source")

```

root_element() :: %Ratatouille.Renderer.Element{

  attributes: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  children: [[child\_element](#t:child_element/0)()],

  tag: :view

}

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#render/2 "Link to this function")

render(canvas, root)

====================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L51 "View Source")

```

render([Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)(), [root\_element](#t:root_element/0)()) ::

  {:ok, [Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)()} | {:error, [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()}

```

Renders a view tree to canvas, given a canvas and a root element (an element

with the `:view` tag).

The tree is rendered by recursively rendering each element in the hierarchy.

The canvas serves as both the accumulator for rendered cells at each stage and

as the box representing available space for rendering, which shrinks as this

space is consumed.

[Link to this function](#render_tree/2 "Link to this function")

render\_tree(canvas, elements)

==============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L58 "View Source")

```

render_tree(

  [Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)(),

  Ratatouille.Renderer.Element.t() | [Ratatouille.Renderer.Element.t()]

) :: [Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)()

```

[Link to this function](#validate_tree/1 "Link to this function")

validate\_tree(element)

=======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L83 "View Source")

```

validate_tree(Ratatouille.Renderer.Element.t()) :: :ok | {:error, [String.t](https://hexdocs.pm/elixir/String.html#t:t/0)()}

```

Validates the hierarchy of a view tree given the root element.

Used by the render/2 function to prevent strange errors that may otherwise

occur when processing invalid view trees.

[Link to this section](#callbacks)

Callbacks

=============================================

[Link to this callback](#c:render/3 "Link to this callback")

render(arg1, arg2, function)

============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer.ex#L33 "View Source")

```

render(

  [Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)(),

  Ratatouille.Renderer.Element.t(),

  ([Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)(), Ratatouille.Renderer.Element.t() ->

     [Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)())

) :: [Ratatouille.Renderer.Canvas.t](Ratatouille.Renderer.Canvas.html#t:t/0)()

```





Ratatouille.Renderer.Attributes — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Attributes [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/attributes.ex#L1 "View Source")

================================================================================================================================================================================

Functions for working with element attributes

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[to\_terminal\_attribute(code)](#to_terminal_attribute/1)

[to\_terminal\_color(code)](#to_terminal_color/1)

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#to_terminal_attribute/1 "Link to this function")

to\_terminal\_attribute(code)

=============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/attributes.ex#L20 "View Source")

[Link to this function](#to_terminal_color/1 "Link to this function")

to\_terminal\_color(code)

=========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/attributes.ex#L11 "View Source")





Ratatouille.Renderer.Border — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Border [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/border.ex#L1 "View Source")

========================================================================================================================================================================

Primitives for rendering borders

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[render(canvas)](#render/1)

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#render/1 "Link to this function")

render(canvas)

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/border.ex#L19 "View Source")





Ratatouille.Renderer.Box — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Box [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L1 "View Source")

==================================================================================================================================================================

This defines the internal representation of a rectangular region---a box---for

rendering, as well as logic for transforming these boxes.

Boxes live on a coordinate plane. The y-axis is inverted so that the y values

increase as the box's height grows.

```

--------------> x

|

| \_\_\_\_\_\_\_\_

| | |

| |\_\_\_\_\_\_|

v

y

```

A `Box` struct stores the coordinates for two corners of the box---the

top-left and bottom-right corners--from which the remaining attributes

(height, width, other corners) can be computed.

```

 \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

| |

| A |

| |

| |

| |

| B |

|\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_|

A: top-left corner, e.g. (0, 0)

B: bottom-right corner, e.g. (10, 10)

```

For rendering purposes, the outermost box will typically have a top-left

corner (0, 0) and a bottom-right corner (x, y) where x is the number of rows

and y is the number of columns on the terminal.

This outermost box can then be subdivided as necessary to render different

elements of the view.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[bottom\_left(box)](#bottom_left/1)

[bottom\_right(box)](#bottom_right/1)

[consume(box, dx, dy)](#consume/3)

[contains?(box, position)](#contains?/2)

[from\_dimensions(width, height, origin \\ %Position{x: 0, y: 0})](#from_dimensions/3)

[head(box, n)](#head/2)

Given a box, returns a slice of the y axis with `n` rows from the top.

[height(box)](#height/1)

[padded(box, size)](#padded/2)

[positions(box)](#positions/1)

[tail(box, n)](#tail/2)

Given a box, returns a slice of the y axis with `n` rows from the bottom.

[top\_left(box)](#top_left/1)

[top\_right(box)](#top_right/1)

[translate(box, dx, dy)](#translate/3)

[width(box)](#width/1)

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#bottom_left/1 "Link to this function")

bottom\_left(box)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L111 "View Source")

[Link to this function](#bottom_right/1 "Link to this function")

bottom\_right(box)

==================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L114 "View Source")

[Link to this function](#consume/3 "Link to this function")

consume(box, dx, dy)

====================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L61 "View Source")

[Link to this function](#contains?/2 "Link to this function")

contains?(box, position)

========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L122 "View Source")

[Link to this function](#from_dimensions/3 "Link to this function")

from\_dimensions(width, height, origin \\ %Position{x: 0, y: 0})

================================================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L132 "View Source")

[Link to this function](#head/2 "Link to this function")

head(box, n)

============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L89 "View Source")

Given a box, returns a slice of the y axis with `n` rows from the top.

[Link to this function](#height/1 "Link to this function")

height(box)

===========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L119 "View Source")

[Link to this function](#padded/2 "Link to this function")

padded(box, size)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L72 "View Source")

[Link to this function](#positions/1 "Link to this function")

positions(box)

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L79 "View Source")

[Link to this function](#tail/2 "Link to this function")

tail(box, n)

============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L99 "View Source")

Given a box, returns a slice of the y axis with `n` rows from the bottom.

[Link to this function](#top_left/1 "Link to this function")

top\_left(box)

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L106 "View Source")

[Link to this function](#top_right/1 "Link to this function")

top\_right(box)

===============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L108 "View Source")

[Link to this function](#translate/3 "Link to this function")

translate(box, dx, dy)

======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L47 "View Source")

[Link to this function](#width/1 "Link to this function")

width(box)

==========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/box.ex#L116 "View Source")





Ratatouille.Renderer.Canvas — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Canvas [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L1 "View Source")

========================================================================================================================================================================

A canvas represents a terminal window, a subvision of it for rendering, and a

sparse mapping of positions to cells.

A `%Canvas{}` struct can be rendered to different output formats. This includes

the primary use-case of rendering to the termbox-managed window, but also

rendering to strings, which is useful for testing.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Functions](#functions)

------------------------

[consume(canvas, dx, dy)](#consume/3)

Copies the canvas to a new one with the render box consumed by the given `dx`

and `dy`.

[consume\_columns(canvas, n)](#consume_columns/2)

Creates a new canvas with `n` columns (from the left) consumed.

[consume\_rows(canvas, n)](#consume_rows/2)

Creates a new canvas with `n` rows (from the top) consumed.

[fill\_background(canvas)](#fill_background/1)

[from\_dimensions(x, y)](#from_dimensions/2)

Creates an empty canvas with the given dimensions.

[merge\_cells(canvas, cells)](#merge_cells/2)

Merges a list of cells into the canvas, provided that the cells are located

within the canvas's rendering box. Returns a new canvas with the merged cells.

[padded(canvas, size)](#padded/2)

Copies the canvas to a new one with the render box padded on each side (top,

left, bottom, right) by `size`. Pass a negative size to remove padding.

[put\_box(canvas, render\_box)](#put_box/2)

[render\_to\_string(canvas)](#render_to_string/1)

[render\_to\_strings(canvas)](#render_to_strings/1)

[render\_to\_termbox(bindings, canvas)](#render_to_termbox/2)

[translate(canvas, dx, dy)](#translate/3)

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:t/0 "Link to this type")

t()

===

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L16 "View Source")

```

t() :: %Ratatouille.Renderer.Canvas{

  cells: [map](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),

  outer_box: [Ratatouille.Renderer.Box.t](Ratatouille.Renderer.Box.html#t:t/0)(),

  render_box: [Ratatouille.Renderer.Box.t](Ratatouille.Renderer.Box.html#t:t/0)()

}

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#consume/3 "Link to this function")

consume(canvas, dx, dy)

=======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L86 "View Source")

```

consume([t](#t:t/0)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()) :: [t](#t:t/0)()

```

Copies the canvas to a new one with the render box consumed by the given `dx`

and `dy`.

The render box is used to indicate the empty, renderable space on the canvas,

so this might be called with a `dy` of 1 after rendering a line of text. The

box is consumed left-to-right and top-to-bottom.

[Link to this function](#consume_columns/2 "Link to this function")

consume\_columns(canvas, n)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L100 "View Source")

```

consume_columns([t](#t:t/0)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()) :: [t](#t:t/0)()

```

Creates a new canvas with `n` columns (from the left) consumed.

[Link to this function](#consume_rows/2 "Link to this function")

consume\_rows(canvas, n)

========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L94 "View Source")

```

consume_rows([t](#t:t/0)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()) :: [t](#t:t/0)()

```

Creates a new canvas with `n` rows (from the top) consumed.

[Link to this function](#fill_background/1 "Link to this function")

fill\_background(canvas)

========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L57 "View Source")

[Link to this function](#from_dimensions/2 "Link to this function")

from\_dimensions(x, y)

======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L43 "View Source")

```

from_dimensions([non\_neg\_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(), [non\_neg\_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()) :: [t](#t:t/0)()

```

Creates an empty canvas with the given dimensions.

 Examples

-----------

```

iex> Canvas.from\_dimensions(10, 20)

%Canvas{

 outer\_box: %Ratatouille.Renderer.Box{

 top\_left: %ExTermbox.Position{x: 0, y: 0},

 bottom\_right: %ExTermbox.Position{x: 9, y: 19}

 },

 render\_box: %Ratatouille.Renderer.Box{

 top\_left: %ExTermbox.Position{x: 0, y: 0},

 bottom\_right: %ExTermbox.Position{x: 9, y: 19}

 },

 cells: %{}

}

```

[Link to this function](#merge_cells/2 "Link to this function")

merge\_cells(canvas, cells)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L107 "View Source")

```

merge_cells([t](#t:t/0)(), [[ExTermbox.Cell.t](https://hexdocs.pm/ex_termbox/1.0.2/ExTermbox.Cell.html#t:t/0)()]) :: [t](#t:t/0)()

```

Merges a list of cells into the canvas, provided that the cells are located

within the canvas's rendering box. Returns a new canvas with the merged cells.

[Link to this function](#padded/2 "Link to this function")

padded(canvas, size)

====================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L73 "View Source")

```

padded([t](#t:t/0)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()) :: [t](#t:t/0)()

```

Copies the canvas to a new one with the render box padded on each side (top,

left, bottom, right) by `size`. Pass a negative size to remove padding.

[Link to this function](#put_box/2 "Link to this function")

put\_box(canvas, render\_box)

=============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L51 "View Source")

```

put_box([t](#t:t/0)(), [Ratatouille.Renderer.Box.t](Ratatouille.Renderer.Box.html#t:t/0)()) :: [t](#t:t/0)()

```

[Link to this function](#render_to_string/1 "Link to this function")

render\_to\_string(canvas)

==========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L151 "View Source")

```

render_to_string([t](#t:t/0)()) :: [String.t](https://hexdocs.pm/elixir/String.html#t:t/0)()

```

[Link to this function](#render_to_strings/1 "Link to this function")

render\_to\_strings(canvas)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L126 "View Source")

```

render_to_strings([t](#t:t/0)()) :: [[String.t](https://hexdocs.pm/elixir/String.html#t:t/0)()]

```

[Link to this function](#render_to_termbox/2 "Link to this function")

render\_to\_termbox(bindings, canvas)

=====================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L155 "View Source")

```

render_to_termbox([module](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(), [t](#t:t/0)()) :: :ok

```

[Link to this function](#translate/3 "Link to this function")

translate(canvas, dx, dy)

=========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/canvas.ex#L121 "View Source")

```

translate([t](#t:t/0)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(), [integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()) :: [t](#t:t/0)()

```





Ratatouille.Renderer.Cells — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Cells [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/cells.ex#L1 "View Source")

======================================================================================================================================================================

Functions for working with canvas cells.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[background(attrs)](#background/1)

Computes a cell's background given a standardized attributes map.

[foreground(attrs)](#foreground/1)

Computes a cell's foreground given a standardized attributes map.

[generator(position, orientation, template \\ Cell.empty())](#generator/3)

Given a starting position, orientation and cell template, returns a cell

generator which can be used to iteratively generate a row or column of cells.

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#background/1 "Link to this function")

background(attrs)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/cells.ex#L32 "View Source")

Computes a cell's background given a standardized attributes map.

[Link to this function](#foreground/1 "Link to this function")

foreground(attrs)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/cells.ex#L18 "View Source")

Computes a cell's foreground given a standardized attributes map.

The foreground value is computed by taking the color's integer value and the

integer values of any styling attributes (e.g., bold, underline) and computing

the bitwise OR of all the values.

[Link to this function](#generator/3 "Link to this function")

generator(position, orientation, template \\ Cell.empty())

==========================================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/cells.ex#L40 "View Source")

Given a starting position, orientation and cell template, returns a cell

generator which can be used to iteratively generate a row or column of cells.





Ratatouille.Renderer.Line — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Line [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/line.ex#L1 "View Source")

====================================================================================================================================================================

Primitives for rendering lines

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[render(canvas, orientation, position, ch, len)](#render/5)

[render\_horizontal(canvas, position, ch, len)](#render_horizontal/4)

[render\_vertical(canvas, position, ch, len)](#render_vertical/4)

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#render/5 "Link to this function")

render(canvas, orientation, position, ch, len)

==============================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/line.ex#L15 "View Source")

[Link to this function](#render_horizontal/4 "Link to this function")

render\_horizontal(canvas, position, ch, len)

=============================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/line.ex#L9 "View Source")

[Link to this function](#render_vertical/4 "Link to this function")

render\_vertical(canvas, position, ch, len)

===========================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/line.ex#L12 "View Source")





Ratatouille.Renderer.Text — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Renderer.Text [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/text.ex#L1 "View Source")

====================================================================================================================================================================

Primitives for rendering text

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[render(canvas, position, text, attrs \\ %{})](#render/4)

[render\_group(canvas, text\_elements, attrs \\ %{})](#render_group/3)

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#render/4 "Link to this function")

render(canvas, position, text, attrs \\ %{})

============================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/text.ex#L9 "View Source")

[Link to this function](#render_group/3 "Link to this function")

render\_group(canvas, text\_elements, attrs \\ %{})

===================================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/renderer/text.ex#L23 "View Source")





Ratatouille.Runtime — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Runtime [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime.ex#L1 "View Source")

========================================================================================================================================================

A runtime for apps implementing the [`Ratatouille.App`](Ratatouille.App.html) behaviour. See

[`Ratatouille.App`](Ratatouille.App.html) for details on how to build apps.

 Runtime Context

------------------

The runtime provides a map with additional context to the app's

[`Ratatouille.App.init/1`](Ratatouille.App.html#c:init/1) callback. This can be used, for example,

to get information about the terminal window. Currently, the following

attributes are provided via the map:

* `:window`: A map with `:height` and `:width` keys.

 Shutdown Options

-------------------

When a quit event is received (by default, "q", "Q" or ctrl-c), the runtime

will carry out the configured shutdown strategy. The default strategy

(`:self`) just stops the runtime process itself. In certain cases, it may

be desirable to stop an OTP application or the system itself, so a few other

strategies are provided:

* `:supervisor` - Stops the runtime supervisor, which will terminate the

runtime process and other dependencies. The VM will still be running

afterwards unless stopped by other means.

* `{:application, name}` - Stops the named application. The VM will still be

running afterwards unless stopped by other means.

* `:system`: Gracefully stops the system (calls [`:init.stop/0`](http://www.erlang.org/doc/man/init.html#stop-0)). Gracefully

shutting down the VM ensures that all applications are stopped. There will

be some lag between sending the quit event and the OS process actually

exiting, as the VM needs about a second to stop this way. See the note below

if this is a problem.

If the `:system` option is too slow, it's possible to halt the system manually

with [`System.halt/0`](https://hexdocs.pm/elixir/System.html#halt/0). It's just important to ensure that the system is only

halted after the terminal was restored to its original state. Otherwise, there

may be rendering artifacts or issues with the cursor. The `:supervisor` option

can be used to properly halt the system by monitoring the runtime supervisor

and halting once it has exited. Alternatively, use the `:application` option

to stop an application that runs the runtime supervisor and halt in the

application's `stop/1` callback.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[child\_spec(arg)](#child_spec/1)

Returns a specification to start this module under a supervisor.

[run(state)](#run/1)

[start\_link(config)](#start_link/1)

Starts the application runtime given a module defining a Ratatouille terminal

application.

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#child_spec/1 "Link to this function")

child\_spec(arg)

================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime.ex#L44 "View Source")

Returns a specification to start this module under a supervisor.

`arg` is passed as the argument to [`Task.start_link/1`](https://hexdocs.pm/elixir/Task.html#start_link/1) in the `:start` field

of the spec.

For more information, see the [`Supervisor`](https://hexdocs.pm/elixir/Supervisor.html) module,

the [`Supervisor.child_spec/2`](https://hexdocs.pm/elixir/Supervisor.html#child_spec/2) function and the [`Supervisor.child_spec/0`](https://hexdocs.pm/elixir/Supervisor.html#t:child_spec/0) type.

[Link to this function](#run/1 "Link to this function")

run(state)

==========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime.ex#L97 "View Source")

```

run([Ratatouille.Runtime.State.t](Ratatouille.Runtime.State.html#t:t/0)()) :: :ok

```

[Link to this function](#start_link/1 "Link to this function")

start\_link(config)

===================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime.ex#L82 "View Source")

```

start_link([Keyword.t](https://hexdocs.pm/elixir/Keyword.html#t:t/0)()) :: {:ok, [pid](https://hexdocs.pm/elixir/typespecs.html#basic-types)()}

```

Starts the application runtime given a module defining a Ratatouille terminal

application.

 Configuration

----------------

* `:app` (required) - The [`Ratatouille.App`](Ratatouille.App.html) to run.

* `:shutdown` - The strategy for stopping the terminal application when a quit

 event is received.

* `:interval` - The runtime loop interval in milliseconds. The default

 interval is 500 ms. A subscription can be fulfilled at most once every

 interval, so this effectively configures the maximum subscription

 resolution that's possible.

* `:quit_events` - Specifies the events that should quit the terminal

 application. Given as a list of tuples conforming where each tuple conforms

 to either `{:ch, ch}` or `{:key, key}`. If not specified, ctrl-c and q / Q

 can be used to quit the application by default.





Ratatouille.Runtime.Command — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Runtime.Command [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/command.ex#L1 "View Source")

========================================================================================================================================================================

Commands provide a way to start an expensive call in the background and get

the result back via [`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2).

Commands should be constructed via the functions below and not via the struct

directly, as this is internal and subject to change.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Functions](#functions)

------------------------

[batch(cmds)](#batch/1)

Returns a batch command given a list of commands. This simply provides a way

to return multiple commands as a single one. Batch commands should not depend

on one another---Ratatouille's runtime may run some or all of them in

parallel and doesn't guarantee any particular order of execution.

[new(func, message)](#new/2)

Returns a new command that can be returned in the [`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2)

or [`Ratatouille.App.init/1`](Ratatouille.App.html#c:init/1) callbacks.

[Link to this section](#types)

Types

=====================================

[Link to this opaque](#t:t/0 "Link to this opaque")

t()

===

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/command.ex#L18 "View Source")

(opaque)

```

t()

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#batch/1 "Link to this function")

batch(cmds)

===========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/command.ex#L50 "View Source")

```

batch([[t](#t:t/0)()]) :: [t](#t:t/0)()

```

Returns a batch command given a list of commands. This simply provides a way

to return multiple commands as a single one. Batch commands should not depend

on one another---Ratatouille's runtime may run some or all of them in

parallel and doesn't guarantee any particular order of execution.

Dependencies should be expressed via a single command or a sequence of

commands orchestrated via the application model state.

[Link to this function](#new/2 "Link to this function")

new(func, message)

==================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/command.ex#L34 "View Source")

```

new((() -> [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()), [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [t](#t:t/0)()

```

Returns a new command that can be returned in the [`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2)

or [`Ratatouille.App.init/1`](Ratatouille.App.html#c:init/1) callbacks.

Takes an anonymous function and a message. The message is used to send a

response back to your app along with the result. It can be any Erlang term, so

it's also possible to include identifiers (e.g., `{:finished, id}`).





Ratatouille.Runtime.State — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Runtime.State [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/state.ex#L1 "View Source")

====================================================================================================================================================================

Defines a struct to store the runtime loop's state.





Ratatouille.Runtime.Subscription — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Runtime.Subscription [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/subscription.ex#L1 "View Source")

==================================================================================================================================================================================

Subscriptions provide a way for the app to be notified via

[`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2) when something interesting happens.

Subscriptions should be constructed via the functions below and not via the

struct directly, as this is internal and subject to change.

Currently, it's possible to subscribe to time intervals ([`interval/2`](#interval/2)) and to

create batch subscriptions (i.e., multiple time intervals). More subscription

types may be introduced later.

### 

 Accuracy of Time Intervals

Ratatouille's runtime loop, which handles subscriptions, runs on a interval

itself (by default, every 500 ms). This means that the runtime loop is the

minimum possible subscription interval. If a subscription's interval is more

frequent than the runtime loop interval, the runtime loop interval is the

subscription's effective interval.

There is also no guarantee that subscriptions will be processed on time, as

the runtime may be busy with other tasks (e.g., handling events or rendering).

With that said, if care is taken to keep expensive calls out of the runtime

loop, subscriptions should be processed very close to requested interval.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Functions](#functions)

------------------------

[batch(subs)](#batch/1)

Creates a batch subscription from a list of subscriptions.

[interval(ms, message)](#interval/2)

Returns a subscription based on a time interval. Takes the number of

milliseconds (`ms`) and a message as arguments. When returned in the

[`Ratatouille.App.subscribe/1`](Ratatouille.App.html#c:subscribe/1) callback, the runtime will call the

[`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2) function with current model and the message, on

approximately the given interval. See above for details on what

"approximately" means here.

[Link to this section](#types)

Types

=====================================

[Link to this opaque](#t:t/0 "Link to this opaque")

t()

===

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/subscription.ex#L32 "View Source")

(opaque)

```

t()

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#batch/1 "Link to this function")

batch(subs)

===========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/subscription.ex#L60 "View Source")

```

batch([[t](#t:t/0)()]) :: [t](#t:t/0)()

```

Creates a batch subscription from a list of subscriptions.

This provides a way to subscribe to multiple things, while still returning a

single subscription in [`Ratatouille.App.subscribe/1`](Ratatouille.App.html#c:subscribe/1).

[Link to this function](#interval/2 "Link to this function")

interval(ms, message)

=====================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/subscription.ex#L47 "View Source")

```

interval([non\_neg\_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(), [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [t](#t:t/0)()

```

Returns a subscription based on a time interval. Takes the number of

milliseconds (`ms`) and a message as arguments. When returned in the

[`Ratatouille.App.subscribe/1`](Ratatouille.App.html#c:subscribe/1) callback, the runtime will call the

[`Ratatouille.App.update/2`](Ratatouille.App.html#c:update/2) function with current model and the message, on

approximately the given interval. See above for details on what

"approximately" means here.





Ratatouille.Runtime.Supervisor — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Runtime.Supervisor [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/supervisor.ex#L1 "View Source")

==============================================================================================================================================================================

A supervisor to run the application runtime and its dependencies.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[child\_spec(init\_arg)](#child_spec/1)

Returns a specification to start this module under a supervisor.

[start\_link(opts \\ [])](#start_link/1)

Starts a supervisor that manages [`Ratatouille.Runtime`](Ratatouille.Runtime.html), along with runtime

dependencies [`Ratatouille.EventManager`](Ratatouille.EventManager.html) and [`Ratatouille.Window`](Ratatouille.Window.html).

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#child_spec/1 "Link to this function")

child\_spec(init\_arg)

======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/supervisor.ex#L6 "View Source")

Returns a specification to start this module under a supervisor.

See [`Supervisor`](https://hexdocs.pm/elixir/Supervisor.html).

[Link to this function](#start_link/1 "Link to this function")

start\_link(opts \\ [])

=======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/runtime/supervisor.ex#L21 "View Source")

```

start_link([Keyword.t](https://hexdocs.pm/elixir/Keyword.html#t:t/0)()) :: {:ok, [pid](https://hexdocs.pm/elixir/typespecs.html#basic-types)()} | :ignore | {:error, [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()}

```

Starts a supervisor that manages [`Ratatouille.Runtime`](Ratatouille.Runtime.html), along with runtime

dependencies [`Ratatouille.EventManager`](Ratatouille.EventManager.html) and [`Ratatouille.Window`](Ratatouille.Window.html).

 Options

----------

* `:runtime` - Options for the runtime. See [`Ratatouille.Runtime.start_link/1`](Ratatouille.Runtime.html#start_link/1).





Ratatouille.View — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.View [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L1 "View Source")

==================================================================================================================================================

In Ratatouille, a view is simply a tree of elements. Each element in the tree

holds an attributes map and a list of zero or more child nodes. Visually, it

looks like something this:

```

%Element{

 tag: :view,

 attributes: %{},

 children: [

 %Element{

 tag: :row,

 attributes: %{},

 children: [

 %Element{tag: :column, attributes: %{size: 4}, children: []},

 %Element{tag: :column, attributes: %{size: 4}, children: []},

 %Element{tag: :column, attributes: %{size: 4}, children: []}

 ]

 }

 ]

}

```

 View DSL

-----------

Because it's a bit tedious to define views like that, Ratatouille provides a

DSL to define them without all the boilerplate.

Now we can turn the above into this:

```

view do

 row do

 column(size: 4)

 column(size: 4)

 column(size: 4)

 end

end

```

While the syntax is more compact, the end result is exactly the same. This

expression produces the exact same `%Element{}` struct as defined above.

To use the DSL like this, we need to import all the functions:

```

import Ratatouille.View

```

Alternatively, import just the ones you need:

```

import Ratatouille.View, only: [view: 0, row: 0, column: 1]

```

### 

 Forms

All of the possible forms are enumerated below.

Element with tag `foo`:

```

foo()

```

Element with tag `foo` and attributes:

```

foo(size: 42)

```

Element with tag `foo` and children as list:

```

foo([

 bar()

])

```

Element with tag `foo` and children as block:

```

foo do

 bar()

end

```

Element with tag `foo`, attributes, and children as list:

```

foo(

 [size: 42],

 [bar()]

)

```

Element with tag `foo`, attributes, and children as block:

```

foo size: 42 do

 bar()

end

```

### 

 Empty Elements

Similar to so-called "empty" HTML elements such as `<br />`, Ratatouille also

has elements for which passing content doesn't make sense. For example, the

leaf node `text` stores its content in its attributes and cannot have any

child elements of its own.

In such cases, the block and list forms are unsupported.

### 

 Validation

While some errors---such as passing children to empty elements---are prevented

by the DSL, it's still possible (for now, at least) to build

semantically-invalid element trees using the DSL. This means that the elements

are being used in a way that doesn't make sense to the renderer.

In order to prevent cryptic rendering errors, the renderer first validates the

element tree it's given and rejects the whole thing if the structure is

unsupported. It currently checks the following things:

* The top-level element passed to the renderer must have the `:view` tag.

* A parent element may only have child elements that have one of the

supported child tags for the parent element.

* An element must define all of its required attributes and may not define any

unknown attributes.

The last two rules are based on the element's specification in

`Ratatouille.Renderer.Element`.

[Link to this section](#summary)

 Summary

==========================================

[Functions](#functions)

------------------------

[bar()](#bar/0)

Defines an element with the `:bar` tag.

[bar(attributes\_or\_children)](#bar/1)

Defines an element with the `:bar` tag and either

[bar(attributes, children)](#bar/2)

Defines an element with the `:bar` tag and the given attributes and

child elements.

[canvas()](#canvas/0)

Defines an element with the `:canvas` tag.

[canvas(attributes\_or\_children)](#canvas/1)

Defines an element with the `:canvas` tag and either

[canvas(attributes, children)](#canvas/2)

Defines an element with the `:canvas` tag and the given attributes and

child elements.

[canvas\_cell()](#canvas_cell/0)

Defines an element with the `:canvas_cell` tag.

[canvas\_cell(attributes)](#canvas_cell/1)

Defines an element with the `:canvas_cell` tag and the given attributes.

[chart()](#chart/0)

Defines an element with the `:chart` tag.

[chart(attributes)](#chart/1)

Defines an element with the `:chart` tag and the given attributes.

[column()](#column/0)

Defines an element with the `:column` tag.

[column(attributes\_or\_children)](#column/1)

Defines an element with the `:column` tag and either

[column(attributes, children)](#column/2)

Defines an element with the `:column` tag and the given attributes and

child elements.

[element(tag, attributes\_or\_children)](#element/2)

[element(tag, attributes, children)](#element/3)

[label()](#label/0)

Defines an element with the `:label` tag.

[label(attributes\_or\_children)](#label/1)

Defines an element with the `:label` tag and either

[label(attributes, children)](#label/2)

Defines an element with the `:label` tag and the given attributes and

child elements.

[overlay()](#overlay/0)

Defines an element with the `:overlay` tag.

[overlay(attributes\_or\_children)](#overlay/1)

Defines an element with the `:overlay` tag and either

[overlay(attributes, children)](#overlay/2)

Defines an element with the `:overlay` tag and the given attributes and

child elements.

[panel()](#panel/0)

Defines an element with the `:panel` tag.

[panel(attributes\_or\_children)](#panel/1)

Defines an element with the `:panel` tag and either

[panel(attributes, children)](#panel/2)

Defines an element with the `:panel` tag and the given attributes and

child elements.

[row()](#row/0)

Defines an element with the `:row` tag.

[row(attributes\_or\_children)](#row/1)

Defines an element with the `:row` tag and either

[row(attributes, children)](#row/2)

Defines an element with the `:row` tag and the given attributes and

child elements.

[sparkline()](#sparkline/0)

Defines an element with the `:sparkline` tag.

[sparkline(attributes)](#sparkline/1)

Defines an element with the `:sparkline` tag and the given attributes.

[table()](#table/0)

Defines an element with the `:table` tag.

[table(attributes\_or\_children)](#table/1)

Defines an element with the `:table` tag and either

[table(attributes, children)](#table/2)

Defines an element with the `:table` tag and the given attributes and

child elements.

[table\_cell()](#table_cell/0)

Defines an element with the `:table_cell` tag.

[table\_cell(attributes)](#table_cell/1)

Defines an element with the `:table_cell` tag and the given attributes.

[table\_row()](#table_row/0)

Defines an element with the `:table_row` tag.

[table\_row(attributes\_or\_children)](#table_row/1)

Defines an element with the `:table_row` tag and either

[table\_row(attributes, children)](#table_row/2)

Defines an element with the `:table_row` tag and the given attributes and

child elements.

[text()](#text/0)

Defines an element with the `:text` tag.

[text(attributes)](#text/1)

Defines an element with the `:text` tag and the given attributes.

[tree()](#tree/0)

Defines an element with the `:tree` tag.

[tree(attributes\_or\_children)](#tree/1)

Defines an element with the `:tree` tag and either

[tree(attributes, children)](#tree/2)

Defines an element with the `:tree` tag and the given attributes and

child elements.

[tree\_node()](#tree_node/0)

Defines an element with the `:tree_node` tag.

[tree\_node(attributes\_or\_children)](#tree_node/1)

Defines an element with the `:tree_node` tag and either

[tree\_node(attributes, children)](#tree_node/2)

Defines an element with the `:tree_node` tag and the given attributes and

child elements.

[view()](#view/0)

Defines an element with the `:view` tag.

[view(attributes\_or\_children)](#view/1)

Defines an element with the `:view` tag and either

[view(attributes, children)](#view/2)

Defines an element with the `:view` tag and the given attributes and

child elements.

[viewport()](#viewport/0)

Defines an element with the `:viewport` tag.

[viewport(attributes\_or\_children)](#viewport/1)

Defines an element with the `:viewport` tag and either

[viewport(attributes, children)](#viewport/2)

Defines an element with the `:viewport` tag and the given attributes and

child elements.

[Link to this section](#functions)

Functions

=============================================

[Link to this macro](#bar/0 "Link to this macro")

bar()

=====

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:bar` tag.

 Allowed Child Elements

-------------------------

* label

 Examples

-----------

Empty element:

```

bar()

```

With a block:

```

bar do

 # ...child elements...

end

```

[Link to this macro](#bar/1 "Link to this macro")

bar(attributes\_or\_children)

=============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:bar` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* label

 Examples

-----------

Passing attributes:

```

bar(key: value)

```

Passing attributes and a block:

```

bar(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

bar([elem1, elem2])

```

[Link to this macro](#bar/2 "Link to this macro")

bar(attributes, children)

=========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:bar` tag and the given attributes and

child elements.

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* label

 Examples

-----------

```

bar([key: value], [elem1, elem2])

```

[Link to this macro](#canvas/0 "Link to this macro")

canvas()

========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:canvas` tag.

 Allowed Child Elements

-------------------------

* canvas\_cell

 Examples

-----------

Empty element:

```

canvas()

```

With a block:

```

canvas do

 # ...child elements...

end

```

[Link to this macro](#canvas/1 "Link to this macro")

canvas(attributes\_or\_children)

================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:canvas` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `height` (required) - Integer representing the canvas height

* `width` (required) - Integer representing the canvas width

 Allowed Child Elements

-------------------------

* canvas\_cell

 Examples

-----------

Passing attributes:

```

canvas(key: value)

```

Passing attributes and a block:

```

canvas(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

canvas([elem1, elem2])

```

[Link to this macro](#canvas/2 "Link to this macro")

canvas(attributes, children)

============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:canvas` tag and the given attributes and

child elements.

 Attributes

-------------

* `height` (required) - Integer representing the canvas height

* `width` (required) - Integer representing the canvas width

 Allowed Child Elements

-------------------------

* canvas\_cell

 Examples

-----------

```

canvas([key: value], [elem1, elem2])

```

[Link to this macro](#canvas_cell/0 "Link to this macro")

canvas\_cell()

==============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L273 "View Source")

(macro)

Defines an element with the `:canvas_cell` tag.

 Examples

-----------

Empty element:

```

canvas\_cell()

```

[Link to this macro](#canvas_cell/1 "Link to this macro")

canvas\_cell(attributes)

========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L288 "View Source")

(macro)

Defines an element with the `:canvas_cell` tag and the given attributes.

 Attributes

-------------

* `x` (required) - Integer representing the cell's column (zero-indexed)

* `y` (required) - Integer representing the cell's row (zero-indexed)

* `color` (optional) - Constant representing color to use for foreground

* `char` (optional) - Single character to render within this cell

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Examples

-----------

```

canvas\_cell(key: value)

```

[Link to this macro](#chart/0 "Link to this macro")

chart()

=======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L273 "View Source")

(macro)

Defines an element with the `:chart` tag.

 Examples

-----------

Empty element:

```

chart()

```

[Link to this macro](#chart/1 "Link to this macro")

chart(attributes)

=================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L288 "View Source")

(macro)

Defines an element with the `:chart` tag and the given attributes.

 Attributes

-------------

* `series` (required) - List of float or integer values representing the series

* `type` (required) - Type of chart to plot. Currently only `:line` is supported

* `height` (optional) - Height of the chart in rows

 Examples

-----------

```

chart(key: value)

```

[Link to this macro](#column/0 "Link to this macro")

column()

========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:column` tag.

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Empty element:

```

column()

```

With a block:

```

column do

 # ...child elements...

end

```

[Link to this macro](#column/1 "Link to this macro")

column(attributes\_or\_children)

================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:column` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `size` (required) - Number of units on the grid that the column should occupy

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Passing attributes:

```

column(key: value)

```

Passing attributes and a block:

```

column(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

column([elem1, elem2])

```

[Link to this macro](#column/2 "Link to this macro")

column(attributes, children)

============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:column` tag and the given attributes and

child elements.

 Attributes

-------------

* `size` (required) - Number of units on the grid that the column should occupy

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

```

column([key: value], [elem1, elem2])

```

[Link to this function](#element/2 "Link to this function")

element(tag, attributes\_or\_children)

======================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L120 "View Source")

[Link to this function](#element/3 "Link to this function")

element(tag, attributes, children)

==================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L127 "View Source")

[Link to this macro](#label/0 "Link to this macro")

label()

=======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:label` tag.

 Allowed Child Elements

-------------------------

* text

 Examples

-----------

Empty element:

```

label()

```

With a block:

```

label do

 # ...child elements...

end

```

[Link to this macro](#label/1 "Link to this macro")

label(attributes\_or\_children)

===============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:label` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `content` (optional) - Binary containing the text content to be displayed

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

* `wrap` (optional) - Boolean indicating whether or not to wrap lines to fit available space

 Allowed Child Elements

-------------------------

* text

 Examples

-----------

Passing attributes:

```

label(key: value)

```

Passing attributes and a block:

```

label(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

label([elem1, elem2])

```

[Link to this macro](#label/2 "Link to this macro")

label(attributes, children)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:label` tag and the given attributes and

child elements.

 Attributes

-------------

* `content` (optional) - Binary containing the text content to be displayed

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

* `wrap` (optional) - Boolean indicating whether or not to wrap lines to fit available space

 Allowed Child Elements

-------------------------

* text

 Examples

-----------

```

label([key: value], [elem1, elem2])

```

[Link to this macro](#overlay/0 "Link to this macro")

overlay()

=========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:overlay` tag.

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Empty element:

```

overlay()

```

With a block:

```

overlay do

 # ...child elements...

end

```

[Link to this macro](#overlay/1 "Link to this macro")

overlay(attributes\_or\_children)

=================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:overlay` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `padding` (optional) - Integer number of units of padding

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Passing attributes:

```

overlay(key: value)

```

Passing attributes and a block:

```

overlay(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

overlay([elem1, elem2])

```

[Link to this macro](#overlay/2 "Link to this macro")

overlay(attributes, children)

=============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:overlay` tag and the given attributes and

child elements.

 Attributes

-------------

* `padding` (optional) - Integer number of units of padding

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

```

overlay([key: value], [elem1, elem2])

```

[Link to this macro](#panel/0 "Link to this macro")

panel()

=======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:panel` tag.

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Empty element:

```

panel()

```

With a block:

```

panel do

 # ...child elements...

end

```

[Link to this macro](#panel/1 "Link to this macro")

panel(attributes\_or\_children)

===============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:panel` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `color` (optional) - Color of title

* `background` (optional) - Background of title

* `attributes` (optional) - Attributes for the title

* `padding` (optional) - Integer providing inner padding to use when rendering child elements

* `height` (optional) - Height of the table in rows or `:fill` to fill the parent container's box

* `title` (optional) - Binary containing the title for the panel

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Passing attributes:

```

panel(key: value)

```

Passing attributes and a block:

```

panel(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

panel([elem1, elem2])

```

[Link to this macro](#panel/2 "Link to this macro")

panel(attributes, children)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:panel` tag and the given attributes and

child elements.

 Attributes

-------------

* `color` (optional) - Color of title

* `background` (optional) - Background of title

* `attributes` (optional) - Attributes for the title

* `padding` (optional) - Integer providing inner padding to use when rendering child elements

* `height` (optional) - Height of the table in rows or `:fill` to fill the parent container's box

* `title` (optional) - Binary containing the title for the panel

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

```

panel([key: value], [elem1, elem2])

```

[Link to this macro](#row/0 "Link to this macro")

row()

=====

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:row` tag.

 Allowed Child Elements

-------------------------

* column

 Examples

-----------

Empty element:

```

row()

```

With a block:

```

row do

 # ...child elements...

end

```

[Link to this macro](#row/1 "Link to this macro")

row(attributes\_or\_children)

=============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:row` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* column

 Examples

-----------

Passing attributes:

```

row(key: value)

```

Passing attributes and a block:

```

row(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

row([elem1, elem2])

```

[Link to this macro](#row/2 "Link to this macro")

row(attributes, children)

=========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:row` tag and the given attributes and

child elements.

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* column

 Examples

-----------

```

row([key: value], [elem1, elem2])

```

[Link to this macro](#sparkline/0 "Link to this macro")

sparkline()

===========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L273 "View Source")

(macro)

Defines an element with the `:sparkline` tag.

 Examples

-----------

Empty element:

```

sparkline()

```

[Link to this macro](#sparkline/1 "Link to this macro")

sparkline(attributes)

=====================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L288 "View Source")

(macro)

Defines an element with the `:sparkline` tag and the given attributes.

 Attributes

-------------

* `series` (required) - List of float or integer values representing the series

 Examples

-----------

```

sparkline(key: value)

```

[Link to this macro](#table/0 "Link to this macro")

table()

=======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:table` tag.

 Allowed Child Elements

-------------------------

* table\_row

 Examples

-----------

Empty element:

```

table()

```

With a block:

```

table do

 # ...child elements...

end

```

[Link to this macro](#table/1 "Link to this macro")

table(attributes\_or\_children)

===============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:table` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* table\_row

 Examples

-----------

Passing attributes:

```

table(key: value)

```

Passing attributes and a block:

```

table(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

table([elem1, elem2])

```

[Link to this macro](#table/2 "Link to this macro")

table(attributes, children)

===========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:table` tag and the given attributes and

child elements.

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* table\_row

 Examples

-----------

```

table([key: value], [elem1, elem2])

```

[Link to this macro](#table_cell/0 "Link to this macro")

table\_cell()

=============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L273 "View Source")

(macro)

Defines an element with the `:table_cell` tag.

 Examples

-----------

Empty element:

```

table\_cell()

```

[Link to this macro](#table_cell/1 "Link to this macro")

table\_cell(attributes)

=======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L288 "View Source")

(macro)

Defines an element with the `:table_cell` tag and the given attributes.

 Attributes

-------------

* `content` (required) - Binary containing the text content to be displayed

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Examples

-----------

```

table\_cell(key: value)

```

[Link to this macro](#table_row/0 "Link to this macro")

table\_row()

============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:table_row` tag.

 Allowed Child Elements

-------------------------

* table\_cell

 Examples

-----------

Empty element:

```

table\_row()

```

With a block:

```

table\_row do

 # ...child elements...

end

```

[Link to this macro](#table_row/1 "Link to this macro")

table\_row(attributes\_or\_children)

====================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:table_row` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Allowed Child Elements

-------------------------

* table\_cell

 Examples

-----------

Passing attributes:

```

table\_row(key: value)

```

Passing attributes and a block:

```

table\_row(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

table\_row([elem1, elem2])

```

[Link to this macro](#table_row/2 "Link to this macro")

table\_row(attributes, children)

================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:table_row` tag and the given attributes and

child elements.

 Attributes

-------------

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Allowed Child Elements

-------------------------

* table\_cell

 Examples

-----------

```

table\_row([key: value], [elem1, elem2])

```

[Link to this macro](#text/0 "Link to this macro")

text()

======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L273 "View Source")

(macro)

Defines an element with the `:text` tag.

 Examples

-----------

Empty element:

```

text()

```

[Link to this macro](#text/1 "Link to this macro")

text(attributes)

================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L288 "View Source")

(macro)

Defines an element with the `:text` tag and the given attributes.

 Attributes

-------------

* `content` (required) - Binary containing the text content to be displayed

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Examples

-----------

```

text(key: value)

```

[Link to this macro](#tree/0 "Link to this macro")

tree()

======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:tree` tag.

 Allowed Child Elements

-------------------------

* tree\_node

 Examples

-----------

Empty element:

```

tree()

```

With a block:

```

tree do

 # ...child elements...

end

```

[Link to this macro](#tree/1 "Link to this macro")

tree(attributes\_or\_children)

==============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:tree` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* tree\_node

 Examples

-----------

Passing attributes:

```

tree(key: value)

```

Passing attributes and a block:

```

tree(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

tree([elem1, elem2])

```

[Link to this macro](#tree/2 "Link to this macro")

tree(attributes, children)

==========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:tree` tag and the given attributes and

child elements.

 Attributes

-------------

None

 Allowed Child Elements

-------------------------

* tree\_node

 Examples

-----------

```

tree([key: value], [elem1, elem2])

```

[Link to this macro](#tree_node/0 "Link to this macro")

tree\_node()

============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:tree_node` tag.

 Allowed Child Elements

-------------------------

* tree\_node

 Examples

-----------

Empty element:

```

tree\_node()

```

With a block:

```

tree\_node do

 # ...child elements...

end

```

[Link to this macro](#tree_node/1 "Link to this macro")

tree\_node(attributes\_or\_children)

====================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:tree_node` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `content` (required) - Binary label for the node

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Allowed Child Elements

-------------------------

* tree\_node

 Examples

-----------

Passing attributes:

```

tree\_node(key: value)

```

Passing attributes and a block:

```

tree\_node(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

tree\_node([elem1, elem2])

```

[Link to this macro](#tree_node/2 "Link to this macro")

tree\_node(attributes, children)

================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:tree_node` tag and the given attributes and

child elements.

 Attributes

-------------

* `content` (required) - Binary label for the node

* `color` (optional) - Constant representing color to use for foreground

* `background` (optional) - Constant representing color to use for background

* `attributes` (optional) - Constant representing style attributes to apply

 Allowed Child Elements

-------------------------

* tree\_node

 Examples

-----------

```

tree\_node([key: value], [elem1, elem2])

```

[Link to this macro](#view/0 "Link to this macro")

view()

======

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:view` tag.

 Allowed Child Elements

-------------------------

* overlay

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Empty element:

```

view()

```

With a block:

```

view do

 # ...child elements...

end

```

[Link to this macro](#view/1 "Link to this macro")

view(attributes\_or\_children)

==============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:view` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `top_bar` (optional) - A `:bar` element to occupy the view's first row

* `bottom_bar` (optional) - A `:bar` element to occupy the view's last row

 Allowed Child Elements

-------------------------

* overlay

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Passing attributes:

```

view(key: value)

```

Passing attributes and a block:

```

view(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

view([elem1, elem2])

```

[Link to this macro](#view/2 "Link to this macro")

view(attributes, children)

==========================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:view` tag and the given attributes and

child elements.

 Attributes

-------------

* `top_bar` (optional) - A `:bar` element to occupy the view's first row

* `bottom_bar` (optional) - A `:bar` element to occupy the view's last row

 Allowed Child Elements

-------------------------

* overlay

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

```

view([key: value], [elem1, elem2])

```

[Link to this macro](#viewport/0 "Link to this macro")

viewport()

==========

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L195 "View Source")

(macro)

Defines an element with the `:viewport` tag.

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Empty element:

```

viewport()

```

With a block:

```

viewport do

 # ...child elements...

end

```

[Link to this macro](#viewport/1 "Link to this macro")

viewport(attributes\_or\_children)

==================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L199 "View Source")

(macro)

Defines an element with the `:viewport` tag and either:

* given attributes and an optional block

* a list of child elements

 Attributes

-------------

* `offset_x` (optional) - Integer representing the number of columns to offset the child content by. Defaults to 0.

* `offset_y` (optional) - Integer representing the number of rows to offset the child content by. Defaults to 0.

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

Passing attributes:

```

viewport(key: value)

```

Passing attributes and a block:

```

viewport(key: value) do

 # ...child elements...

end

```

Passing list of children:

```

viewport([elem1, elem2])

```

[Link to this macro](#viewport/2 "Link to this macro")

viewport(attributes, children)

==============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/view.ex#L238 "View Source")

(macro)

Defines an element with the `:viewport` tag and the given attributes and

child elements.

 Attributes

-------------

* `offset_x` (optional) - Integer representing the number of columns to offset the child content by. Defaults to 0.

* `offset_y` (optional) - Integer representing the number of rows to offset the child content by. Defaults to 0.

 Allowed Child Elements

-------------------------

* canvas

* chart

* label

* panel

* row

* sparkline

* table

* tree

* viewport

 Examples

-----------

```

viewport([key: value], [elem1, elem2])

```





Ratatouille.Window — Ratatouille v0.5.1

try { if(localStorage.getItem('night-mode') === 'true') document.body.className += ' night-mode'; } catch (e) { }

Ratatouille v0.5.1

Ratatouille.Window [View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L1 "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)

 Summary

==========================================

[Types](#types)

----------------

[fetch\_attr()](#t:fetch_attr/0)

[Functions](#functions)

------------------------

[child\_spec(init\_arg)](#child_spec/1)

Returns a specification to start this module under a supervisor.

[close(pid \\ \_\_MODULE\_\_)](#close/1)

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)](#fetch/2)

Fetches an attribute for the window. This is currently limited to the window

dimensions, which can be useful when laying out content.

[start\_link(opts \\ [])](#start_link/1)

Starts the gen\_server representing the window.

[update(pid \\ \_\_MODULE\_\_, view)](#update/2)

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

presenting it.

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:fetch_attr/0 "Link to this type")

fetch\_attr()

=============

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L75 "View Source")

```

fetch_attr() :: :width | :height | :box

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#child_spec/1 "Link to this function")

child\_spec(init\_arg)

======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L7 "View Source")

Returns a specification to start this module under a supervisor.

See [`Supervisor`](https://hexdocs.pm/elixir/Supervisor.html).

[Link to this function](#close/1 "Link to this function")

close(pid \\ \_\_MODULE\_\_)

============================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L73 "View Source")

```

close([GenServer.server](https://hexdocs.pm/elixir/GenServer.html#t:server/0)()) :: :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/2 "Link to this function")

fetch(pid \\ \_\_MODULE\_\_, attr)

==================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L92 "View Source")

```

fetch([GenServer.server](https://hexdocs.pm/elixir/GenServer.html#t:server/0)(), [fetch\_attr](#t:fetch_attr/0)()) :: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

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/1 "Link to this function")

start\_link(opts \\ [])

=======================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L38 "View Source")

```

start_link([Keyword.t](https://hexdocs.pm/elixir/Keyword.html#t:t/0)()) :: [GenServer.on\_start](https://hexdocs.pm/elixir/GenServer.html#t:on_start/0)()

```

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 to [`GenServer.start_link/3`](https://hexdocs.pm/elixir/GenServer.html#start_link/3). By

```

 default, `name: Ratatouille.Window` is passed in order to

 protect against accidental double initialization, but this

 can be overridden by passing `nil` or an alternate value.

```

* `:input_mode` - Configure the input mode. See [`Ratatouille.Constants.input_mode/1`](Ratatouille.Constants.html#input_mode/1)

```

 for possible values.

```

* `:output_mode` - Configure the output mode. See [`Ratatouille.Constants.output_mode/1`](Ratatouille.Constants.html#output_mode/1)

```

 for possible values.

```

[Link to this function](#update/2 "Link to this function")

update(pid \\ \_\_MODULE\_\_, view)

===================================

[View Source](https://github.com/ndreynolds/ratatouille/blob/master/lib/ratatouille/window.ex#L66 "View Source")

```

update([GenServer.server](https://hexdocs.pm/elixir/GenServer.html#t:server/0)(), Ratatouille.Renderer.Element.t()) :: :ok

```

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

presenting it.

