This crate allows you to move the terminal cursor cross-platform. It supports all UNIX and windows terminals down to windows 7 (not all terminals are tested see Tested Terminals for more info)
This crate is a sub-crate of crossterm to move the cursor, and can be use individually.
Other sub-crates are: - Crossterm Style - Crossterm Terminal - Crossterm Screen - Crossterm Input
When you want to use other modules as well you might want to use crossterm with feature flags
This documentation is only for crossterm_cursor
version 0.1
if you have an older version I suggest you check the Upgrade Manual. Also, check out the examples folders with detailed examples for all functionality of this crate.
Add the crossterm_cursor
package to your Cargo.toml
file.
``
[dependencies]
crossterm_cursor` = "0.1"
``` And import the crossterm_input modules you want to use.
```rust
extern crate crossterm_cursor;
pub use crossterm_cursor::{cursor, TerminalCursor}; ```
These are the features of this crate:
Check out the examples for more information about how to use this crate.
```rust use crossterm_cursor::cursor;
let mut cursor = cursor();
/// Moving the cursor // Set the cursor to position X: 10, Y: 5 in the terminal cursor.goto(10,5);
// Move the cursor up,right,down,left 3 cells. cursor.moveup(3); cursor.moveright(3); cursor.movedown(3); cursor.moveleft(3);
/// Safe the current cursor position to recall later // Goto X: 5 Y: 5 cursor.goto(5,5); // Safe cursor position: X: 5 Y: 5 cursor.saveposition(); // Goto X: 5 Y: 20 cursor.goto(5,20); // Print at X: 5 Y: 20. print!("Yea!"); // Reset back to X: 5 Y: 5. cursor.resetposition(); // Print 'Back' at X: 5 Y: 5. print!("Back");
// hide cursor cursor.hide(); // show cursor cursor.show(); // blink or not blinking of the cursor (not widely supported) cursor.blink(true)
```
This crate supports all Unix terminals and windows terminals down to Windows 7 but not all of them have been tested. If you have used this library for a terminal other than the above list without issues feel free to add it to the above list, I really would appreciate it.
This library is average stable now, I don't expect it to not to change that much. If there are any changes that will affect previous versions I will describe what to change to upgrade.
I highly appreciate it when you are contributing to this crate. Also Since my native language is not English my grammar and sentence order will not be perfect. So improving this by correcting these mistakes will help both me and the reader of the docs.
This project is licensed under the MIT License - see the LICENSE.md file for details