# `Minga.Core.Decorations.VirtualText`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/core/decorations/virtual_text.ex#L1)

A virtual text decoration: display-only text injected at a buffer position.

Virtual text is rendered on screen but does not exist in the buffer content.
The cursor skips over it. Yank ignores it. It occupies screen columns (for
inline/EOL) or screen rows (for above/below) and the viewport accounts for
its dimensions, but buffer operations are unaware of it.

## Placement modes

- `:inline` - text appears at the anchor column, pushing subsequent buffer
  content to the right on the same line
- `:eol` - text appears after the last character of the anchor line,
  separated by at least one space
- `:above` - entire styled lines injected above the anchor line
- `:below` - entire styled lines injected below the anchor line

# `placement`

```elixir
@type placement() :: :inline | :eol | :above | :below
```

Placement mode for virtual text.

- `:inline` - at the anchor column, displacing buffer content rightward
- `:eol` - after the last character of the anchor line
- `:above` - full lines injected above the anchor line
- `:below` - full lines injected below the anchor line

# `segment`

```elixir
@type segment() :: {text :: String.t(), style :: Minga.Core.Face.t()}
```

A styled text segment: the text string and its Face style.

# `t`

```elixir
@type t() :: %Minga.Core.Decorations.VirtualText{
  anchor: Minga.Core.IntervalTree.position(),
  group: term() | nil,
  id: reference(),
  placement: placement(),
  priority: integer(),
  segments: [segment()]
}
```

# `display_width`

```elixir
@spec display_width(t()) :: non_neg_integer()
```

Returns the total display width of the virtual text segments.

# `segments_display_width`

```elixir
@spec segments_display_width([segment()]) :: non_neg_integer()
```

Returns the total display width of a list of styled segments.

---

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