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

Redraws a few lines in place below the shell prompt, without the alternate screen.

A region remembers how many lines it last drew and which of them holds the terminal
cursor. Every function returns the bytes to write and the region to keep; nothing
here writes to a terminal.

    {bytes, region} = Drafter.Prompt.Region.draw(%Drafter.Prompt.Region{}, frame, {80, 24})
    {bytes, region} = Drafter.Prompt.Region.leave(region)

The cursor must be at the start of an empty line before the first `draw/3`. Lines
are cut to one column less than the terminal's width and the frame to one line less
than its height, so a frame never wraps or scrolls past the top of the screen.
Every line break written is `\r\n`.

# `size`

```elixir
@type size() :: {pos_integer(), pos_integer()}
```

# `t`

```elixir
@type t() :: %Drafter.Prompt.Region{
  cursor_row: non_neg_integer(),
  height: non_neg_integer()
}
```

# `clear`

```elixir
@spec clear(t()) :: {iodata(), t()}
```

Erase the frame and leave the cursor where its first line was.

The returned region is empty.

# `draw`

```elixir
@spec draw(t(), Drafter.Prompt.Frame.t(), size()) :: {iodata(), t()}
```

Draw `frame` over whatever the region drew last.

Lines left over from a taller previous frame are erased. The cursor is shown at the
frame's cursor position, or hidden at the end of the last line when the frame has
none.

# `leave`

```elixir
@spec leave(t()) :: {iodata(), t()}
```

Move the cursor to the start of the line below the frame and show it.

The frame stays on screen. The returned region is empty, so the next `draw/3` starts
a new frame there.

---

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