pub enum Event {
Show 42 variants
KeyPress(Key),
KeyRepeat(Key),
KeyRelease(Key),
MouseClick(Mouse),
MouseRelease(Mouse),
MouseWheel(Mouse),
MouseMove(Mouse),
Resize(Winsize),
WindowCellSize {
width: u16,
height: u16,
},
WindowPixelSize {
width: u16,
height: u16,
},
CellPixelSize {
width: u16,
height: u16,
},
FocusIn,
FocusOut,
PasteStart,
PasteEnd,
PasteChunk(Vec<u8>),
CursorPosition(Position),
PrimaryDeviceAttributes(Vec<Option<u32>>),
SecondaryDeviceAttributes(Vec<Option<u32>>),
TertiaryDeviceAttributes(String),
TerminalName(String),
ModeReport {
mode: Mode,
setting: ModeSetting,
},
ModifyOtherKeys(ModifyOtherKeysMode),
KittyKeyboardEnhancements(KittyKeyboardFlags),
WindowOp {
op: u32,
args: Vec<Option<u32>>,
},
Termcap {
recognized: bool,
payload: String,
},
ForegroundColor(Color),
BackgroundColor(Color),
CursorColor(Color),
PaletteColor {
index: u8,
color: Color,
},
ColorScheme(ColorScheme),
Clipboard {
selection: ClipboardSelection,
content: String,
},
KittyGraphics {
options: Vec<(String, String)>,
payload: Vec<u8>,
},
Multi(Vec<Event>),
UnknownCsi(Vec<u8>),
UnknownSs3(Vec<u8>),
UnknownOsc(Vec<u8>),
UnknownDcs(Vec<u8>),
UnknownSos(Vec<u8>),
UnknownPm(Vec<u8>),
UnknownApc(Vec<u8>),
Unknown(Vec<u8>),
}Expand description
A terminal event.
Variants§
KeyPress(Key)
Key was pressed.
KeyRepeat(Key)
Key auto-repeated (Kitty Keyboard Protocol).
KeyRelease(Key)
Key was released (Kitty Keyboard Protocol).
MouseClick(Mouse)
Mouse button was pressed.
MouseRelease(Mouse)
Mouse button was released.
MouseWheel(Mouse)
Mouse wheel scrolled.
MouseMove(Mouse)
Mouse moved (with or without a button held).
Resize(Winsize)
The terminal surface changed size. Emitted only for genuine
change notifications: kernel SIGWINCH (full Winsize),
ReadConsoleInput window-buffer-size events on Windows
(cells only), and in-band CSI 48 t reports under mode 2048
(full Winsize). Replies to explicit size queries are
delivered as WindowCellSize / WindowPixelSize /
CellPixelSize instead.
WindowCellSize
Reply to a CSI 18 t query — window size in cells.
WindowPixelSize
Reply to a CSI 14 t query — window size in pixels.
CellPixelSize
Reply to a CSI 16 t query — single-cell size in pixels.
FocusIn
Focus gained.
FocusOut
Focus lost.
PasteStart
Bracketed paste started.
PasteEnd
Bracketed paste ended.
PasteChunk(Vec<u8>)
Streaming chunk of pasted bytes emitted between Event::PasteStart
and Event::PasteEnd. Pastes that exceed the source’s read
buffer are split across multiple chunks; reassembly and any
text decoding are the caller’s responsibility (terminals may
paste arbitrary binary content, not just valid UTF-8).
CursorPosition(Position)
Cursor position report (CPR). Coordinates are zero-based (the 1-based wire form is normalized when parsed).
PrimaryDeviceAttributes(Vec<Option<u32>>)
Primary device attributes (DA1) — list of decoded numeric attributes.
SecondaryDeviceAttributes(Vec<Option<u32>>)
Secondary device attributes (DA2).
TertiaryDeviceAttributes(String)
Tertiary device attributes (DA3) — terminal ID string.
TerminalName(String)
Terminal name reply (XTVERSION). Carries the raw identifier string,
which typically combines a name and version (e.g. "XTerm(380)").
ModeReport
DECRPM / RM mode report.
The setting distinguishes all five DECRPM states. A terminal can
report a mode as permanently set or permanently reset, meaning it
recognizes the mode but will not let the host toggle it. When deciding
whether a feature is usable, prefer
ModeSetting::is_available
over is_recognized: a
permanently reset mode is recognized yet can never be enabled.
ModifyOtherKeys(ModifyOtherKeysMode)
modifyOtherKeys report.
KittyKeyboardEnhancements(KittyKeyboardFlags)
Kitty keyboard protocol active-enhancements report
(CSI ? <flags> u). The payload is the parsed
crate::ansi::kitty::KittyKeyboardFlags bitset.
WindowOp
XTWINOPS reply (window operation).
Termcap
XTGETTCAP / termcap capability reply. recognized is true for a
successful reply (DCS 1 + r) and false for a failure
(DCS 0 + r); payload is the decoded ;-joined cap[=value]
string, decoded the same way in both cases (a failure echoes the
requested, now known-unsupported, capability names).
Fields
ForegroundColor(Color)
OSC 10 default foreground color reply.
BackgroundColor(Color)
OSC 11 default background color reply.
CursorColor(Color)
OSC 12 cursor color reply.
PaletteColor
OSC 4 indexed palette color reply (OSC 4 ; index ; color).
ColorScheme(ColorScheme)
Color-scheme report (DEC mode 2031): whether the terminal is in its dark or light scheme. Indicates only the dark/light preference, not the actual colors.
Clipboard
OSC 52 clipboard content reply.
Fields
selection: ClipboardSelectionClipboard selection that was reported.
KittyGraphics
Kitty graphics response (APC G ... payload).
Multi(Vec<Event>)
Multiple events emitted by a single sequence.
UnknownCsi(Vec<u8>)
Unknown CSI sequence (parameters + intermediates + final byte).
UnknownSs3(Vec<u8>)
Unknown SS3 sequence.
UnknownOsc(Vec<u8>)
Unknown OSC sequence (payload bytes, no ESC/ST framing).
UnknownDcs(Vec<u8>)
Unknown DCS sequence (payload).
UnknownSos(Vec<u8>)
Unknown SOS sequence (payload).
UnknownPm(Vec<u8>)
Unknown PM sequence (payload).
UnknownApc(Vec<u8>)
Unknown APC sequence (payload).
Unknown(Vec<u8>)
Catch-all for unrecognized byte sequences.
Implementations§
Source§impl Event
impl Event
Sourcepub fn as_key(&self) -> Option<&Key>
pub fn as_key(&self) -> Option<&Key>
Borrow the Key payload if this is any key event
(Event::KeyPress, Event::KeyRepeat, or
Event::KeyRelease).
Sourcepub fn as_mouse(&self) -> Option<&Mouse>
pub fn as_mouse(&self) -> Option<&Mouse>
Borrow the Mouse payload if this is any mouse event
(Event::MouseClick, Event::MouseRelease,
Event::MouseWheel, or Event::MouseMove).