# `Drafter.Prompt.Terminal`
[🔗](https://github.com/jaman/drafter/blob/v0.6.0/lib/drafter/prompt/terminal.ex#L1)

Where a prompt is shown and where its keys come from.

Three implementations ship with Drafter:

  * `Drafter.Prompt.Terminal.Local` — the terminal the program runs in
  * `Drafter.Prompt.Terminal.Piped` — standard input and output when they are not a
    terminal
  * `Drafter.Prompt.Terminal.Scripted` — keys from a list, for tests

Functions that change what the terminal remembers return the terminal to keep
using.

# `event`

```elixir
@type event() :: Drafter.Terminal.ANSI.event()
```

A key or paste event as `Drafter.Terminal.ANSI` decodes it.

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `close`

```elixir
@spec close(t()) :: :ok
```

Give the terminal back. The terminal must not be used afterwards.

# `commit`

```elixir
@spec commit(t(), Drafter.Prompt.Frame.t()) :: t()
```

Show `frame` as the last frame and move below it, so later output follows it.

# `draw`

```elixir
@spec draw(t(), Drafter.Prompt.Frame.t()) :: t()
```

Show `frame` in place of the frame drawn before it.

# `interactive?`

```elixir
@spec interactive?(t()) :: boolean()
```

Whether the terminal redraws frames and delivers keys one at a time.

# `next_event`

```elixir
@spec next_event(t(), timeout()) :: {event() | :timeout | :closed, t()}
```

Wait up to `timeout` for the next event.

Returns the event, `:timeout`, or `:closed` when no more input can arrive.

# `print`

```elixir
@spec print(t(), iodata()) :: t()
```

Write `text` where the current frame is, pushing the frame out of the way.

The frame is erased; draw it again afterwards.

# `size`

```elixir
@spec size(t()) :: {pos_integer(), pos_integer()}
```

The terminal's size as `{columns, rows}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
