Drafter.Terminal.Reports (drafter v0.5.6)

Copy Markdown View Source

Replies to the questions a driver asks a terminal at startup, other than the graphics and keyboard ones.

cell_size_query/0 asks for the size of one cell in pixels; size_queries/0 asks for that in both the standard form and iTerm2's own (OSC 1337 ; ReportCellSize), the text area's size in pixels and its size in cells. The replies parse to {:cell_size, {width, height}} (CSI 6 ; height ; width t), {:window_pixels, {width, height}} (CSI 4 ; height ; width t) and {:text_cells, {cols, rows}} (CSI 8 ; rows ; cols t); iTerm2's OSC 1337 ; ReportCellSize = height ; width ; scale reply, sizes in points, parses to {:cell_size, {width × scale, height × scale}} in pixels. A terminal may answer some and not others.

iex> Drafter.Terminal.Reports.parse("\e]1337;ReportCellSize=13.0;6.0;2.0\e\\")
{[{:cell_size, {12, 26}}], ""}

iex> Drafter.Terminal.Reports.parse("\e[4;745;1353t\e[8;59;221t")
{[{:window_pixels, {1353, 745}}], "\e[8;59;221t"}

pixel_mouse_query/0 asks whether pixel mouse reporting (mode 1016) is set; the reply CSI ? 1016 ; status $ y parses to {:pixel_mouse, true} when the status is 1 (set) or 3 (permanently set), and {:pixel_mouse, false} for any other status, including 0 from a terminal that does not know the mode.

iex> Drafter.Terminal.Reports.parse("\e[?1016;1$y")
{[{:pixel_mouse, true}], ""}

iex> Drafter.Terminal.Reports.parse("\e[?1016;0$y")
{[{:pixel_mouse, false}], ""}

Summary

Types

An event a report parses to.

Functions

The sequence that asks the terminal how many pixels one cell is.

Parse a report at the head of buffer, or :no_match.

The sequence that asks the terminal whether pixel mouse reporting is set.

The sequences that ask the terminal how many pixels one cell is, how many pixels its text area is, and how many cells, for terminals that answer only some of them.

Types

report()

@type report() ::
  {:cell_size, {pos_integer(), pos_integer()}}
  | {:window_pixels, {pos_integer(), pos_integer()}}
  | {:text_cells, {pos_integer(), pos_integer()}}
  | {:pixel_mouse, boolean()}

An event a report parses to.

Functions

cell_size_query()

@spec cell_size_query() :: String.t()

The sequence that asks the terminal how many pixels one cell is.

parse(arg1)

@spec parse(binary()) :: {[report()], binary()} | :no_match

Parse a report at the head of buffer, or :no_match.

pixel_mouse_query()

@spec pixel_mouse_query() :: String.t()

The sequence that asks the terminal whether pixel mouse reporting is set.

size_queries()

@spec size_queries() :: String.t()

The sequences that ask the terminal how many pixels one cell is, how many pixels its text area is, and how many cells, for terminals that answer only some of them.