Skip to main content

Event

Enum Event 

Source
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.

Fields

§width: u16

Width in terminal cells.

§height: u16

Height in terminal cells.

§

WindowPixelSize

Reply to a CSI 14 t query — window size in pixels.

Fields

§width: u16

Width in pixels.

§height: u16

Height in pixels.

§

CellPixelSize

Reply to a CSI 16 t query — single-cell size in pixels.

Fields

§width: u16

Cell width in pixels.

§height: u16

Cell height 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.

Fields

§mode: Mode

Reported mode.

§setting: ModeSetting

Current mode setting.

§

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).

Fields

§op: u32

Window operation number.

§args: Vec<Option<u32>>

Window operation arguments.

§

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

§recognized: bool

Whether the requested capability was recognized.

§payload: String

Decoded capability payload.

§

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).

Fields

§index: u8

Palette color index.

§color: Color

Reported palette 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: ClipboardSelection

Clipboard selection that was reported.

§content: String

Clipboard content.

§

KittyGraphics

Kitty graphics response (APC G ... payload).

Fields

§options: Vec<(String, String)>

Response options.

§payload: Vec<u8>

Response payload bytes.

§

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

Source

pub fn as_key(&self) -> Option<&Key>

Borrow the Key payload if this is any key event (Event::KeyPress, Event::KeyRepeat, or Event::KeyRelease).

Source

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).

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Event

Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,