What a driver writes to turn pixel mouse reporting (SGR-Pixels, DECSET 1016) on and off, and when.
A driver keeps one of three states per terminal:
:off— mouse reports are in cells.:waiting— pixel reports are wanted, but the terminal has not yet said how big a cell is, so pixels could not be turned into cells. The driver has asked.:on— mode 1016 has been set and the terminal asked whether it took.
Each function returns the new state and the bytes to write. Reports are read as
pixels only after the terminal answers Drafter.Terminal.Reports.pixel_mouse_query/0
with {:pixel_mouse, true}; a terminal that ignores mode 1016 answers false, its
reports stay in cells, and their payloads carry no :px. Every terminal that knows
mode 1016 answers the query; a terminal that answers neither yes nor no keeps cell
reading.
iex> Drafter.Terminal.PixelMouse.enable(:off, nil)
{:waiting, "\e[16t"}
iex> Drafter.Terminal.PixelMouse.after_input(:waiting, {8, 16})
{:on, "\e[?1016h\e[?1016$p"}
Summary
Functions
Call after decoding input, with the cell size now known: a :waiting driver sets
mode 1016 and asks whether it took once the cell size has arrived.
What to write when the terminal is restored: mode 1016 off when it was set.
Return to cell reports. The terminal's answer to the query that follows turns pixel reading off in the parser.
Ask for pixel reports. Sets mode 1016 at once when the cell size is known, and asks for the cell size otherwise.
What to write when the terminal is resized: the cell size query while pixel reports are on, since a change of font size changes both the grid and the cell.
The state a driver starts in for its pixel_mouse setup option. A driver starting
in :waiting must ask for the cell size among its startup queries.
Types
@type cell_size() :: {pos_integer(), pos_integer()} | nil
The terminal's cell size in pixels, or nil when it has not reported one.
@type t() :: :off | :waiting | :on
Functions
Call after decoding input, with the cell size now known: a :waiting driver sets
mode 1016 and asks whether it took once the cell size has arrived.
What to write when the terminal is restored: mode 1016 off when it was set.
Return to cell reports. The terminal's answer to the query that follows turns pixel reading off in the parser.
Ask for pixel reports. Sets mode 1016 at once when the cell size is known, and asks for the cell size otherwise.
What to write when the terminal is resized: the cell size query while pixel reports are on, since a change of font size changes both the grid and the cell.
The state a driver starts in for its pixel_mouse setup option. A driver starting
in :waiting must ask for the cell size among its startup queries.
iex> Drafter.Terminal.PixelMouse.start(true)
:waiting