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
  • OS X (not tested)
  • 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 Displayed, clears the entire terminal screen.

Down

A type that, when Displayed, makes the cursor move down by the specified amount.

Goto

A type that, when Displayed, makes the cursor go the specified coordinates.

Left

A type that, when Displayed, makes the cursor move left by the specified amount.

Relative

A type that, when Displayed, makes the cursor move by the specified amount.

Right

A type that, when Displayed, makes the cursor move right by the specified amount.

Up

A type that, when Displayed, makes the cursor move up by the specified amount.

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.