Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sista::Cursor Struct Reference

Manages terminal cursor operations. More...

#include <cursor.hpp>

Public Member Functions

 Cursor ()
 Constructor that hides the cursor and clears the screen.
 
 ~Cursor ()
 Destructor that shows the cursor and resets ANSI settings.
 
void goTo (unsigned short int, unsigned short int) const
 Moves the cursor to the specified (y, x) coordinates.
 
void goTo (sista::Coordinates) const
 Moves the cursor to the specified Coordinates.
 
void eraseScreen (EraseScreen) const
 Erases parts of the screen based on the specified EraseScreen option.
 
void eraseLine (EraseLine, bool=true) const
 Erases parts of the current line based on the specified EraseLine option.
 
void move (MoveCursor, unsigned short int) const
 Moves the cursor in the specified direction by a given number of positions.
 
void move (MoveCursorDEC) const
 Moves the cursor using DEC-specific commands.
 
void move (MoveCursorSCO) const
 Moves the cursor using SCO-specific commands.
 

Detailed Description

Manages terminal cursor operations.

The Cursor struct provides methods to manipulate the terminal cursor, including moving to specific coordinates, erasing parts of the screen or line, and moving the cursor in various directions. It also handles hiding and showing the cursor upon creation and destruction.

See also
EraseScreen
EraseLine
MoveCursor
MoveCursorDEC
MoveCursorSCO

Constructor & Destructor Documentation

◆ Cursor()

sista::Cursor::Cursor ( )

Constructor that hides the cursor and clears the screen.

◆ ~Cursor()

sista::Cursor::~Cursor ( )

Destructor that shows the cursor and resets ANSI settings.

Member Function Documentation

◆ eraseLine()

void sista::Cursor::eraseLine ( EraseLine  eraseLine_,
bool  moveCursor = true 
) const

Erases parts of the current line based on the specified EraseLine option.

Parameters
eraseLine_The EraseLine option specifying which part of the line to erase.
moveCursorIf true, moves the cursor to the beginning of the line after erasure.

This method outputs the appropriate ANSI escape code to erase parts of the current line according to the selected option from the EraseLine enum. If moveCursor is true, it also moves the cursor to the start of the line after performing the erasure.

See also
EraseLine

◆ eraseScreen()

void sista::Cursor::eraseScreen ( EraseScreen  eraseScreen_) const

Erases parts of the screen based on the specified EraseScreen option.

Parameters
eraseScreen_The EraseScreen option specifying which part of the screen to erase.

This method outputs the appropriate ANSI escape code to erase parts of the terminal screen according to the selected option from the EraseScreen enum.

See also
EraseScreen

◆ goTo() [1/2]

void sista::Cursor::goTo ( sista::Coordinates  coordinates_) const

Moves the cursor to the specified Coordinates.

Parameters
coordinates_A Coordinates instance specifying the (y, x) position.
Note
The coordinates are adjusted by predefined offsets to account for terminal borders or margins.
See also
sista::Coordinates

◆ goTo() [2/2]

void sista::Cursor::goTo ( unsigned short int  y_,
unsigned short int  x_ 
) const

Moves the cursor to the specified (y, x) coordinates.

Parameters
y_The y coordinate (row).
x_The x coordinate (column).
Note
The coordinates are 0-based for this function and are absolute positions on the terminal.

◆ move() [1/3]

void sista::Cursor::move ( MoveCursor  moveCursor_,
unsigned short int  n = 1 
) const

Moves the cursor in the specified direction by a given number of positions.

Parameters
moveCursor_The MoveCursor direction to move the cursor.
nThe number of positions to move the cursor (default is 1).

This method outputs the appropriate ANSI escape code to move the terminal cursor in the specified direction by the given number of positions.

See also
MoveCursor

◆ move() [2/3]

void sista::Cursor::move ( MoveCursorDEC  moveCursorDEC_) const

Moves the cursor using DEC-specific commands.

Parameters
moveCursorDEC_The MoveCursorDEC command to execute (save or restore cursor position).

This method outputs the appropriate ANSI escape code to save or restore the cursor position using DEC-specific commands.

See also
MoveCursorDEC

◆ move() [3/3]

void sista::Cursor::move ( MoveCursorSCO  moveCursorSCO_) const

Moves the cursor using SCO-specific commands.

Parameters
moveCursorSCO_The MoveCursorSCO command to execute (save or restore cursor position).

This method outputs the appropriate ANSI escape code to save or restore the cursor position using SCO-specific commands.

See also
MoveCursorSCO

The documentation for this struct was generated from the following files: