[][src]Struct crossterm_cursor::TerminalCursor

pub struct TerminalCursor { /* fields omitted */ }

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_cursor::{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.

Enables or disables the cursor blinking.

Notes

Windows versions lower than Windows 10 do not support this functionality.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]