pub struct TerminalCursor<'stdout> { /* fields omitted */ }
Allows you to preform actions with the terminal cursor.
- Moving n times Up, Down, Left, Right
- Goto a certain position
- Get cursor position
- Storing the current cursor position and resetting to that stored cursor position later
- Hiding an showing the cursor
- Control over blinking of the terminal cursor (only some terminals are supporting this)
Note that positions of the cursor are 0 -based witch means that the coordinates (cells) starts counting from 0
Check /examples/cursor
in the library for more specific examples.
When you want to use 'cursor' on 'alternate screen' use the 'crossterm_screen' crate.
Create new TerminalCursor
instance whereon cursor related actions can be performed.
Create a new instance of TerminalCursor
whereon cursor related actions could be preformed on the given output.
Use this function when you want your terminal to operate with a specific output.
This could be useful when you have a screen which is in 'alternate mode',
and you want your actions from the TerminalCursor
, created by this function, to operate on the 'alternate screen'.
You should checkout the 'crossterm_screen' crate for more information about this.
let screen = Screen::default();
if let Ok(alternate) = screen.enable_alternate_modes(false) {
let terminal = TerminalCursor::from_output(&alternate.screen.stdout);
}
Goto some position (x,y) in the terminal.
position is 0-based, which means we start counting at 0.
Get current cursor position (x,y) in the terminal.
position is 0-based, which means we start counting at 0.
Move the current cursor position n
times up.
Move the current cursor position n
times right.
Move the current cursor position n
times down.
Move the current cursor position n
times left.
Save cursor position for recall later.
Note that this position is stored program based not per instance of the Cursor
struct.
Return to saved cursor position
Hide de cursor in the console.
Show the cursor in the console.
Enable or disable blinking of the terminal.
Not all terminals are supporting this functionality. Windows versions lower than windows 10 also are not supporting this version.
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)