Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder<'alloc>(/* private fields */);
Expand description

Mouse encoder that converts normalized mouse events into terminal escape sequences.

Implementations§

Source§

impl<'alloc> Encoder<'alloc>

Source

pub fn new() -> Result<Self>

Create a new mouse encoder instance.

Source

pub fn new_with_alloc<'ctx: 'alloc, Ctx>( alloc: &'alloc Allocator<'ctx, Ctx>, ) -> Result<Self>

Create a new mouse encoder instance with a custom allocator.

See the crate-level documentation regarding custom memory management and lifetimes.

Source

pub fn encode_to_vec( &mut self, event: &Event<'_>, vec: &mut Vec<u8>, ) -> Result<()>

Encode a key event into a terminal escape sequence.

Converts a key event into the appropriate terminal escape sequence based on the encoder’s current options. The provided Vec byte buffer will be grown automatically if more capacity is needed.

Not all key events produce output. For example, unmodified modifier keys typically don’t generate escape sequences. Check the returned usize to determine if any data was written.

Source

pub fn encode(&mut self, event: &Event<'_>, buf: &mut [u8]) -> Result<usize>

Encode a mouse event into a terminal escape sequence.

Not all mouse events produce output. In such cases this returns Ok(0).

If the output buffer is too small, this returns Err(Error::OutOfSpace { required }) where required is the required size.

Source

pub fn set_options_from_terminal( &mut self, terminal: &Terminal<'_, '_>, ) -> &mut Self

Set encoder options from a terminal’s current state.

This sets tracking mode and output format from terminal state. It does not modify size or any-button state.

Source

pub fn set_tracking_mode(&mut self, value: TrackingMode) -> &mut Self

Set mouse tracking mode.

Source

pub fn set_format(&mut self, value: Format) -> &mut Self

Set mouse output format.

Source

pub fn set_size(&mut self, value: EncoderSize) -> &mut Self

Set renderer size context.

Source

pub fn set_any_button_pressed(&mut self, value: bool) -> &mut Self

Set whether any mouse button is currently pressed.

Source

pub fn set_track_last_cell(&mut self, value: bool) -> &mut Self

Set whether to enable motion deduplication by last cell.

Source

pub fn reset(&mut self)

Reset internal encoder state.

This clears motion deduplication state (last tracked cell).

Trait Implementations§

Source§

impl<'alloc> Debug for Encoder<'alloc>

Source§

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

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

impl Drop for Encoder<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'alloc> Freeze for Encoder<'alloc>

§

impl<'alloc> RefUnwindSafe for Encoder<'alloc>

§

impl<'alloc> !Send for Encoder<'alloc>

§

impl<'alloc> !Sync for Encoder<'alloc>

§

impl<'alloc> Unpin for Encoder<'alloc>

§

impl<'alloc> UnsafeUnpin for Encoder<'alloc>

§

impl<'alloc> UnwindSafe for Encoder<'alloc>

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