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

A terminal whose keys come from a list and whose output is kept as text.

Events are handed out in order, and `:closed` once they run out. Only committed
frames and printed text are kept; frames drawn on the way are dropped, so the
transcript does not depend on timing.

    terminal = Drafter.Prompt.Terminal.Scripted.start([{:key, :y}])
    {{:key, :y}, terminal} = Drafter.Prompt.Terminal.next_event(terminal, :infinity)
    {:closed, _terminal} = Drafter.Prompt.Terminal.next_event(terminal, :infinity)
    Drafter.Prompt.Terminal.Scripted.stop(terminal)

The terminal is a process, so it can be used from any process and by several
prompts in a row. `Drafter.Prompt.Script` wraps it for tests.

## Options

  * `:size` - `{columns, rows}` reported to prompts. Default `{80, 24}`.

# `t`

```elixir
@type t() :: %Drafter.Prompt.Terminal.Scripted{
  size: {pos_integer(), pos_integer()},
  store: pid()
}
```

# `remaining`

```elixir
@spec remaining(t()) :: [Drafter.Prompt.Terminal.event()]
```

The events not yet handed out.

# `start`

```elixir
@spec start(
  [Drafter.Prompt.Terminal.event()],
  keyword()
) :: t()
```

Start a terminal that will hand out `events`.

# `stop`

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

Stop the terminal's process.

# `transcript`

```elixir
@spec transcript(t()) :: String.t()
```

Everything committed and printed so far, as plain text.

---

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