Minga.Core.Decorations.VirtualText (Minga v0.1.0)

Copy Markdown View Source

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

Summary

Types

Placement mode for virtual text.

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

t()

Functions

Returns the total display width of the virtual text segments.

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

Types

placement()

@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()

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

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

t()

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

Functions

display_width(virtual_text)

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

Returns the total display width of the virtual text segments.

segments_display_width(segments)

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

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