[][src]Module crossterm::cursor

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::{stdout, Write};

use crossterm::{
    ExecutableCommand, execute, Result,
    cursor::{DisableBlinking, EnableBlinking, MoveTo, RestorePosition, SavePosition}
};

fn main() -> Result<()> {
    // with macro
    execute!(
        stdout(),
        SavePosition,
        MoveTo(10, 10),
        EnableBlinking,
        DisableBlinking,
        RestorePosition
    );

  // with function
  stdout()
    .execute(MoveTo(11,11))?
    .execute(RestorePosition);

 Ok(())
}

For manual execution control check out crossterm::queue.

Structs

DisableBlinking

A command that disables blinking of the terminal cursor.

EnableBlinking

A command that enables blinking of the terminal cursor.

Hide

A command that hides the terminal cursor.

MoveDown

A command that moves the terminal cursor a given number of rows down.

MoveLeft

A command that moves the terminal cursor a given number of columns to the left.

MoveRight

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).

MoveToColumn

A command that moves the terminal cursor to the given column on the current row.

MoveToNextLine

A command that moves the terminal cursor up the given number of lines, and moves it to the first column.

MoveToPreviousLine

A command that moves the terminal cursor down the given number of lines, and moves it to the first column.

MoveUp

A command that moves the terminal cursor a given number of rows up.

RestorePosition

A command that restores the saved terminal cursor position.

SavePosition

A command that saves the current terminal cursor position.

Show

A command that shows the terminal cursor.

Functions

position

Returns the cursor position (column, row).