module

TermBuf::Input::Mouse

What the terminal says the pointer did, taken out of an SGR mouse report.

SGR — DEC private mode 1006 — is the encoding worth decoding: the older one packs the coordinates into single bytes and cannot name a column past 223, and it has no way to say which button was let go. An SGR report is CSI < button ; column ; row M for a press and the same with a final m for a release, all of it in decimal.

Turning the reporting on is the application's call, through whatever its driver offers. Decoding is not: Input::Stream watches for CSI < from the moment it is built, so a report arrives as Events::Mouse whoever asked for it.

Constants

ALT = 8

Alt, or meta, was held.

CTRL = 16

Control was held.

EXTENDED = 128

The bit that says the button field names one of buttons 8 to 11.

MOTION = 32

The bit that says the pointer moved rather than being clicked.

SHIFT = 4

Shift was held.

WHEEL = 64

The bit that says the button field names a wheel notch.

Class methods

action(code : Int32, final : Char) : Action

What happened. The final byte separates a press from a release, and the motion bit turns a press into a drag.

Source
button(code : Int32) : Button

Which button code names.

The button lives in the low two bits, and one of two flags above them says which set of four to read them against: the wheel, buttons 8 to 11, or — with neither flag — left, middle, right and none.

Source
decode(sequence : Input::Sequence) : Events::Mouse | Nil

What sequence says the pointer did, or nil if it is not an SGR mouse report after all.

Returning nil is how a pattern says "not mine": a CSI < that is not a report — a truncated one, a field that is not a number, a coordinate at zero — carries on to the key decoder and arrives as Key::Name::Unknown, which beats inventing a click nobody made.

Source
modifiers(code : Int32) : Modifiers

What was held down alongside it.

Source

Nested types