Crate term_cursor [−] [src]
Intro
term_cursor
is a crate for handling terminal cursor movement in a platform independent way.
The supported platforms are:
Windows
Linux
macOS
FreeBSD
(not tested)OpenBSD
(not tested)
API
This crate provides 2 APIs which can be used to achieve the same effects:
- A functions based approach, which provides very simple functions to directly interact with the terminal (see the functions section below).
- A newtype pattern based approach, that provies a bunch of types which all implement
std::fmt::Display
(see the structs section below). When such types get formatted, they operate on the terminal in a way very similar to the functions API.
Watch out!
Both APIs always operate on the "default" terminal that is bound to the process.
In other words, on Windows GetStdHandle(STD_OUTPUT_HANDLE)
is used, and on *NIX, the ANSI terminal communcation is done through stdout
/ stdin
.
Structs
Clear |
A type that, when |
Down |
A type that, when |
Goto |
A type that, when |
Left |
A type that, when |
Relative |
A type that, when |
Right |
A type that, when |
Up |
A type that, when |
Enums
Error |
The central error type. |
Functions
clear |
Clear the screen, i.e. setting every character in the terminal to a space |
get_cursor_pos |
Get the current cursor position. The tuple returned contains the (x, y) coordinates of the cursor position. X and Y correspond to columns and rows respectively. |
set_cursor_pos |
Set the cursor position to the specified coordinates. X and Y correspond to columns and rows respectively. |