Expand description
§Cursor
The crossterm_cursor
crate is deprecated and no longer maintained. The GitHub repository will
be archived soon. All the code is being moved to the crossterm
crate. You can learn more in
the Merge sub-crates to the crossterm crate
issue.
The crossterm_cursor
crate provides a 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
Basic usage:
// You can replace the following line with `use crossterm::TerminalCursor;`
// if you're using the `crossterm` crate with the `cursor` feature enabled.
use crossterm_cursor::{Result, TerminalCursor};
fn main() -> Result<()> {
// Get a cursor, save position
let cursor = TerminalCursor::new();
cursor.save_position()?;
// Do something with the cursor
cursor.goto(10, 10)?;
cursor.blink(true)?;
// Be a good citizen, cleanup
cursor.blink(false)?;
cursor.restore_position()
}
Commands:
use std::io::{stdout, Write};
use crossterm_cursor::{execute, BlinkOff, BlinkOn, Goto, ResetPos, Result, SavePos};
fn main() -> Result<()> {
execute!(
stdout(),
SavePos,
Goto(10, 10),
BlinkOn,
BlinkOff,
ResetPos
)
}
Re-exports§
pub use crossterm_utils::execute;
pub use crossterm_utils::queue;
pub use crossterm_utils::Command;
pub use crossterm_utils::ErrorKind;
pub use crossterm_utils::ExecutableCommand;
pub use crossterm_utils::Output;
pub use crossterm_utils::QueueableCommand;
pub use crossterm_utils::Result;
Structs§
- Blink
Off - A command to disable the cursor blinking.
- BlinkOn
- A command to enable the cursor blinking.
- Down
- A command to move the cursor given rows down.
- Goto
- A command to move the cursor to the given position.
- Hide
- A command to hide the cursor.
- Left
- A command to move the cursor given columns left.
- Reset
Pos - A command to restore the saved cursor position.
- Right
- A command to move the cursor given columns right.
- SavePos
- A command to save the cursor position.
- Show
- A command to show the cursor.
- Terminal
Cursor - A terminal cursor.
- Up
- A command to move the cursor given rows up.
Functions§
- cursor
- Creates a new
TerminalCursor
.