Module cursor
Available on crate features
dep_crossterm
and std
only.Expand description
A module to work with the terminal cursor
§Cursor
The cursor
module provides functionality to work with the terminal cursor.
This documentation does not contain a lot of examples. The reason is that it’s fairly obvious how to use this crate. Although, we do provide examples repository to demonstrate the capabilities.
§Examples
Cursor actions can be performed with commands. Please have a look at command documentation for a more detailed documentation.
use std::io::{self, Write};
use crossterm::{
ExecutableCommand, execute,
cursor::{DisableBlinking, EnableBlinking, MoveTo, RestorePosition, SavePosition}
};
fn main() -> io::Result<()> {
// with macro
execute!(
io::stdout(),
SavePosition,
MoveTo(10, 10),
EnableBlinking,
DisableBlinking,
RestorePosition
);
// with function
io::stdout()
.execute(MoveTo(11,11))?
.execute(RestorePosition);
Ok(())
}
For manual execution control check out crossterm::queue.
Structs§
- Disable
Blinking - A command that disables blinking of the terminal cursor.
- Enable
Blinking - A command that enables blinking of the terminal cursor.
- Hide
- A command that hides the terminal cursor.
- Move
Down - A command that moves the terminal cursor a given number of rows down.
- Move
Left - A command that moves the terminal cursor a given number of columns to the left.
- Move
Right - A command that moves the terminal cursor a given number of columns to the right.
- MoveTo
- A command that moves the terminal cursor to the given position (column, row).
- Move
ToColumn - A command that moves the terminal cursor to the given column on the current row.
- Move
ToNext Line - A command that moves the terminal cursor down the given number of lines, and moves it to the first column.
- Move
ToPrevious Line - A command that moves the terminal cursor up the given number of lines, and moves it to the first column.
- Move
ToRow - A command that moves the terminal cursor to the given row on the current column.
- MoveUp
- A command that moves the terminal cursor a given number of rows up.
- Restore
Position - A command that restores the saved terminal cursor position.
- Save
Position - A command that saves the current terminal cursor position.
- Show
- A command that shows the terminal cursor.
Enums§
- SetCursor
Style - A command that sets the style of the cursor. It uses two types of escape codes, one to control blinking, and the other the shape.
Functions§
- position
- Returns the cursor position (column, row).