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

The terminal the program runs in, used without the alternate screen.

`open/1` returns a terminal for the calling process, which must also be the process
that uses and closes it:

    {:ok, terminal} = Drafter.Prompt.Terminal.Local.open()
    {event, terminal} = Drafter.Prompt.Terminal.next_event(terminal, :infinity)
    Drafter.Prompt.Terminal.close(terminal)

## Options

  * `:input` - `boolean()`, default `true`. With `true` the terminal is put into raw
    mode, bracketed paste is turned on and keys are read through
    `Drafter.Terminal.Stdin`; closing the terminal undoes all three and leaves the
    terminal in line mode, where a line feed returns to the first column. With `false` the terminal
    mode is left alone and `next_event/2` only waits.

Frames are written to `/dev/tty`, and to standard output where that cannot be
opened. While a terminal opened with `input: true` is open, `Ctrl+C` arrives as the
event `{:key, :c, [:ctrl]}`.

Events decoded but not consumed when the terminal closes are kept for the next
terminal the same process opens.

# `t`

```elixir
@type t() :: %Drafter.Prompt.Terminal.Local{
  buffer: Drafter.Terminal.InputBuffer.t() | nil,
  device: :file.io_device() | :stdio,
  events: [Drafter.Prompt.Terminal.event()],
  input: boolean(),
  mode: Drafter.Terminal.RawMode.mode(),
  region: Drafter.Prompt.Region.t()
}
```

# `available?`

```elixir
@spec available?() :: boolean()
```

Whether prompts can be drawn here: standard input is a terminal and `TERM` is not
`dumb`.

# `open`

```elixir
@spec open(keyword()) :: {:ok, t()} | {:error, term()}
```

Open the terminal for the calling process.

`{:error, reason}` means the terminal could not be put into raw mode; nothing was
changed.

# `stdin_terminal?`

```elixir
@spec stdin_terminal?() :: boolean()
```

Whether standard input is a terminal.

---

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