[][src]Module crossterm::cursor

A functionality to work with the terminal cursor

Cursor

The cursor module 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::{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::{BlinkOff, BlinkOn, execute, Goto, ResetPos, Result, SavePos};


fn main() -> Result<()> {
    execute!(
        stdout(),
        SavePos,
        Goto(10, 10),
        BlinkOn,
        BlinkOff,
        ResetPos
    )
}

Structs

BlinkOff

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.

ResetPos

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.

TerminalCursor

A terminal cursor.

Up

A command to move the cursor given rows up.

Functions

cursor

Creates a new TerminalCursor.