Struct crossterm::TerminalCursor[][src]

pub struct TerminalCursor<'stdout> { /* fields omitted */ }

Struct that stores an specific platform implementation for cursor related actions.

Check /examples/cursor in the library for more specific examples.

extern crate crossterm;
use self::crossterm::cursor;
use self::crossterm::Screen;

let screen = Screen::default();
let mut cursor = cursor(&screen);

// Get cursor and goto pos X: 5, Y: 10
cursor.goto(5,10);
 
cursor.show();
cursor.hide();
cursor.blink(true);
cursor.move_left(2);

Methods

impl<'stdout> TerminalCursor<'stdout>
[src]

Create new cursor instance whereon cursor related actions can be performed.

Goto some position (x,y) in the terminal.

let screen = Screen::default();
let cursor = cursor(&screen);

// change the cursor to position, x: 4 and y: 5
cursor.goto(4,5);

Get current cursor position (x,y) in the terminal.

let screen = Screen::default();
let cursor = cursor(&screen);

// get the current cursor pos
let (x,y) = cursor.pos();

Move the current cursor position n times up.

let screen = Screen::default();
let cursor = cursor(&screen);

// Move the cursor to position 3 times to the up in the terminal
cursor.move_up(3);

Move the current cursor position n times right.

let screen = Screen::default();
let cursor = cursor(&screen);

// Move the cursor to position 3 times to the right in the terminal
cursor.move_right(3);

Move the current cursor position n times down.

let screen = Screen::default();
let cursor = cursor(&screen);

// Move the cursor to position 3 times to the down in the terminal
cursor.move_down(3);

Move the current cursor position n times left.

let screen = Screen::default();
let cursor = cursor(&screen);

 // Move the cursor to position 3 times to the left in the terminal
 cursor.move_left(3);

Save cursor position for recall later.

Note that this position is stored program based not per instance of the Cursor struct.

let screen = Screen::default();
let cursor = cursor(&screen);

cursor.safe_position();

Return to saved cursor position

Note that this method reset to the position set by save_position() and that this position is stored program based not per instance of the Cursor struct.

let screen = Screen::default();
let cursor = cursor(&screen);

cursor.reset_position();

Hide de cursor in the console.

let cursor = cursor(&Screen::default());
cursor.hide();

Show the cursor in the console.


let screen = Screen::default();
let cursor = cursor(&screen);
cursor.show();

Enable or disable blinking of the terminal.

Not all terminals are supporting this functionality. Windows versions lower than windows 10 also are not supporting this version.

let screen = Screen::default();
let cursor = cursor(&screen);
cursor.blink(true);
cursor.blink(false);

Auto Trait Implementations

impl<'stdout> Send for TerminalCursor<'stdout>

impl<'stdout> Sync for TerminalCursor<'stdout>