[−][src]Struct crossterm::cursor::TerminalCursor
A terminal cursor.
The TerminalCursor
instance is stateless and does not hold any data.
You can create as many instances as you want and they will always refer to the
same terminal cursor.
The cursor position is 0 based. For example 0
means first column/row, 1
second column/row, etc.
Examples
Basic usage:
use crossterm::{Result, TerminalCursor}; fn main() -> Result<()> { let cursor = TerminalCursor::new(); cursor.save_position()?; cursor.goto(10, 10)?; cursor.blink(true)?; cursor.blink(false)?; cursor.restore_position() }
Methods
impl TerminalCursor
[src]
pub fn new() -> TerminalCursor
[src]
Creates a new TerminalCursor
.
pub fn goto(&self, column: u16, row: u16) -> Result<()>
[src]
Moves the cursor to the given position.
pub fn pos(&self) -> Result<(u16, u16)>
[src]
Returns the cursor position ((column, row)
tuple).
pub fn move_up(&mut self, row_count: u16) -> Result<&mut TerminalCursor>
[src]
Moves the cursor row_count
times up.
pub fn move_right(&mut self, col_count: u16) -> Result<&mut TerminalCursor>
[src]
Moves the cursor col_count
times right.
pub fn move_down(&mut self, row_count: u16) -> Result<&mut TerminalCursor>
[src]
Moves the cursor row_count
times down.
pub fn move_left(&mut self, col_count: u16) -> Result<&mut TerminalCursor>
[src]
Moves the cursor col_count
times left.
pub fn save_position(&self) -> Result<()>
[src]
Saves the cursor position.
See the restore_position method.
Notes
The cursor position is stored globally and is not related to the current/any
TerminalCursor
instance.
pub fn restore_position(&self) -> Result<()>
[src]
Restores the saved cursor position.
See the save_position method.
pub fn hide(&self) -> Result<()>
[src]
Hides the cursor.
See the show method.
pub fn show(&self) -> Result<()>
[src]
Shows the cursor.
See the hide method.
pub fn blink(&self, blink: bool) -> Result<()>
[src]
Enables or disables the cursor blinking.
Notes
Windows versions lower than Windows 10 do not support this functionality.
Auto Trait Implementations
impl Send for TerminalCursor
impl Sync for TerminalCursor
impl Unpin for TerminalCursor
impl UnwindSafe for TerminalCursor
impl RefUnwindSafe for TerminalCursor
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,