|
Sista v3.0.0-beta.10
C++ lightweight OS-agnostic library for terminal animations and videogames
|
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 |
| Class representing a terminal cursor for movement operations. More... | |
| class | Field |
| Class representing a terminal Field for pawns and borders. More... | |
| struct | Path |
| Represents a movement path for a Pawn, including priority handling. More... | |
| class | Pawn |
| Class representing a Pawn owned by a Field or SwappableField. More... | |
| struct | RGBColor |
| Represents an RGB color with red, green, and blue components in True Color (24-bit). More... | |
| class | SwappableField |
| Class representing a terminal SwappableField for pawns and borders. 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 char, unsigned char, unsigned char) |
| Sets the foreground color using RGB values. | |
| void | setBackgroundColor (unsigned char, unsigned char, unsigned char) |
| Sets the background color using RGB values. | |
| void | setForegroundColor (unsigned char) |
| Sets the foreground color using a 256-color palette index. | |
| void | setBackgroundColor (unsigned char) |
| Sets the background color using a 256-color palette index. | |
| std::string | fgColorStr (ForegroundColor) |
| Converts a ForegroundColor enum to its corresponding ANSI escape code string. | |
| std::string | bgColorStr (BackgroundColor) |
| Converts a BackgroundColor enum to its corresponding ANSI escape code string. | |
| std::string | attrStr (Attribute) |
| Converts an Attribute enum to its corresponding ANSI escape code string. | |
| std::string | fgColorStr (const RGBColor &) |
| Converts an RGBColor struct to its corresponding ANSI escape code string for foreground color. | |
| std::string | bgColorStr (const RGBColor &) |
| Converts RGB values to their corresponding ANSI escape code string for foreground color. | |
| std::string | fgColorStr (unsigned char, unsigned char, unsigned char) |
| Converts RGB values to their corresponding ANSI escape code string for foreground color. | |
| std::string | bgColorStr (unsigned char, unsigned char, unsigned char) |
| Converts RGB values to their corresponding ANSI escape code string for background color. | |
| void | setScreenMode (ScreenMode) |
| Sets a specific screen mode. | |
| void | unsetScreenMode (ScreenMode) |
| Unsets a specific screen mode. | |
| std::bitset< 10 > | make_attr_bitset (std::initializer_list< Attribute > attrs) |
| Helper function to create a bitset from an initializer list of Attributes. | |
| 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. | |
| _load_ext () | |
| __getattr__ (str name) | |
| __dir__ () | |
| None | set_foreground_color (int color) |
| Set the terminal foreground color using one of the F_* constants. | |
| None | set_background_color (int color) |
| Set the terminal background color using one of the B_* constants. | |
| None | set_attribute (int attribute) |
| Enable a terminal text attribute using one of the A_* constants. | |
| None | reset_attribute (int attribute) |
| Disable/reset a terminal text attribute using one of the A_* constants. | |
| None | reset_ansi () |
| Reset all ANSI text attributes and colors to the terminal defaults. | |
| None | clear_screen (bool spaces=True) |
| Clear the terminal and reposition the cursor to top-left. | |
| None | print (str message) |
| Print a message to the terminal using Sista's configured output stream. | |
| Capsule | create_ansi_settings (int fgcolor=..., int bgcolor=..., int attribute=...) |
| Create an ANSI settings object and return it as a Capsule. | |
| Capsule | create_border (str symbol, Capsule ansi_settings) |
| Create a Border object that uses a single-character symbol and ANSI settings. | |
| Capsule | create_coordinates (int y, int x) |
| Create a Coordinates object and return it as a Capsule. | |
Variables | |
| str | MODULE_NAME = f"{__name__}._sista" |
| _ext = _load_ext() | |
| list | _ext_names = [n for n in dir(_ext) if not n.startswith("_")] |
| Capsule = Any | |
| int | F_BLACK |
| int | F_RED |
| int | F_GREEN |
| int | F_YELLOW |
| int | F_BLUE |
| int | F_MAGENTA |
| int | F_CYAN |
| int | F_WHITE |
| int | B_BLACK |
| int | B_RED |
| int | B_GREEN |
| int | B_YELLOW |
| int | B_BLUE |
| int | B_MAGENTA |
| int | B_CYAN |
| int | B_WHITE |
| int | A_RESET |
| int | A_BRIGHT |
| int | A_FAINT |
| int | A_ITALIC |
| int | A_UNDERLINE |
| int | A_BLINK |
| int | A_BLINK_FAST |
| int | A_REVERSE |
| int | A_HIDDEN |
| int | A_STRIKETHROUGH |
| int | DIRECTION_UP |
| int | DIRECTION_DOWN |
| int | DIRECTION_RIGHT |
| int | DIRECTION_LEFT |
| int | BEGINNING_OF_NEXT_LINE |
| int | BEGINNING_OF_PREVIOUS_LINE |
Sista library namespace.
Python type hints and pydocstrings for the Sista C extension module.
Memory-safe and OS-agnostic library for making terminal videogames and animations.
This namespace encapsulates all components of the Sista library.
|
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.
| Enumerator | |
|---|---|
| RESET | |
| BRIGHT | |
| FAINT | |
| ITALIC | |
| UNDERSCORE | |
| BLINK | |
| RAPID_BLINK | |
| REVERSE | |
| HIDDEN | |
| STRIKETHROUGH | |
|
strong |
|
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.
| Enumerator | |
|---|---|
| PACMAN | |
| MATRIX | |
|
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.
| 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. |
|
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.
|
strong |
|
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.
| Enumerator | |
|---|---|
| UP | |
| DOWN | |
| RIGHT | |
| LEFT | |
| BEGINNING_OF_NEXT_LINE | |
| BEGINNING_OF_PREVIOUS_LINE | |
| HORIZONTAL_ABSOLUTE | |
|
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.
| Enumerator | |
|---|---|
| SAVE_CURSOR_POSITION | |
| RESTORE_CURSOR_POSITION | |
|
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.
| Enumerator | |
|---|---|
| SCO_SAVE_CURSOR_POSITION | |
| SCO_RESTORE_CURSOR_POSITION | |
|
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.
| sista.__dir__ | ( | ) |
| sista.__getattr__ | ( | str | name | ) |
|
protected |
| std::string sista::attrStr | ( | Attribute | ) |
Converts an Attribute enum to its corresponding ANSI escape code string.
| attribute | The Attribute to convert. |
This function takes an Attribute enum value and returns the corresponding ANSI escape code as a string. This can be useful for constructing custom ANSI sequences or for logging purposes.
| std::string sista::bgColorStr | ( | BackgroundColor | ) |
Converts a BackgroundColor enum to its corresponding ANSI escape code string.
| color | The BackgroundColor to convert. |
This function takes a BackgroundColor enum value and returns the corresponding ANSI escape code as a string. This can be useful for constructing custom ANSI sequences or for logging purposes.
| std::string sista::bgColorStr | ( | const RGBColor & | ) |
Converts RGB values to their corresponding ANSI escape code string for foreground color.
| red | The red component (0-255). |
| green | The green component (0-255). |
| blue | The blue component (0-255). |
This function takes RGB values and returns the corresponding ANSI escape code as a string for setting the foreground color. This can be useful for constructing custom ANSI sequences or for logging purposes.
| std::string sista::bgColorStr | ( | unsigned char | , |
| unsigned char | , | ||
| unsigned char | |||
| ) |
Converts RGB values to their corresponding ANSI escape code string for background color.
| red | The red component (0-255). |
| green | The green component (0-255). |
| blue | The blue component (0-255). |
This function takes RGB values and returns the corresponding ANSI escape code as a string for setting the background color. This can be useful for constructing custom ANSI sequences or for logging purposes.
| None sista.clear_screen | ( | bool | spaces = True | ) |
Clear the terminal and reposition the cursor to top-left.
:param spaces:
| void sista::clearScreen | ( | bool | spaces = true | ) |
Clears the terminal screen and optionally the scrollback buffer.
| spaces | If 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.
spaces to false. | Capsule sista.create_ansi_settings | ( | int | fgcolor = ..., |
| int | bgcolor = ..., |
||
| int | attribute = ... |
||
| ) |
Create an ANSI settings object and return it as a Capsule.
The settings object describes foreground/background colors and a text attribute to be applied when rendering borders, pawns, etc.
:param fgcolor: Foreground color (one of the F_* constants). :param bgcolor: Background color (one of the B_* constants). :param attribute: Text attribute (one of the A_* constants). :return: Capsule wrapping the ANSISettings handler.
| Capsule sista.create_coordinates | ( | int | y, |
| int | x | ||
| ) |
Create a Coordinates object and return it as a Capsule.
Coordinates are small value objects (y,row and x,column) used by pawn creation and movement functions. Caller is responsible for freeing the capsule when no longer needed (the extension provides destructors).
:param y: Row index (unsigned short). :param x: Column index (unsigned short). :return: Capsule wrapping a Coordinates struct.
| std::string sista::fgColorStr | ( | const RGBColor & | ) |
Converts an RGBColor struct to its corresponding ANSI escape code string for foreground color.
| color | The RGBColor to convert. |
This function takes an RGBColor struct and returns the corresponding ANSI escape code as a string for setting the foreground color. This can be useful for constructing custom ANSI sequences or for logging purposes.
| std::string sista::fgColorStr | ( | ForegroundColor | ) |
Converts a ForegroundColor enum to its corresponding ANSI escape code string.
| color | The ForegroundColor to convert. |
This function takes a ForegroundColor enum value and returns the corresponding ANSI escape code as a string. This can be useful for constructing custom ANSI sequences or for logging purposes.
| std::string sista::fgColorStr | ( | unsigned char | , |
| unsigned char | , | ||
| unsigned char | |||
| ) |
Converts RGB values to their corresponding ANSI escape code string for foreground color.
| red | The red component (0-255). |
| green | The green component (0-255). |
| blue | The blue component (0-255). |
This function takes RGB values and returns the corresponding ANSI escape code as a string for setting the foreground color. This can be useful for constructing custom ANSI sequences or for logging purposes.
|
inline |
Returns the Sista library version as a string.
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.
|
inline |
Returns the major version number of the Sista library.
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.
|
inline |
Returns the minor version number of the Sista library.
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.
|
inline |
Returns the patch version number of the Sista library.
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.
|
inline |
Helper function to create a bitset from an initializer list of Attributes.
| attrs | An initializer list of Attribute enums. |
This function takes an initializer list of Attribute enums and converts it into a std::bitset<10>, where each bit corresponds to an attribute being set. This is useful for managing multiple attributes in the ANSISettings struct.
| None sista.print | ( | str | message | ) |
Print a message to the terminal using Sista's configured output stream.
The function respects Sista's current ANSI settings (colors/attributes) as managed by the extension.
:param message: Message to print (a single text line). :type message: str
| None sista.reset_ansi | ( | ) |
Reset all ANSI text attributes and colors to the terminal defaults.
| None sista.reset_attribute | ( | int | attribute | ) |
Disable/reset a terminal text attribute using one of the A_* constants.
:param attribute: One of the A_* constants (e.g. A_RESET). :type attribute: int
| 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:
| void sista::resetAttribute | ( | Attribute | ) |
Resets a text attribute using a predefined Attribute enum.
| attribute | The 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.
| None sista.set_attribute | ( | int | attribute | ) |
Enable a terminal text attribute using one of the A_* constants.
:param attribute: One of the A_* constants (e.g. A_UNDERLINE). :type attribute: int
| None sista.set_background_color | ( | int | color | ) |
Set the terminal background color using one of the B_* constants.
:param color: One of the B_* constants (e.g. B_BLUE). :type color: int
| None sista.set_foreground_color | ( | int | color | ) |
Set the terminal foreground color using one of the F_* constants.
:param color: One of the F_* constants (e.g. F_RED). :type color: int
| void sista::setAttribute | ( | Attribute | ) |
Sets a text attribute using a predefined Attribute enum.
| attribute | The 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.
| void sista::setBackgroundColor | ( | BackgroundColor | ) |
Sets the background color using a predefined BackgroundColor enum.
| color | The 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.
| void sista::setBackgroundColor | ( | const RGBColor & | ) |
Sets the background color using an RGBColor struct.
| rgbcolor | The 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.
| void sista::setBackgroundColor | ( | unsigned char | ) |
Sets the background color using a 256-color palette index.
| color | The 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.
| void sista::setBackgroundColor | ( | unsigned char | , |
| unsigned char | , | ||
| unsigned char | |||
| ) |
Sets the background color using RGB values.
| red | The red component (0-255). |
| green | The green component (0-255). |
| blue | The 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.
| void sista::setForegroundColor | ( | const RGBColor & | ) |
Sets the foreground color using an RGBColor struct.
| rgbcolor | The 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.
| void sista::setForegroundColor | ( | ForegroundColor | ) |
Sets the foreground color using a predefined ForegroundColor enum.
| color | The 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.
| void sista::setForegroundColor | ( | unsigned char | ) |
Sets the foreground color using a 256-color palette index.
| color | The 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.
| void sista::setForegroundColor | ( | unsigned char | , |
| unsigned char | , | ||
| unsigned char | |||
| ) |
Sets the foreground color using RGB values.
| red | The red component (0-255). |
| green | The green component (0-255). |
| blue | The 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.
| void sista::setScreenMode | ( | ScreenMode | ) |
Sets a specific screen mode.
| mode | The 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.
| void sista::unsetScreenMode | ( | ScreenMode | ) |
Unsets a specific screen mode.
| mode | The 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.
|
protected |
|
protected |
| int sista.A_BLINK |
| int sista.A_BLINK_FAST |
| int sista.A_BRIGHT |
| int sista.A_FAINT |
| int sista.A_HIDDEN |
| int sista.A_ITALIC |
| int sista.A_RESET |
| int sista.A_REVERSE |
| int sista.A_STRIKETHROUGH |
| int sista.A_UNDERLINE |
| int sista.B_BLACK |
| int sista.B_BLUE |
| int sista.B_CYAN |
| int sista.B_GREEN |
| int sista.B_MAGENTA |
| int sista.B_RED |
| int sista.B_WHITE |
| int sista.B_YELLOW |
| int sista.BEGINNING_OF_NEXT_LINE |
| int sista.BEGINNING_OF_PREVIOUS_LINE |
| sista.Capsule = Any |
| int sista.DIRECTION_DOWN |
| int sista.DIRECTION_LEFT |
| int sista.DIRECTION_RIGHT |
| int sista.DIRECTION_UP |
| int sista.F_BLACK |
| int sista.F_BLUE |
| int sista.F_CYAN |
| int sista.F_GREEN |
| int sista.F_MAGENTA |
| int sista.F_RED |
| int sista.F_WHITE |
| int sista.F_YELLOW |
| str sista.MODULE_NAME = f"{__name__}._sista" |