Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
sista Namespace Reference

Sista library namespace. More...

Classes

struct  ANSISettings
 Represents a set of ANSI settings including colors and attributes. More...
 
class  Border
 Represents a brick of the border with a symbol and ANSI settings. More...
 
struct  Coordinates
 Represents 2D coordinates with x and y values. More...
 
struct  Cursor
 Manages terminal cursor operations. More...
 
class  Field
 Represents a 2D grid where Pawns can be placed, moved, and managed. More...
 
struct  Path
 Represents a movement path for a Pawn, including priority handling. More...
 
class  Pawn
 Represents an object on the field with a symbol, coordinates, and ANSI settings. More...
 
struct  RGBColor
 Represents an RGB color with red, green, and blue components in True Color (24-bit). More...
 
class  SwappableField
 A specialized Field that handles Pawn swaps without conflicts. More...
 

Enumerations

enum class  ForegroundColor : int {
  BLACK = 30 , RED = 31 , GREEN = 32 , YELLOW = 33 ,
  BLUE = 34 , MAGENTA = 35 , CYAN = 36 , WHITE = 37
}
 Enumeration of foreground colors for ANSI escape codes. More...
 
enum class  BackgroundColor : int {
  BLACK = 40 , RED = 41 , GREEN = 42 , YELLOW = 43 ,
  BLUE = 44 , MAGENTA = 45 , CYAN = 46 , WHITE = 47
}
 Enumeration of background colors for ANSI escape codes. More...
 
enum class  Attribute : int {
  RESET = 0 , BRIGHT = 1 , FAINT = 2 , ITALIC = 3 ,
  UNDERSCORE = 4 , BLINK = 5 , RAPID_BLINK = 6 , REVERSE = 7 ,
  HIDDEN = 8 , STRIKETHROUGH = 9
}
 Enumeration of text attributes for ANSI escape codes. More...
 
enum class  ScreenMode : int {
  MONOCROME_TEXT_40_25 = 0 , COLOR_TEXT_40_25 = 1 , MONOCROME_TEXT_80_25 = 2 , COLOR_TEXT_80_25 = 3 ,
  FOUR_COLORS_GRAPHICS_320_200 = 4 , MONOCROME_GRAPHICS_320_200 = 5 , MONOCROME_GRAPHICS_640_200 = 6 , LINE_WRAPPING = 7 ,
  COLOR_GRAPHICS_320_200 = 13 , COLOR_16_COLORS_GRAPHICS_640_200 = 14 , MONOCROME_2_COLORS_GRAPHICS_640_350 = 15 , COLOR_16_COLORS_GRAPHICS_640_350 = 16 ,
  MONOCROME_2_COLORS_GRAPHICS_640_480 = 17 , COLOR_16_COLORS_GRAPHICS_640_480 = 18 , COLOR_256_COLORS_GRAPHICS_320_200 = 19
}
 Represents various ANSI screen modes. More...
 
enum class  EraseScreen : int { FROM_CURSOR_TO_END = 0 , FROM_CURSOR_TO_BEGINNING = 1 , ENTIRE_SCREEN = 2 , ERASE_SAVED_LINES = 3 }
 Enumeration for screen erasure options in ANSI escape codes. More...
 
enum class  EraseLine : int { LINE_FROM_CURSOR_TO_END = 0 , LINE_FROM_CURSOR_TO_BEGINNING = 1 , ENTIRE_LINE = 2 }
 Enumeration for line erasure options in ANSI escape codes. More...
 
enum class  MoveCursor : char {
  UP = 'A' , DOWN = 'B' , RIGHT = 'C' , LEFT = 'D' ,
  BEGINNING_OF_NEXT_LINE = 'E' , BEGINNING_OF_PREVIOUS_LINE = 'F' , HORIZONTAL_ABSOLUTE = 'G'
}
 Enumeration for cursor movement directions in ANSI escape codes. More...
 
enum class  MoveCursorDEC : int { SAVE_CURSOR_POSITION = 7 , RESTORE_CURSOR_POSITION = 8 }
 Enumeration for DEC-specific cursor movement commands in ANSI escape codes. More...
 
enum class  MoveCursorSCO : char { SCO_SAVE_CURSOR_POSITION = 's' , SCO_RESTORE_CURSOR_POSITION = 'u' }
 Enumeration for SCO-specific cursor movement commands in ANSI escape codes. More...
 
enum class  Effect { PACMAN = 0 , MATRIX = 1 }
 Enumeration for handling out-of-bounds coordinates. More...
 

Functions

void setForegroundColor (ForegroundColor)
 Sets the foreground color using a predefined ForegroundColor enum.
 
void setBackgroundColor (BackgroundColor)
 Sets the background color using a predefined BackgroundColor enum.
 
void setAttribute (Attribute)
 Sets a text attribute using a predefined Attribute enum.
 
void resetAttribute (Attribute)
 Resets a text attribute using a predefined Attribute enum.
 
void resetAnsi ()
 Resets all ANSI settings to default values.
 
void setForegroundColor (const RGBColor &)
 Sets the foreground color using an RGBColor struct.
 
void setBackgroundColor (const RGBColor &)
 Sets the background color using an RGBColor struct.
 
void setForegroundColor (unsigned short int, unsigned short int, unsigned short int)
 Sets the foreground color using RGB values.
 
void setBackgroundColor (unsigned short int, unsigned short int, unsigned short int)
 Sets the background color using RGB values.
 
void setForegroundColor (unsigned short int)
 Sets the foreground color using a 256-color palette index.
 
void setBackgroundColor (unsigned short int)
 Sets the background color using a 256-color palette index.
 
void setScreenMode (ScreenMode)
 Sets a specific screen mode.
 
void unsetScreenMode (ScreenMode)
 Unsets a specific screen mode.
 
void clearScreen (bool spaces=true)
 Clears the terminal screen and optionally the scrollback buffer.
 
const char * getVersion ()
 Returns the Sista library version as a string.
 
int getVersionMajor ()
 Returns the major version number of the Sista library.
 
int getVersionMinor ()
 Returns the minor version number of the Sista library.
 
int getVersionPatch ()
 Returns the patch version number of the Sista library.
 

Detailed Description

Sista library namespace.

This namespace encapsulates all components of the Sista library.

See also
ANSISettings
Coordinates

Enumeration Type Documentation

◆ Attribute

enum class sista::Attribute : int
strong

Enumeration of text attributes for ANSI escape codes.

This enum class defines various text attributes that can be used in ANSI escape codes. Each attribute is associated with its corresponding ANSI code value, ranging from 0 to 9.

See also
setAttribute(Attribute)
resetAttribute(Attribute)
Enumerator
RESET 
BRIGHT 
FAINT 
ITALIC 
UNDERSCORE 
BLINK 
RAPID_BLINK 
REVERSE 
HIDDEN 
STRIKETHROUGH 

◆ BackgroundColor

enum class sista::BackgroundColor : int
strong

Enumeration of background colors for ANSI escape codes.

This enum class defines various background colors that can be used in ANSI escape codes. Each color is associated with its corresponding ANSI code value, ranging from 40 to 47.

See also
setBackgroundColor(BackgroundColor)
Enumerator
BLACK 
RED 
GREEN 
YELLOW 
BLUE 
MAGENTA 
CYAN 
WHITE 

◆ Effect

enum class sista::Effect
strong

Enumeration for handling out-of-bounds coordinates.

This enum class defines different effects that can be applied when a Pawn's coordinates go out of the bounds of the Field. The effects determine how the coordinates are adjusted to bring them back within valid limits.

  • PACMAN: Wraps around to the opposite side of the field (like in the PacMan game).
  • MATRIX: Wraps to the beginning of the next line (like in classic C-style arrays).
See also
Field::movingByCoordinates
Field::movePawnBy
Enumerator
PACMAN 
MATRIX 

◆ EraseLine

enum class sista::EraseLine : int
strong

Enumeration for line erasure options in ANSI escape codes.

This enum class defines various options for erasing parts of the current line in the terminal using ANSI escape codes. Each option corresponds to a specific ANSI code value.

See also
Cursor::eraseLine
Enumerator
LINE_FROM_CURSOR_TO_END 
LINE_FROM_CURSOR_TO_BEGINNING 

Erase from the cursor position to the end of the line.

ENTIRE_LINE 

Erase from the cursor position to the beginning of the line.

◆ EraseScreen

enum class sista::EraseScreen : int
strong

Enumeration for screen erasure options in ANSI escape codes.

This enum class defines various options for erasing parts of the terminal screen using ANSI escape codes. Each option corresponds to a specific ANSI code value.

See also
Cursor::eraseScreen
Enumerator
FROM_CURSOR_TO_END 
FROM_CURSOR_TO_BEGINNING 

Erase from the cursor position to the end of the screen.

ENTIRE_SCREEN 

Erase from the cursor position to the beginning of the screen.

ERASE_SAVED_LINES 

Erase the entire screen.

◆ ForegroundColor

enum class sista::ForegroundColor : int
strong

Enumeration of foreground colors for ANSI escape codes.

This enum class defines various foreground colors that can be used in ANSI escape codes. Each color is associated with its corresponding ANSI code value, ranging from 30 to 37.

See also
setForegroundColor(ForegroundColor)
Enumerator
BLACK 
RED 
GREEN 
YELLOW 
BLUE 
MAGENTA 
CYAN 
WHITE 

◆ MoveCursor

enum class sista::MoveCursor : char
strong

Enumeration for cursor movement directions in ANSI escape codes.

This enum class defines various directions for moving the terminal cursor using ANSI escape codes. Each direction corresponds to a specific command character used in the escape sequences.

See also
Cursor::move(MoveCursor, unsigned short int)
Enumerator
UP 
DOWN 
RIGHT 
LEFT 
BEGINNING_OF_NEXT_LINE 
BEGINNING_OF_PREVIOUS_LINE 
HORIZONTAL_ABSOLUTE 

◆ MoveCursorDEC

enum class sista::MoveCursorDEC : int
strong

Enumeration for DEC-specific cursor movement commands in ANSI escape codes.

This enum class defines specific commands for saving and restoring the cursor position using DEC (Digital Equipment Corporation) ANSI escape codes. Each command corresponds to a specific ANSI code value.

See also
Cursor::move(MoveCursorDEC)
Enumerator
SAVE_CURSOR_POSITION 
RESTORE_CURSOR_POSITION 

◆ MoveCursorSCO

enum class sista::MoveCursorSCO : char
strong

Enumeration for SCO-specific cursor movement commands in ANSI escape codes.

This enum class defines specific commands for saving and restoring the cursor position using SCO (Santa Cruz Operation) ANSI escape codes. Each command corresponds to a specific command character used in the escape sequences.

See also
Cursor::move(MoveCursorSCO)
Enumerator
SCO_SAVE_CURSOR_POSITION 
SCO_RESTORE_CURSOR_POSITION 

◆ ScreenMode

enum class sista::ScreenMode : int
strong

Represents various ANSI screen modes.

This enum defines different screen modes that can be set or unset using ANSI escape codes. Each mode corresponds to a specific configuration of text and graphics display.

Enumerator
MONOCROME_TEXT_40_25 
COLOR_TEXT_40_25 
MONOCROME_TEXT_80_25 
COLOR_TEXT_80_25 
FOUR_COLORS_GRAPHICS_320_200 
MONOCROME_GRAPHICS_320_200 
MONOCROME_GRAPHICS_640_200 
LINE_WRAPPING 
COLOR_GRAPHICS_320_200 
COLOR_16_COLORS_GRAPHICS_640_200 
MONOCROME_2_COLORS_GRAPHICS_640_350 
COLOR_16_COLORS_GRAPHICS_640_350 
MONOCROME_2_COLORS_GRAPHICS_640_480 
COLOR_16_COLORS_GRAPHICS_640_480 
COLOR_256_COLORS_GRAPHICS_320_200 

Function Documentation

◆ clearScreen()

void sista::clearScreen ( bool  spaces = true)

Clears the terminal screen and optionally the scrollback buffer.

Parameters
spacesIf true, clears both the screen and the scrollback buffer; if false, only moves the cursor to the top-left corner.

This function outputs ANSI escape codes to clear the terminal screen. If the spaces parameter is set to true, it also clears the scrollback buffer. After clearing, it moves the cursor to the top-left corner of the terminal.

Note
Clearing the scrollback buffer may not be necessary in all applications and can be omitted by setting spaces to false.
See also
CLS
SSB
TL

◆ getVersion()

const char * sista::getVersion ( )
inline

Returns the Sista library version as a string.

Returns
A string representing the Sista library version.

This function returns the version of the Sista library in the format "MAJOR.MINOR.PATCH". It is useful for logging, debugging, or displaying version information in applications that utilize the Sista library.

See also
SISTA_VERSION

◆ getVersionMajor()

int sista::getVersionMajor ( )
inline

Returns the major version number of the Sista library.

Returns
An integer representing the major version number.

This function returns the major version number of the Sista library. The major version typically indicates significant changes or milestones in the library's development.

See also
SISTA_VERSION_MAJOR

◆ getVersionMinor()

int sista::getVersionMinor ( )
inline

Returns the minor version number of the Sista library.

Returns
An integer representing the minor version number.

This function returns the minor version number of the Sista library. The minor version typically indicates the addition of new features or improvements that are backward-compatible.

See also
SISTA_VERSION_MINOR

◆ getVersionPatch()

int sista::getVersionPatch ( )
inline

Returns the patch version number of the Sista library.

Returns
An integer representing the patch version number.

This function returns the patch version number of the Sista library. The patch version typically indicates bug fixes or minor changes that do not affect the overall functionality or compatibility of the library.

See also
SISTA_VERSION_PATCH

◆ resetAnsi()

void sista::resetAnsi ( )

Resets all ANSI settings to default values.

This function resets the terminal's text attributes, foreground color, and background color to their default values. It outputs the corresponding ANSI escape codes to standard output.

Default settings are:

  • Attribute: RESET
  • Foreground Color: WHITE
  • Background Color: BLACK
See also
Attribute
ForegroundColor
BackgroundColor

◆ resetAttribute()

void sista::resetAttribute ( Attribute  )

Resets a text attribute using a predefined Attribute enum.

Parameters
attributeThe Attribute to reset.

This function resets the terminal's text attribute based on the provided Attribute enum value. It outputs the corresponding ANSI escape code to standard output.

See also
Attribute

◆ setAttribute()

void sista::setAttribute ( Attribute  )

Sets a text attribute using a predefined Attribute enum.

Parameters
attributeThe Attribute to set.

This function sets the terminal's text attribute based on the provided Attribute enum value. It outputs the corresponding ANSI escape code to standard output.

See also
Attribute

◆ setBackgroundColor() [1/4]

void sista::setBackgroundColor ( BackgroundColor  )

Sets the background color using a predefined BackgroundColor enum.

Parameters
colorThe BackgroundColor to set.

This function sets the terminal's background color based on the provided BackgroundColor enum value. It outputs the corresponding ANSI escape code to standard output.

See also
BackgroundColor

◆ setBackgroundColor() [2/4]

void sista::setBackgroundColor ( const RGBColor )

Sets the background color using an RGBColor struct.

Parameters
rgbcolorThe RGBColor to set.

This function sets the terminal's background color based on the provided RGBColor struct. It extracts the red, green, and blue components and calls the appropriate function to set the color using RGB values.

See also
RGBColor

◆ setBackgroundColor() [3/4]

void sista::setBackgroundColor ( unsigned short int  )

Sets the background color using a 256-color palette index.

Parameters
colorThe color index (0-255).

This function sets the terminal's background color based on the provided 256-color palette index. It outputs the corresponding ANSI escape code to standard output.

See also
256-color palette

◆ setBackgroundColor() [4/4]

void sista::setBackgroundColor ( unsigned short int  ,
unsigned short int  ,
unsigned short int   
)

Sets the background color using RGB values.

Parameters
redThe red component (0-255).
greenThe green component (0-255).
blueThe blue component (0-255).

This function sets the terminal's background color based on the provided RGB values. It outputs the corresponding ANSI escape code to standard output.

See also
RGBColor

◆ setForegroundColor() [1/4]

void sista::setForegroundColor ( const RGBColor )

Sets the foreground color using an RGBColor struct.

Parameters
rgbcolorThe RGBColor to set.

This function sets the terminal's foreground color based on the provided RGBColor struct. It extracts the red, green, and blue components and calls the appropriate function to set the color using RGB values.

See also
RGBColor

◆ setForegroundColor() [2/4]

void sista::setForegroundColor ( ForegroundColor  )

Sets the foreground color using a predefined ForegroundColor enum.

Parameters
colorThe ForegroundColor to set.

This function sets the terminal's foreground color based on the provided ForegroundColor enum value. It outputs the corresponding ANSI escape code to standard output.

See also
ForegroundColor

◆ setForegroundColor() [3/4]

void sista::setForegroundColor ( unsigned short int  )

Sets the foreground color using a 256-color palette index.

Parameters
colorThe color index (0-255).

This function sets the terminal's foreground color based on the provided 256-color palette index. It outputs the corresponding ANSI escape code to standard output.

See also
256-color palette

◆ setForegroundColor() [4/4]

void sista::setForegroundColor ( unsigned short int  ,
unsigned short int  ,
unsigned short int   
)

Sets the foreground color using RGB values.

Parameters
redThe red component (0-255).
greenThe green component (0-255).
blueThe blue component (0-255).

This function sets the terminal's foreground color based on the provided RGB values. It outputs the corresponding ANSI escape code to standard output.

See also
RGBColor

◆ setScreenMode()

void sista::setScreenMode ( ScreenMode  )

Sets a specific screen mode.

Parameters
modeThe ScreenMode to set.

This function sets the terminal's screen mode based on the provided ScreenMode enum value. It outputs the corresponding ANSI escape code to standard output.

See also
ScreenMode

◆ unsetScreenMode()

void sista::unsetScreenMode ( ScreenMode  )

Unsets a specific screen mode.

Parameters
modeThe ScreenMode to unset.

This function unsets the terminal's screen mode based on the provided ScreenMode enum value. It outputs the corresponding ANSI escape code to standard output.

See also
ScreenMode