ElementTui

An Elixir library to create terminal user interfaces (tui), using termbox2 under the hood. Current functionality was build to support rtttex, but I am happy with the base functionality and open to merge requests to improve and expand it.

Installation

The package can be installed by adding elementtui to your list of dependencies in mix.exs:

def deps do
  [
    {:elementtui, "~> 0.4"}
  ]
end

Usage

There are some simple examples available on codeberg that should help you get started. Also see the documentation on hexdocs.

Minimal hello world example:

ElementTui.run_loop(
  fn _, ev ->
    case ev do
      {:key,  _, _, ?q} ->
        {:halt, nil}

      _ ->
        ElementTui.Element.text("Hello World")
        |> ElementTui.render(5, 5, 100, 1)

        ElementTui.present()

        {:cont, nil}
    end
  end,
  nil,
  timeout: 1000
)

Note that when starting your own project you need to make sure elixir/erlang does not listen for input, by setting -noinput in the mix.exs file.

Examples

For the code to create these examples see codeberg/elementtui_examples

Performance example

performance

Popup example

popup