pub struct CursorManager { /* private fields */ }Expand description
Manages cursor save/restore operations.
This struct handles the complexity of cursor save/restore across different strategies. It tracks the saved position for emulated mode and provides a unified interface regardless of the underlying mechanism.
§Contract
save()must be called beforerestore()- Calling
restore()without a priorsave()is safe but may have no effect - Multiple
save()calls overwrite the previous save (no nesting)
Implementations§
Source§impl CursorManager
impl CursorManager
Sourcepub const fn new(strategy: CursorSaveStrategy) -> Self
pub const fn new(strategy: CursorSaveStrategy) -> Self
Create a new cursor manager with the specified strategy.
Sourcepub fn detect(caps: &TerminalCapabilities) -> Self
pub fn detect(caps: &TerminalCapabilities) -> Self
Create a cursor manager with auto-detected strategy.
Sourcepub const fn strategy(&self) -> CursorSaveStrategy
pub const fn strategy(&self) -> CursorSaveStrategy
Get the current strategy.
Sourcepub fn restore<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn restore<W: Write>(&self, writer: &mut W) -> Result<()>
Restore the cursor position.
§Errors
Returns an error if writing to the output fails. For emulated mode, does nothing if no position was saved.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the saved position (for emulated mode).
This has no effect on DEC/ANSI modes.
Sourcepub const fn saved_position(&self) -> Option<(u16, u16)>
pub const fn saved_position(&self) -> Option<(u16, u16)>
Get the saved position (for emulated mode).
Returns None for DEC/ANSI modes or if no position was saved.
Trait Implementations§
Source§impl Clone for CursorManager
impl Clone for CursorManager
Source§fn clone(&self) -> CursorManager
fn clone(&self) -> CursorManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CursorManager
impl Debug for CursorManager
Auto Trait Implementations§
impl Freeze for CursorManager
impl RefUnwindSafe for CursorManager
impl Send for CursorManager
impl Sync for CursorManager
impl Unpin for CursorManager
impl UnwindSafe for CursorManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more