Sista v3.0.0-beta.10
C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
17#pragma once
18
19#include <stddef.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
34struct sista_Field;
36
53FieldHandler_t sista_createField(size_t, size_t);
80
92
136
146int sista_resetAnsi();
147
223 unsigned char red;
224 unsigned char green;
225 unsigned char blue;
226};
227
310
320struct sista_ANSISettings;
322
343 enum sista_Attribute);
368 struct sista_RGBColor,
369 enum sista_Attribute);
395
405struct sista_Border;
407
439
470
481 unsigned short y;
482 unsigned short x;
483};
484
494struct sista_Pawn;
495typedef struct sista_Pawn* PawnHandler_t;
496
517
544 struct sista_Coordinates);
571 struct sista_Coordinates);
572
584
595const char* sista_getLastErrorMessage();
596
616
664
675int sista_clearScreen(int spaces);
676
694
695struct sista_Cursor;
696typedef struct sista_Cursor* CursorHandler_t;
697
726int sista_moveCursor(CursorHandler_t, enum sista_MoveCursor, unsigned short);
740int sista_cursorGoTo(CursorHandler_t, unsigned short, unsigned short);
767
768const char* sista_getVersion();
772
773#ifdef __cplusplus
774}
775#endif
const char * sista_getVersion()
Definition api.cpp:463
ANSISettingsHandler_t sista_createANSISettings(enum sista_ForegroundColor, enum sista_BackgroundColor, enum sista_Attribute)
Creates an ANSISettings object.
Definition api.cpp:144
int sista_printSwappableField(SwappableFieldHandler_t, char)
Prints the specified Field with a given border.
Definition api.cpp:82
int sista_getVersionPatch()
Definition api.cpp:472
int sista_getVersionMajor()
Definition api.cpp:466
struct sista_Cursor * CursorHandler_t
Definition api.h:696
sista_ErrorCode
Error codes exposed by the C API for detailed diagnostics.
Definition api.h:504
@ SISTA_ERR_NULL_SETTINGS
Definition api.h:507
@ SISTA_ERR_NULL_FIELD
Definition api.h:506
@ SISTA_ERR_NULL_PAWN
Definition api.h:511
@ SISTA_ERR_OCCUPIED
Definition api.h:509
@ SISTA_ERR_NULL_CURSOR
Definition api.h:513
@ SISTA_ERR_NULL_BORDER
Definition api.h:512
@ SISTA_ERR_OUT_OF_BOUNDS
Definition api.h:508
@ SISTA_ERR_NULL_COLOR
Definition api.h:514
@ SISTA_ERR_BAD_ALLOC
Definition api.h:510
@ SISTA_OK
Definition api.h:505
@ SISTA_ERR_UNKNOWN
Definition api.h:515
int sista_printField(FieldHandler_t, char)
Prints the specified Field with a given border.
Definition api.cpp:73
sista_Attribute
Text attributes for terminal text.
Definition api.h:199
@ A_BLINK_FAST
Definition api.h:206
@ A_RESET
Definition api.h:200
@ A_HIDDEN
Definition api.h:208
@ A_ITALIC
Definition api.h:203
@ A_STRIKETHROUGH
Definition api.h:209
@ A_FAINT
Definition api.h:202
@ A_BLINK
Definition api.h:205
@ A_REVERSE
Definition api.h:207
@ A_UNDERLINE
Definition api.h:204
@ A_BRIGHT
Definition api.h:201
int sista_setAttribute(enum sista_Attribute)
Sets a text attribute.
Definition api.cpp:107
int sista_setForegroundColorRGB(const struct sista_RGBColor *)
Sets the foreground color using an RGB color.
Definition api.cpp:117
struct sista_Field * FieldHandler_t
Definition api.h:35
sista_ForegroundColor
Predefined foreground colors for terminal text.
Definition api.h:158
@ F_RED
Definition api.h:160
@ F_GREEN
Definition api.h:161
@ F_CYAN
Definition api.h:165
@ F_WHITE
Definition api.h:166
@ F_MAGENTA
Definition api.h:164
@ F_BLACK
Definition api.h:159
@ F_YELLOW
Definition api.h:162
@ F_BLUE
Definition api.h:163
struct sista_Border * BorderHandler_t
Definition api.h:406
int sista_printFieldWithBorder(FieldHandler_t, BorderHandler_t)
Prints the field with the specified border.
Definition api.cpp:227
int sista_destroyANSISettings(ANSISettingsHandler_t)
Deallocates the ANSISettings from memory.
Definition api.cpp:182
int sista_getLastErrorCode()
Returns the last API error code for the current thread.
Definition api.cpp:475
struct sista_ANSISettings * ANSISettingsHandler_t
Definition api.h:321
int sista_cursorGoTo(CursorHandler_t, unsigned short, unsigned short)
Moves the cursor to the specified coordinates.
Definition api.cpp:445
ANSISettingsHandler_t sista_createANSISettingsRGB(struct sista_RGBColor, struct sista_RGBColor, enum sista_Attribute)
Creates an ANSISettings object.
int sista_destroyField(FieldHandler_t)
Deallocates the Field from memory.
Definition api.cpp:43
int sista_setBackgroundColorRGB(const struct sista_RGBColor *)
Sets the background color using an RGB color.
Definition api.cpp:130
int sista_movePawn(FieldHandler_t, PawnHandler_t, struct sista_Coordinates)
Moves the pawn to a new position.
Definition api.cpp:328
struct sista_Pawn * PawnHandler_t
Definition api.h:495
int sista_destroySwappableField(SwappableFieldHandler_t)
Deallocates the SwappableField from memory.
Definition api.cpp:63
int sista_moveCursor(CursorHandler_t, enum sista_MoveCursor, unsigned short)
Moves the cursor in the specified direction by a given amount.
Definition api.cpp:434
int sista_setForegroundColor(enum sista_ForegroundColor)
Sets the foreground color using a predefined color.
Definition api.cpp:97
int sista_resetAnsi()
Resets ANSI settings to default.
Definition api.cpp:92
int sista_destroyBorder(BorderHandler_t)
Deallocates the Border from memory.
Definition api.cpp:217
FieldHandler_t sista_createField(size_t, size_t)
Creates a Field with the specified width and height.
Definition api.cpp:32
int sista_printSwappableFieldWithBorder(SwappableFieldHandler_t, BorderHandler_t)
Prints the field with the specified border.
Definition api.cpp:240
int sista_resetAttribute(enum sista_Attribute)
Resets a text attribute.
Definition api.cpp:112
struct sista_SwappableField * SwappableFieldHandler_t
Definition api.h:91
int sista_applySwaps(SwappableFieldHandler_t)
Executes all pending pawn swaps.
Definition api.cpp:397
sista_BackgroundColor
Predefined background colors for terminal text.
Definition api.h:178
@ B_BLACK
Definition api.h:179
@ B_RED
Definition api.h:180
@ B_WHITE
Definition api.h:186
@ B_MAGENTA
Definition api.h:184
@ B_GREEN
Definition api.h:181
@ B_BLUE
Definition api.h:183
@ B_YELLOW
Definition api.h:182
@ B_CYAN
Definition api.h:185
int sista_clearScreen(int spaces)
Clears the terminal screen and repositions the cursor.
Definition api.cpp:411
CursorHandler_t sista_createCursor()
Creates a cursor handler.
Definition api.cpp:416
int sista_cursorGoToCoordinates(CursorHandler_t, struct sista_Coordinates)
Moves the cursor to the specified coordinates.
Definition api.cpp:454
sista_MoveCursor
Enumeration for cursor movement directions in ANSI escape codes.
Definition api.h:685
@ BEGINNING_OF_NEXT_LINE
Definition api.h:690
@ HORIZONTAL_ABSOLUTE
Definition api.h:692
@ DOWN
Definition api.h:687
@ UP
Definition api.h:686
@ LEFT
Definition api.h:689
@ RIGHT
Definition api.h:688
@ BEGINNING_OF_PREVIOUS_LINE
Definition api.h:691
PawnHandler_t sista_createPawnInSwappableField(SwappableFieldHandler_t, char, ANSISettingsHandler_t, struct sista_Coordinates)
Creates a Pawn object in a given field.
Definition api.cpp:254
PawnHandler_t sista_createPawnInField(FieldHandler_t, char, ANSISettingsHandler_t, struct sista_Coordinates)
Creates a Pawn object in a given field.
Definition api.cpp:291
int sista_getVersionMinor()
Definition api.cpp:469
BorderHandler_t sista_createBorder(char, ANSISettingsHandler_t)
Creates a Border object.
Definition api.cpp:202
int sista_applyANSISettings(ANSISettingsHandler_t)
Applies the ANSI settings to the terminal.
Definition api.cpp:192
int sista_addPawnToSwap(SwappableFieldHandler_t, PawnHandler_t, struct sista_Coordinates)
Adds the Pawn to a list of pawns to be moved ("swapped") later.
Definition api.cpp:365
const char * sista_getLastErrorMessage()
Returns the last API error message for the current thread.
Definition api.cpp:478
int sista_destroyCursor(CursorHandler_t)
Deallocates the Cursor from memory.
Definition api.cpp:425
int sista_setBackgroundColor(enum sista_BackgroundColor)
Sets the background color using a predefined color.
Definition api.cpp:102
SwappableFieldHandler_t sista_createSwappableField(size_t, size_t)
Creates a SwappableField with the specified width and height.
Definition api.cpp:52
Opaque struct representing ANSI settings.
Opaque struct representing a Border object.
Represents a pair of coordinates (y, x).
Definition api.h:480
unsigned short y
Definition api.h:481
unsigned short x
Definition api.h:482
Opaque struct representing a Field object.
Opaque struct representing a Pawn object.
Represents an RGB color with red, green, and blue components.
Definition api.h:222
unsigned char blue
Definition api.h:225
unsigned char red
Definition api.h:223
unsigned char green
Definition api.h:224
Opaque struct representing a SwappableField object.