Sista v3.0.0-beta.10
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

Class representing a terminal cursor for movement operations. More...

#include <cursor.hpp>

Collaboration diagram for sista::Cursor:
Collaboration graph

Public Member Functions

 Cursor ()
 Constructor that hides the cursor.
 
 ~Cursor ()
 Destructor that shows the cursor.
 
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.
 
Cursor __new__ (cls)
 
None __init__ (self)
 Create and return a Cursor wrapper object.
 
None move (self, int direction, int amount)
 Move the cursor in the specified direction by the given amount.
 
None go_to (self, int y, int x)
 Move the cursor to the absolute (y, x) position.
 
None go_to_coordinates (self, Capsule coords)
 Move the cursor to the position described by a Coordinates capsule.
 

Detailed Description

Class representing a terminal cursor for movement operations.

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.

◆ ~Cursor()

sista::Cursor::~Cursor ( )

Destructor that shows the cursor.

◆ __init__()

None sista.Cursor.__init__ (   self)

Create and return a Cursor wrapper object.

The returned object is a Python wrapper that owns the underlying C Cursor handler. Use the instance methods (move, go_to, go_to_coordinates) on the returned Cursor object. The wrapper manages the C-side lifetime (it will destroy the C handler when the Python object is deallocated).

Member Function Documentation

◆ __new__()

Cursor sista.Cursor.__new__ (   cls)

◆ 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

◆ go_to()

None sista.Cursor.go_to (   self,
int  y,
int  x 
)

Move the cursor to the absolute (y, x) position.

:param y: Row index to move to. :param x: Column index to move to.

◆ go_to_coordinates()

None sista.Cursor.go_to_coordinates (   self,
Capsule  coords 
)

Move the cursor to the position described by a Coordinates capsule.

:param coords: Capsule returned by create_coordinates.

◆ 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/4]

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/4]

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/4]

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

◆ move() [4/4]

None sista.Cursor.move (   self,
int  direction,
int  amount 
)

Move the cursor in the specified direction by the given amount.

:param direction: One of the DIRECTION_* constants (or equivalent). :param amount: Number of positions to move the cursor.


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