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>
impl<'alloc> Encoder<'alloc>
Sourcepub fn new_with_alloc<'ctx: 'alloc, Ctx>(
alloc: &'alloc Allocator<'ctx, Ctx>,
) -> Result<Self>
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.
Sourcepub fn encode_to_vec(
&mut self,
event: &Event<'_>,
vec: &mut Vec<u8>,
) -> Result<()>
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.
Sourcepub fn encode(&mut self, event: &Event<'_>, buf: &mut [u8]) -> Result<usize>
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.
Sourcepub fn set_options_from_terminal(
&mut self,
terminal: &Terminal<'_, '_>,
) -> &mut Self
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.
Sourcepub fn set_tracking_mode(&mut self, value: TrackingMode) -> &mut Self
pub fn set_tracking_mode(&mut self, value: TrackingMode) -> &mut Self
Set mouse tracking mode.
Sourcepub fn set_format(&mut self, value: Format) -> &mut Self
pub fn set_format(&mut self, value: Format) -> &mut Self
Set mouse output format.
Sourcepub fn set_size(&mut self, value: EncoderSize) -> &mut Self
pub fn set_size(&mut self, value: EncoderSize) -> &mut Self
Set renderer size context.
Set whether any mouse button is currently pressed.
Sourcepub fn set_track_last_cell(&mut self, value: bool) -> &mut Self
pub fn set_track_last_cell(&mut self, value: bool) -> &mut Self
Set whether to enable motion deduplication by last cell.