class

Phosphor::MouseEvent

Inherits Phosphor::Event < Reference < Object

A mouse action (press, release, drag, or wheel) received from the terminal.

x and y are 0-based, matching Frame coordinates. modifiers is a placeholder bitmask for Shift/Ctrl/Alt state.

Constants

BUTTONS = [MouseButton::Left, MouseButton::Middle, MouseButton::Right, MouseButton::Unknown]

MouseButton values in the order the SGR button byte's low 2 bits encode them — index 3 ("11") is unassigned by the protocol, hence Unknown. Only meaningful for Press/Release/Drag; wheel events reuse these same bits for scroll direction instead.

Constructors

new(kind : MouseKind, button : MouseButton, x : Int32, y : Int32, modifiers : Int32 = 0)
Source

Class methods

from_sgr?(bytes : Bytes) : MouseEvent | Nil

Parses an SGR extended mouse sequence (\e[<Cb;Cx;CyM or \e[<Cb;Cx;Cym) into a MouseEvent, or returns nil if bytes is not a valid SGR report.

Cx/Cy are 1-based in the wire format; subtracted by 1 here so the resulting MouseEvent#x/#y are 0-based, matching Frame coordinates. modifiers encodes Shift (1), Alt (2), and Ctrl (4) from the button byte's upper bits.

Source

Instance methods

button
Source
kind
Source
modifiers
Source