Sista v3.0.0-beta.10
C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
api.h File Reference

C API for Sista library. More...

#include <stddef.h>
Include dependency graph for api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sista_RGBColor
 Represents an RGB color with red, green, and blue components. More...
 
struct  sista_Coordinates
 Represents a pair of coordinates (y, x). More...
 

Typedefs

typedef struct sista_FieldFieldHandler_t
 
typedef struct sista_SwappableFieldSwappableFieldHandler_t
 
typedef struct sista_ANSISettingsANSISettingsHandler_t
 
typedef struct sista_BorderBorderHandler_t
 
typedef struct sista_PawnPawnHandler_t
 
typedef struct sista_Cursor * CursorHandler_t
 

Enumerations

enum  sista_ForegroundColor {
  F_BLACK = 30 , F_RED = 31 , F_GREEN = 32 , F_YELLOW = 33 ,
  F_BLUE = 34 , F_MAGENTA = 35 , F_CYAN = 36 , F_WHITE = 37
}
 Predefined foreground colors for terminal text. More...
 
enum  sista_BackgroundColor {
  B_BLACK = 40 , B_RED = 41 , B_GREEN = 42 , B_YELLOW = 43 ,
  B_BLUE = 44 , B_MAGENTA = 45 , B_CYAN = 46 , B_WHITE = 47
}
 Predefined background colors for terminal text. More...
 
enum  sista_Attribute {
  A_RESET = 0 , A_BRIGHT = 1 , A_FAINT = 2 , A_ITALIC = 3 ,
  A_UNDERLINE = 4 , A_BLINK = 5 , A_BLINK_FAST = 6 , A_REVERSE = 7 ,
  A_HIDDEN = 8 , A_STRIKETHROUGH = 9
}
 Text attributes for terminal text. More...
 
enum  sista_ErrorCode {
  SISTA_OK = 0 , SISTA_ERR_NULL_FIELD = 1001 , SISTA_ERR_NULL_SETTINGS = 1002 , SISTA_ERR_OUT_OF_BOUNDS = 1003 ,
  SISTA_ERR_OCCUPIED = 1004 , SISTA_ERR_BAD_ALLOC = 1005 , SISTA_ERR_NULL_PAWN = 1006 , SISTA_ERR_NULL_BORDER = 1007 ,
  SISTA_ERR_NULL_CURSOR = 1008 , SISTA_ERR_NULL_COLOR = 1009 , SISTA_ERR_UNKNOWN = 1099
}
 Error codes exposed by the C API for detailed diagnostics. More...
 
enum  sista_MoveCursor {
  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...
 

Functions

FieldHandler_t sista_createField (size_t, size_t)
 Creates a Field with the specified width and height.
 
int sista_printField (FieldHandler_t, char)
 Prints the specified Field with a given border.
 
int sista_destroyField (FieldHandler_t)
 Deallocates the Field from memory.
 
SwappableFieldHandler_t sista_createSwappableField (size_t, size_t)
 Creates a SwappableField with the specified width and height.
 
int sista_printSwappableField (SwappableFieldHandler_t, char)
 Prints the specified Field with a given border.
 
int sista_destroySwappableField (SwappableFieldHandler_t)
 Deallocates the SwappableField from memory.
 
int sista_resetAnsi ()
 Resets ANSI settings to default.
 
int sista_setForegroundColor (enum sista_ForegroundColor)
 Sets the foreground color using a predefined color.
 
int sista_setBackgroundColor (enum sista_BackgroundColor)
 Sets the background color using a predefined color.
 
int sista_setAttribute (enum sista_Attribute)
 Sets a text attribute.
 
int sista_resetAttribute (enum sista_Attribute)
 Resets a text attribute.
 
int sista_setForegroundColorRGB (const struct sista_RGBColor *)
 Sets the foreground color using an RGB color.
 
int sista_setBackgroundColorRGB (const struct sista_RGBColor *)
 Sets the background color using an RGB color.
 
ANSISettingsHandler_t sista_createANSISettings (enum sista_ForegroundColor, enum sista_BackgroundColor, enum sista_Attribute)
 Creates an ANSISettings object.
 
ANSISettingsHandler_t sista_createANSISettingsRGB (struct sista_RGBColor, struct sista_RGBColor, enum sista_Attribute)
 Creates an ANSISettings object.
 
int sista_applyANSISettings (ANSISettingsHandler_t)
 Applies the ANSI settings to the terminal.
 
int sista_destroyANSISettings (ANSISettingsHandler_t)
 Deallocates the ANSISettings from memory.
 
BorderHandler_t sista_createBorder (char, ANSISettingsHandler_t)
 Creates a Border object.
 
int sista_destroyBorder (BorderHandler_t)
 Deallocates the Border from memory.
 
int sista_printFieldWithBorder (FieldHandler_t, BorderHandler_t)
 Prints the field with the specified border.
 
int sista_printSwappableFieldWithBorder (SwappableFieldHandler_t, BorderHandler_t)
 Prints the field with the specified border.
 
PawnHandler_t sista_createPawnInSwappableField (SwappableFieldHandler_t, char, ANSISettingsHandler_t, struct sista_Coordinates)
 Creates a Pawn object in a given field.
 
PawnHandler_t sista_createPawnInField (FieldHandler_t, char, ANSISettingsHandler_t, struct sista_Coordinates)
 Creates a Pawn object in a given field.
 
int sista_getLastErrorCode ()
 Returns the last API error code for the current thread.
 
const char * sista_getLastErrorMessage ()
 Returns the last API error message for the current thread.
 
int sista_movePawn (FieldHandler_t, PawnHandler_t, struct sista_Coordinates)
 Moves the pawn to a new position.
 
int sista_addPawnToSwap (SwappableFieldHandler_t, PawnHandler_t, struct sista_Coordinates)
 Adds the Pawn to a list of pawns to be moved ("swapped") later.
 
int sista_applySwaps (SwappableFieldHandler_t)
 Executes all pending pawn swaps.
 
int sista_clearScreen (int spaces)
 Clears the terminal screen and repositions the cursor.
 
CursorHandler_t sista_createCursor ()
 Creates a cursor handler.
 
int sista_moveCursor (CursorHandler_t, enum sista_MoveCursor, unsigned short)
 Moves the cursor in the specified direction by a given amount.
 
int sista_cursorGoTo (CursorHandler_t, unsigned short, unsigned short)
 Moves the cursor to the specified coordinates.
 
int sista_cursorGoToCoordinates (CursorHandler_t, struct sista_Coordinates)
 Moves the cursor to the specified coordinates.
 
int sista_destroyCursor (CursorHandler_t)
 Deallocates the Cursor from memory.
 
const char * sista_getVersion ()
 
int sista_getVersionMajor ()
 
int sista_getVersionMinor ()
 
int sista_getVersionPatch ()
 

Detailed Description

C API for Sista library.

This header defines the C API for the Sista library, allowing interaction with core functionalities such as creating and managing SwappableFields and Pawns. The API is designed to be used in C programs, providing a bridge to the underlying C++ implementations and allowing for FFI usage with other programming languages thanks to ABI compatibility.

Note
This API is compatible with the C89 standard for maximum ABI stability.
Author
FLAK-ZOSO
Date
2025
Version
3.0.0

Typedef Documentation

◆ ANSISettingsHandler_t

◆ BorderHandler_t

typedef struct sista_Border* BorderHandler_t

◆ CursorHandler_t

typedef struct sista_Cursor* CursorHandler_t

◆ FieldHandler_t

typedef struct sista_Field* FieldHandler_t

◆ PawnHandler_t

typedef struct sista_Pawn* PawnHandler_t

◆ SwappableFieldHandler_t

Enumeration Type Documentation

◆ sista_Attribute

Text attributes for terminal text.

This enumeration defines a set of text attributes that can be used to modify the appearance of text in terminal applications using ANSI escape codes. Attributes include styles such as bold, italic, underline, and more.

See also
sista_setAttribute
sista_resetAttribute
sista::Attribute
Enumerator
A_RESET 
A_BRIGHT 
A_FAINT 
A_ITALIC 
A_UNDERLINE 
A_BLINK 
A_BLINK_FAST 
A_REVERSE 
A_HIDDEN 
A_STRIKETHROUGH 

◆ sista_BackgroundColor

Predefined background colors for terminal text.

This enumeration defines a set of standard background colors that can be used to change the background color of text in terminal applications using ANSI escape codes.

See also
sista_setBackgroundColor
sista::BackgroundColor
Enumerator
B_BLACK 
B_RED 
B_GREEN 
B_YELLOW 
B_BLUE 
B_MAGENTA 
B_CYAN 
B_WHITE 

◆ sista_ErrorCode

Error codes exposed by the C API for detailed diagnostics.

Functions that return opaque handlers may fail with NULL. In those cases, callers can use sista_getLastErrorCode() and sista_getLastErrorMessage() to retrieve the specific reason for the most recent failure on the current thread.

Enumerator
SISTA_OK 
SISTA_ERR_NULL_FIELD 
SISTA_ERR_NULL_SETTINGS 
SISTA_ERR_OUT_OF_BOUNDS 
SISTA_ERR_OCCUPIED 
SISTA_ERR_BAD_ALLOC 
SISTA_ERR_NULL_PAWN 
SISTA_ERR_NULL_BORDER 
SISTA_ERR_NULL_CURSOR 
SISTA_ERR_NULL_COLOR 
SISTA_ERR_UNKNOWN 

◆ sista_ForegroundColor

Predefined foreground colors for terminal text.

This enumeration defines a set of standard foreground colors that can be used to change the color of text in terminal applications using ANSI escape codes.

See also
sista_setForegroundColor
sista::ForegroundColor
Enumerator
F_BLACK 
F_RED 
F_GREEN 
F_YELLOW 
F_BLUE 
F_MAGENTA 
F_CYAN 
F_WHITE 

◆ sista_MoveCursor

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
sista::MoveCursor
Enumerator
UP 
DOWN 
RIGHT 
LEFT 
BEGINNING_OF_NEXT_LINE 
BEGINNING_OF_PREVIOUS_LINE 
HORIZONTAL_ABSOLUTE 

Function Documentation

◆ sista_addPawnToSwap()

int sista_addPawnToSwap ( SwappableFieldHandler_t  field,
PawnHandler_t  pawn,
struct sista_Coordinates  destination 
)

Adds the Pawn to a list of pawns to be moved ("swapped") later.

Parameters
fieldThe SwappableField containing the Pawn.
pawnThe Pawn to add to the swap list.
destinationThe destination coordinates.
Returns
Status code from enum sista_ErrorCode.

This function adds the specified Pawn to a list of pawns that will be moved (swapped) when sista_executeSwaps is called. The pawn will be moved to the specified destination coordinates.

On failure, this function also updates the per-thread last-error state accessible with sista_getLastErrorCode() and sista_getLastErrorMessage().

Return values
SISTA_OKIf the pawn was successfully added to the swap list.
SISTA_ERR_NULL_FIELDIf field is NULL.
SISTA_ERR_NULL_PAWNIf pawn is NULL.
SISTA_ERR_OUT_OF_BOUNDSIf the destination is out of bounds.
SISTA_ERR_OCCUPIEDIf the destination is occupied or invalid.
SISTA_ERR_UNKNOWNIf adding the pawn to the swap list failed for another reason.
See also
sista::SwappableField::addPawnToSwap

◆ sista_applyANSISettings()

int sista_applyANSISettings ( ANSISettingsHandler_t  settings)

Applies the ANSI settings to the terminal.

Parameters
settingsThe ANSISettings to apply.
Returns
Status code from enum sista_ErrorCode.

This function applies the specified ANSI settings to the terminal by outputting the corresponding ANSI escape codes to standard output.

See also
sista::ANSISettings::apply
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_SETTINGSIf settings is NULL.

◆ sista_applySwaps()

int sista_applySwaps ( SwappableFieldHandler_t  field)

Executes all pending pawn swaps.

Parameters
fieldThe SwappableField containing the pawns to swap.
Returns
Status code from enum sista_ErrorCode.

This function executes all pending pawn swaps that have been added using sista_addPawnToSwap. It attempts to move each pawn to its specified destination, handling any conflicts or errors that arise.

Note
The swaps that cannot be applied (due to more than one pawn trying to move to the same destination, generally) are skipped.
Todo:
In future versions, the function may return a list of the swaps that could not be applied.

On failure, this function also updates the per-thread last-error state accessible with sista_getLastErrorCode() and sista_getLastErrorMessage().

Return values
SISTA_OKIf all possible (read note) swaps were successful.
SISTA_ERR_NULL_FIELDIf field is NULL.
SISTA_ERR_UNKNOWNIf executing swaps failed for another reason.
See also
sista::SwappableField::applySwaps

◆ sista_clearScreen()

int sista_clearScreen ( int  spaces)

Clears the terminal screen and repositions the cursor.

Parameters
spacesNon-zero to clear visible content and scrollback buffer; zero to only move the cursor to the top-left corner.
Returns
Status code from enum sista_ErrorCode.

This is the C API counterpart of sista::clearScreen(bool).

See also
sista::clearScreen
Return values
SISTA_OKOn success.

◆ sista_createANSISettings()

ANSISettingsHandler_t sista_createANSISettings ( enum  sista_ForegroundColor,
enum  sista_BackgroundColor,
enum  sista_Attribute 
)

Creates an ANSISettings object.

Parameters
fgColorThe foreground color (predefined).
bgColorThe background color (predefined).
attributeThe text attribute to apply.
Returns
A handler to the created ANSISettings object.

This function allocates and initializes a new ANSISettings object. It returns a pointer that can be used to reference the ANSISettings in subsequent API calls.

Return values
NULLIf memory allocation fails.
Warning
The caller is responsible for managing the lifetime of the returned ANSISettings object, including deallocation if necessary.
See also
sista::ANSISettings
sista_destroyANSISettings

◆ sista_createANSISettingsRGB()

ANSISettingsHandler_t sista_createANSISettingsRGB ( struct sista_RGBColor  ,
struct sista_RGBColor  ,
enum  sista_Attribute 
)

Creates an ANSISettings object.

Parameters
fgColorThe foreground color (RGB).
bgColorThe background color (RGB).
attributeThe text attribute to apply.
Returns
A handler to the created ANSISettings object.

This function allocates and initializes a new ANSISettings object. It returns a pointer that can be used to reference the ANSISettings in subsequent API calls. Unlike sista_createANSISettings, it takes RGB colors for foreground and background.

Return values
NULLIf memory allocation fails.
Warning
The caller is responsible for managing the lifetime of the returned ANSISettings object, including deallocation if necessary.
Note
While the API only accepts either predefined colors or RGB colors, the underlying implementation supports mixing both types. This would require two more functions to be exposed in the API.
See also
sista::ANSISettings
sista_destroyANSISettings

◆ sista_createBorder()

BorderHandler_t sista_createBorder ( char  symbol,
ANSISettingsHandler_t  settings 
)

Creates a Border object.

Parameters
symbolThe character symbol for the border brick.
settingsThe ANSISettings to apply to the border brick.
Returns
A handler to the created Border object.

This function allocates and initializes a new Border object with the specified symbol and ANSI settings. It returns a pointer that can be used to reference the Border in subsequent API calls.

Return values
NULLIf memory allocation fails.
Warning
The caller is responsible for managing the lifetime of the returned Border object, including deallocation if necessary.
See also
sista::Border
sista_destroyBorder

◆ sista_createCursor()

CursorHandler_t sista_createCursor ( )

Creates a cursor handler.

Returns
A handler to the created Cursor object.

This function allocates and initializes a new Cursor object. It returns a pointer that can be used to reference the Cursor in subsequent API calls.

Return values
NULLIf memory allocation fails.
Warning
The caller is responsible for managing the lifetime of the returned Cursor object, including deallocation if necessary.
See also
sista::Cursor

◆ sista_createField()

FieldHandler_t sista_createField ( size_t  width,
size_t  height 
)

Creates a Field with the specified width and height.

Parameters
widthThe width of the Field.
heightThe height of the Field.
Returns
A handler to the created Field.

This function allocates and initializes a new Field object with the given dimensions. It returns a pointer that can be used to reference the Field in subsequent API calls.

Return values
NULLIf memory allocation fails.
Warning
The caller is responsible for managing the lifetime of the returned Field object, including deallocation if necessary.
See also
Field

◆ sista_createPawnInField()

PawnHandler_t sista_createPawnInField ( FieldHandler_t  field,
char  symbol,
ANSISettingsHandler_t  settings,
struct sista_Coordinates  position 
)

Creates a Pawn object in a given field.

Parameters
fieldThe Field to add the pawn to.
symbolThe character symbol for the pawn.
settingsThe ANSISettings to apply to the pawn.
positionThe initial position of the pawn.
Returns
A handler to the created Pawn object.

This function allocates and initializes a new Pawn object with the specified symbol, ANSI settings, and initial position. It returns a pointer that can be used to reference the Pawn in subsequent API calls.

Return values
NULLIf creation fails for any reason.
Warning
Unlike with other objects, the caller is NOT responsible for managing the lifetime of the returned Pawn object. Pawns are managed by the Field they are added to, and will be deallocated when the Field is destroyed.
Note
On failure, call sista_getLastErrorCode() and sista_getLastErrorMessage() for details.
See also
sista::Pawn
sista_destroyPawn

◆ sista_createPawnInSwappableField()

PawnHandler_t sista_createPawnInSwappableField ( SwappableFieldHandler_t  field,
char  symbol,
ANSISettingsHandler_t  settings,
struct sista_Coordinates  position 
)

Creates a Pawn object in a given field.

Parameters
fieldThe SwappableField to add the pawn to.
symbolThe character symbol for the pawn.
settingsThe ANSISettings to apply to the pawn.
positionThe initial position of the pawn.
Returns
A handler to the created Pawn object.

This function allocates and initializes a new Pawn object with the specified symbol, ANSI settings, and initial position. It returns a pointer that can be used to reference the Pawn in subsequent API calls.

Return values
NULLIf creation fails for any reason.
Warning
Unlike with other objects, the caller is NOT responsible for managing the lifetime of the returned Pawn object. Pawns are managed by the SwappableField they are added to, and will be deallocated when the SwappableField is destroyed.
Note
On failure, call sista_getLastErrorCode() and sista_getLastErrorMessage() for details.
See also
sista::Pawn
sista_destroyPawn

◆ sista_createSwappableField()

SwappableFieldHandler_t sista_createSwappableField ( size_t  width,
size_t  height 
)

Creates a SwappableField with the specified width and height.

Parameters
widthThe width of the SwappableField.
heightThe height of the SwappableField.
Returns
A handler to the created SwappableField.

This function allocates and initializes a new SwappableField object with the given dimensions. It returns a pointer that can be used to reference the SwappableField in subsequent API calls.

Return values
NULLIf memory allocation fails.
Warning
The caller is responsible for managing the lifetime of the returned SwappableField object, including deallocation if necessary.
See also
SwappableField

◆ sista_cursorGoTo()

int sista_cursorGoTo ( CursorHandler_t  cursor,
unsigned short  y,
unsigned short  x 
)

Moves the cursor to the specified coordinates.

Parameters
cursorThe Cursor handler.
yThe y coordinate (row).
xThe x coordinate (column).
Returns
Status code from enum sista_ErrorCode.

This function moves the terminal cursor to the specified (y, x) coordinates using ANSI escape codes.

See also
sista::Cursor::goTo
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_CURSORIf cursor is NULL.

◆ sista_cursorGoToCoordinates()

int sista_cursorGoToCoordinates ( CursorHandler_t  cursor,
struct sista_Coordinates  coords 
)

Moves the cursor to the specified coordinates.

Parameters
cursorThe Cursor handler.
coordsThe coordinates struct containing y and x.
Returns
Status code from enum sista_ErrorCode.

This function moves the terminal cursor to the specified (y, x) coordinates using ANSI escape codes.

See also
sista::Cursor::goTo
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_CURSORIf cursor is NULL.

◆ sista_destroyANSISettings()

int sista_destroyANSISettings ( ANSISettingsHandler_t  settings)

Deallocates the ANSISettings from memory.

Parameters
settingsThe ANSISettings to delete.
Returns
Status code from enum sista_ErrorCode.

This function deallocates the ANSISettings from memory through the opaque handler pointing to it.

See also
sista::ANSISettings
sista_createANSISettings
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_SETTINGSIf settings is NULL.

◆ sista_destroyBorder()

int sista_destroyBorder ( BorderHandler_t  border)

Deallocates the Border from memory.

Parameters
borderThe Border to delete.
Returns
Status code from enum sista_ErrorCode.

This function deallocates the Border from memory through the opaque handler pointing to it.

See also
sista::Border
sista_createBorder
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_BORDERIf border is NULL.

◆ sista_destroyCursor()

int sista_destroyCursor ( CursorHandler_t  cursor)

Deallocates the Cursor from memory.

Parameters
cursorThe Cursor to delete.
Returns
Status code from enum sista_ErrorCode.

This function deallocates the Cursor from memory through the opaque handler pointing to it.

See also
sista::Cursor
sista_createCursor
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_CURSORIf cursor is NULL.

◆ sista_destroyField()

int sista_destroyField ( FieldHandler_t  field)

Deallocates the Field from memory.

Parameters
fieldThe Field to delete
Returns
Status code from enum sista_ErrorCode.

This function deallocates the Field from memory through the opaque handler pointing to it.

See also
Field
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_FIELDIf field is NULL.

◆ sista_destroySwappableField()

int sista_destroySwappableField ( SwappableFieldHandler_t  field)

Deallocates the SwappableField from memory.

Parameters
fieldThe SwappableField to delete
Returns
Status code from enum sista_ErrorCode.

This function deallocates the SwappableField from memory through the opaque handler pointing to it.

See also
SwappableField
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_FIELDIf field is NULL.

◆ sista_getLastErrorCode()

int sista_getLastErrorCode ( )

Returns the last API error code for the current thread.

This value is updated by API functions that expose failure diagnostics, including functions that return NULL and functions that return a status code from enum sista_ErrorCode.

Successful calls participating in this model reset the value to SISTA_OK.

Returns
One value from enum sista_ErrorCode.

◆ sista_getLastErrorMessage()

const char * sista_getLastErrorMessage ( )

Returns the last API error message for the current thread.

The returned pointer remains valid until the next API call on the same thread that updates the last-error state.

Successful calls participating in this model reset the message to "ok". Call this function immediately after a failing API call to read diagnostics.

Returns
A static, null-terminated message string.

◆ sista_getVersion()

const char * sista_getVersion ( )

◆ sista_getVersionMajor()

int sista_getVersionMajor ( )

◆ sista_getVersionMinor()

int sista_getVersionMinor ( )

◆ sista_getVersionPatch()

int sista_getVersionPatch ( )

◆ sista_moveCursor()

int sista_moveCursor ( CursorHandler_t  cursor,
enum  sista_MoveCursor,
unsigned short  amount 
)

Moves the cursor in the specified direction by a given amount.

Parameters
cursorThe Cursor handler.
directionThe direction to move the cursor.
amountThe number of positions to move the cursor.
Returns
Status code from enum sista_ErrorCode.

This function moves the terminal cursor in the specified direction by the given amount using ANSI escape codes.

See also
sista::Cursor::move
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_CURSORIf cursor is NULL.

◆ sista_movePawn()

int sista_movePawn ( FieldHandler_t  field,
PawnHandler_t  pawn,
struct sista_Coordinates  destination 
)

Moves the pawn to a new position.

Parameters
fieldThe Field containing the Pawn.
pawnThe Pawn to move.
destinationThe destination coordinates.
Returns
Status code from enum sista_ErrorCode.

On failure, this function also updates the per-thread last-error state accessible with sista_getLastErrorCode() and sista_getLastErrorMessage().

Return values
SISTA_OKIf the move was successful.
SISTA_ERR_NULL_FIELDIf field is NULL.
SISTA_ERR_NULL_PAWNIf pawn is NULL.
SISTA_ERR_OUT_OF_BOUNDSIf the destination is out of bounds.
SISTA_ERR_OCCUPIEDIf the destination is occupied or invalid.
SISTA_ERR_UNKNOWNIf the move failed for another reason.
See also
sista::Field::movePawn

◆ sista_printField()

int sista_printField ( FieldHandler_t  field,
char  border 
)

Prints the specified Field with a given border.

Parameters
fieldThe Field.
borderThe border character to use.
Returns
Status code from enum sista_ErrorCode.

This function prints the entire field to the terminal, using the specified character as the border around the field.

See also
Field
Border
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_FIELDIf field is NULL.

◆ sista_printFieldWithBorder()

int sista_printFieldWithBorder ( FieldHandler_t  field,
BorderHandler_t  border 
)

Prints the field with the specified border.

Parameters
fieldThe Field to print.
borderThe Border to print.
Returns
Status code from enum sista_ErrorCode.

This function prints the entire field to the terminal, using the specified Border object to draw the border around the field.

See also
sista::Border::print
sista::Field::print
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_FIELDIf field is NULL.
SISTA_ERR_NULL_BORDERIf border is NULL.

◆ sista_printSwappableField()

int sista_printSwappableField ( SwappableFieldHandler_t  field,
char  border 
)

Prints the specified Field with a given border.

Parameters
fieldThe SwappableField.
borderThe border character to use.
Returns
Status code from enum sista_ErrorCode.

This function prints the entire field to the terminal, using the specified character as the border around the field.

See also
Field
Border
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_FIELDIf field is NULL.

◆ sista_printSwappableFieldWithBorder()

int sista_printSwappableFieldWithBorder ( SwappableFieldHandler_t  field,
BorderHandler_t  border 
)

Prints the field with the specified border.

Parameters
fieldThe SwappableField to print.
borderThe Border to print.
Returns
Status code from enum sista_ErrorCode.

This function prints the entire field to the terminal, using the specified Border object to draw the border around the field.

See also
sista::Border::print
sista::Field::print
Return values
SISTA_OKOn success.
SISTA_ERR_NULL_FIELDIf field is NULL.
SISTA_ERR_NULL_BORDERIf border is NULL.

◆ sista_resetAnsi()

int sista_resetAnsi ( )

Resets ANSI settings to default.

Returns
Status code from enum sista_ErrorCode.

This function resets the terminal's ANSI settings, including colors and attributes, to their default values.

See also
sista::resetAnsi
Return values
SISTA_OKOn success.

◆ sista_resetAttribute()

int sista_resetAttribute ( enum  sista_Attribute)

Resets a text attribute.

Parameters
attributeThe text attribute to reset.
Returns
Status code from enum sista_ErrorCode.

This function resets a text attribute, such as bold or underline, specified in the sista_Attribute enumeration. It outputs the corresponding ANSI escape code to standard output.

See also
sista_Attribute
sista::resetAttribute
Return values
SISTA_OKOn success.

◆ sista_setAttribute()

int sista_setAttribute ( enum  sista_Attribute)

Sets a text attribute.

Parameters
attributeThe text attribute to set.
Returns
Status code from enum sista_ErrorCode.

This function sets a text attribute, such as bold or underline, specified in the sista_Attribute enumeration. It outputs the corresponding ANSI escape code to standard output.

See also
sista_Attribute
sista::setAttribute
Return values
SISTA_OKOn success.

◆ sista_setBackgroundColor()

int sista_setBackgroundColor ( enum  sista_BackgroundColor)

Sets the background color using a predefined color.

Parameters
colorThe predefined background color to set.
Returns
Status code from enum sista_ErrorCode.

This function sets the terminal's background color to one of the predefined colors specified in the sista_BackgroundColor enumeration. It outputs the corresponding ANSI escape code to standard output.

See also
sista_BackgroundColor
sista::setBackgroundColor
Return values
SISTA_OKOn success.

◆ sista_setBackgroundColorRGB()

int sista_setBackgroundColorRGB ( const struct sista_RGBColor color)

Sets the background color using an RGB color.

Parameters
colorA pointer to a sista_RGBColor struct defining the color.
Returns
Status code from enum sista_ErrorCode.

This function sets the terminal's background color using the RGB components specified in the provided sista_RGBColor struct. It outputs the corresponding ANSI escape code to standard output.

Return values
SISTA_OKOn success.
SISTA_ERR_NULL_COLORIf color is NULL.
See also
sista_RGBColor
sista::setBackgroundColor

◆ sista_setForegroundColor()

int sista_setForegroundColor ( enum  sista_ForegroundColor)

Sets the foreground color using a predefined color.

Parameters
colorThe predefined foreground color to set.
Returns
Status code from enum sista_ErrorCode.

This function sets the terminal's foreground color to one of the predefined colors specified in the sista_ForegroundColor enumeration. It outputs the corresponding ANSI escape code to standard output.

See also
sista_ForegroundColor
sista::setForegroundColor
Return values
SISTA_OKOn success.

◆ sista_setForegroundColorRGB()

int sista_setForegroundColorRGB ( const struct sista_RGBColor color)

Sets the foreground color using an RGB color.

Parameters
colorA pointer to a sista_RGBColor struct defining the color.
Returns
Status code from enum sista_ErrorCode.

This function sets the terminal's foreground color using the RGB components specified in the provided sista_RGBColor struct. It outputs the corresponding ANSI escape code to standard output.

Return values
SISTA_OKOn success.
SISTA_ERR_NULL_COLORIf color is NULL.
See also
sista_RGBColor
sista::setForegroundColor