Sista v3.0.0-beta.10
C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
sistamodule.c File Reference

Python C extension module for Sista C API. More...

#include <Python.h>
#include <sista/api.h>
Include dependency graph for sistamodule.c:

Classes

struct  CursorObject
 
struct  PawnObject
 
struct  SwappableFieldObject
 
struct  FieldObject
 

Macros

#define PY_SSIZE_T_CLEAN
 

Functions

static int py_sista_raise_from_status (int status_code, const char *fallback_message)
 
static int py_sista_raise_from_last_error (const char *fallback_message)
 
 PyDoc_STRVAR (py_sista_set_foreground_color_doc, "Set the terminal foreground color using one of the `F_*` constants.\n\n" "### Parameters\n\n" "- `color` (int): One of the `F_*` constants (e.g. `F_RED`).\n")
 
 PyDoc_STRVAR (py_sista_set_background_color_doc, "Set the terminal background color using one of the `B_*` constants.\n\n" "### Parameters\n\n" "- `color` (int): One of the `B_*` constants (e.g. `B_BLUE`).\n")
 
 PyDoc_STRVAR (py_sista_set_attribute_doc, "Enable a terminal text attribute using one of the `A_*` constants.\n\n" "### Parameters\n\n" "- `attribute` (int): One of the `A_*` constants (e.g. `A_UNDERLINE`).\n")
 
 PyDoc_STRVAR (py_sista_reset_attribute_doc, "Disable/reset a terminal text attribute using one of the `A_*` constants.\n\n" "### Parameters\n\n" "- `attribute` (int): One of the `A_*` constants (e.g. `A_RESET`).\n")
 
 PyDoc_STRVAR (py_sista_reset_ansi_doc, "Reset all ANSI text attributes and colors to the terminal defaults.\n\n" "Raises `RuntimeError` if the underlying API reports a failure.\n")
 
 PyDoc_STRVAR (py_sista_clear_screen_doc, "Clear the terminal and reposition the cursor to top-left.\n\n" "### Parameters\n\n" "- `spaces` (bool, optional):\n" " - `True` (default): clear visible content and scrollback buffer.\n" " - `False`: only reposition cursor to top-left.\n\n" "### Raises\n\n" "- `RuntimeError`: if the underlying API reports a failure.\n")
 
 PyDoc_STRVAR (py_sista_print_doc, "Print a message to the terminal using Sista's configured output stream.\n\n" "### Parameters\n\n" "- `message` (str): Message to print (a single text line).\n")
 
 PyDoc_STRVAR (py_sista_create_ansi_settings_doc, "Create an ANSI settings object and return it as a capsule.\n\n" "```py\n" "create_ansi_settings(fgcolor=F_WHITE, bgcolor=B_BLACK, attribute=A_RESET) -> Capsule\n" "```\n\n" "### Parameters\n\n" "- `fgcolor` (int): Foreground color (one of the `F_*` constants).\n" "- `bgcolor` (int): Background color (one of the `B_*` constants).\n" "- `attribute` (int): Text attribute (one of the `A_*` constants).\n\n" "### Returns\n\n" "- Capsule wrapping the ANSISettings handler.\n")
 
 PyDoc_STRVAR (py_sista_create_border_doc, "Create a Border object that uses a single-character symbol and ANSI settings.\n\n" "### Parameters\n\n" "- `symbol` (str): Single character string used to draw border bricks.\n" "- `ansi_settings` (Capsule): Capsule returned by `create_ansi_settings`.\n\n" "### Returns\n\n" "- Capsule wrapping the Border handler.\n")
 
 PyDoc_STRVAR (py_sista_create_coordinates_doc, "Create a Coordinates object and return it as a capsule.\n\n" "### Parameters\n\n" "- `y` (int): Row index.\n" "- `x` (int): Column index.\n\n" "### Returns\n\n" "- Capsule wrapping a Coordinates struct.\n")
 
 PyDoc_STRVAR (py_doc_Field, "Class representing a terminal Field for pawns and borders.\n\n" "Create with `Field(width: int, height: int)`.\n\n" "Provides: `create_pawn`, `move_pawn`, `print_with_border`.\n")
 
 PyDoc_STRVAR (py_doc_SwappableField, "Class representing a terminal SwappableField for pawns and borders.\n\n" "Create with `SwappableField(width: int, height: int)`.\n\n" "Provides: `create_pawn`, `print_with_border`, `add_pawn_to_swap`, `apply_swaps`.\n")
 
 PyDoc_STRVAR (py_doc_Cursor, "Class representing a terminal cursor for movement operations.\n\n" "Create with `Cursor()`.\n\n" "Provides: `move`, `go_to`, `go_to_coordinates`.\n")
 
 PyDoc_STRVAR (py_doc_Pawn, "Class representing a Pawn owned by a Field or SwappableField.\n\n" "Instances are created by `Field.create_pawn(...)` and\n" "`SwappableField.create_pawn(...)`.\n")
 
 PyDoc_STRVAR (py_Field_create_pawn_doc, "Create a Pawn inside this Field and return a Pawn object.\n\n" "### Parameters\n\n" "- `symbol` (str): Single character string representing the pawn.\n" "- `ansi_settings` (Capsule): Capsule returned by `create_ansi_settings`.\n" "- `coords` (Capsule): Capsule returned by `create_coordinates`.\n\n" "### Returns\n\n" "- A `Pawn` object.\n")
 
 PyDoc_STRVAR (py_Field_move_pawn_doc, "Move a pawn inside this Field.\n\n" "### Parameters\n\n" "- `pawn` (Pawn): Pawn object to move.\n" "- `y` (int): Y coordinate of the destination.\n" "- `x` (int): X coordinate of the destination.\n\n" "### Raises\n\n" "- `IndexError`: destination is out of bounds.\n" "- `RuntimeError`: destination is occupied or another API error occurs.\n")
 
 PyDoc_STRVAR (py_Field_print_with_border_doc, "Render this Field to the terminal using the given Border object.\n\n" "### Parameters\n\n" "- `border` (Capsule): Capsule for the Border to draw around the field.\n")
 
 PyDoc_STRVAR (py_SwappableField_create_pawn_doc, "create_pawn(self, symbol: str, ansi_settings: Capsule, coords: Capsule) -> Pawn\n\n" "Create a Pawn inside this SwappableField and return a Pawn object.\n\n" "### Parameters\n\n" "- `symbol` (str): Single character string used to represent the pawn.\n" "- `ansi_settings` (Capsule): Capsule returned by create_ansi_settings().\n" "- `coords` (Capsule): Capsule returned by create_coordinates().\n\n" "### Returns\n\n" "- A `Pawn` object.\n")
 
 PyDoc_STRVAR (py_SwappableField_add_pawn_to_swap_doc, "add_pawn_to_swap(self, pawn: Pawn, coords: Capsule) -> None\n\n" "Schedule a pawn to be swapped to the given coordinates in the next swap operation.\n\n" "### Parameters\n\n" "- `pawn` (Pawn): Pawn object to schedule for swapping.\n" "- `coords` (Capsule): Capsule for the target Coordinates.\n\n" "### Raises\n\n" "- `IndexError`: destination is out of bounds.\n" "- `RuntimeError`: destination is occupied or another API error occurs.\n")
 
 PyDoc_STRVAR (py_SwappableField_apply_swaps_doc, "apply_swaps(self) -> None\n\n" "Execute all scheduled pawn swaps in this SwappableField.\n\n" "### Raises\n\n" "- `RuntimeError`: if applying swaps fails.\n")
 
 PyDoc_STRVAR (py_SwappableField_print_with_border_doc, "print_with_border(self, border: Capsule) -> None\n\n" "Render this SwappableField to the terminal using the given Border object.\n\n" "### Parameters\n\n" "- `border` (Capsule): Capsule for the Border to draw around the field.\n")
 
 PyDoc_STRVAR (py_Cursor_go_to_doc, "Move the cursor to the absolute `(y, x)` position.\n\n" "### Parameters\n\n" "- `y` (int): Row index to move to.\n" "- `x` (int): Column index to move to.\n")
 
 PyDoc_STRVAR (py_Cursor_move_doc, "Move the cursor in the specified direction by the given amount.\n\n" "### Parameters\n\n" "- `direction` (int): One of the `DIRECTION_*` constants.\n" "- `amount` (int): Number of positions to move the cursor.\n")
 
 PyDoc_STRVAR (py_Cursor_go_to_coordinates_doc, "Move the cursor to the position described by a Coordinates capsule.\n\n" "### Parameters\n\n" "- `coords` (Capsule): Capsule returned by `create_coordinates`.\n")
 
static PyObject * py_sista_set_foreground_color (PyObject *self, PyObject *arg)
 Sets the foreground color.
 
static PyObject * py_sista_set_background_color (PyObject *self, PyObject *arg)
 Sets the background color.
 
static PyObject * py_sista_set_attribute (PyObject *self, PyObject *arg)
 Sets the text attribute.
 
static PyObject * py_sista_reset_attribute (PyObject *self, PyObject *arg)
 Resets the text attribute.
 
static PyObject * py_sista_print (PyObject *self, PyObject *args)
 Prints a message.
 
static PyObject * py_sista_reset_ansi (PyObject *self, PyObject *Py_UNUSED(ignored))
 Resets ANSI settings to default.
 
static PyObject * py_sista_clear_screen (PyObject *self, PyObject *args, PyObject *kwargs)
 Clears the terminal and repositions the cursor.
 
static void py_sista_destroy_ansi_settings_capsule_destructor (PyObject *)
 
static PyObject * py_sista_create_ansi_settings (PyObject *self, PyObject *args, PyObject *kwargs)
 
static void py_sista_destroy_border_capsule_destructor (PyObject *capsule)
 Destructor for BorderHandler_t capsule.
 
static PyObject * py_sista_create_border (PyObject *self, PyObject *args)
 Creates a Border object.
 
static void py_sista_destroy_coordinates_capsule_destructor (PyObject *)
 
static PyObject * py_sista_create_coordinates (PyObject *self, PyObject *args)
 Creates a Coordinates object.
 
static void Pawn_dealloc (PyObject *self)
 
static int Pawn_init (PyObject *self, PyObject *args, PyObject *kwds)
 
static PyObject * py_sista_create_pawn_object (PawnHandler_t pawn, PyObject *owner)
 
static PawnHandler_t py_sista_get_pawn_from_object (PyObject *pawn_obj)
 
static void Cursor_dealloc (PyObject *self)
 
static PyObject * Cursor_go_to (PyObject *self, PyObject *args)
 Cursor.go_to(self, y, x)
 
static PyObject * Cursor_go_to_coordinates (PyObject *self, PyObject *args)
 Cursor.go_to_coordinates(self, coords_capsule)
 
static PyObject * Cursor_move (PyObject *self, PyObject *args)
 Cursor.move(self, direction, amount)
 
static int Cursor_init (PyObject *self, PyObject *args, PyObject *kwds)
 
static void SwappableField_dealloc (PyObject *self)
 
static PyObject * SwappableField_create_pawn (PyObject *self, PyObject *args)
 
static PyObject * SwappableField_add_pawn_to_swap (PyObject *self, PyObject *args)
 
static PyObject * SwappableField_apply_swaps (PyObject *self, PyObject *Py_UNUSED(ignored))
 
static PyObject * SwappableField_print_with_border (PyObject *self, PyObject *args)
 
static int SwappableField_init (PyObject *self, PyObject *args, PyObject *kwds)
 
static void Field_dealloc (PyObject *self)
 
static PyObject * Field_create_pawn (PyObject *self, PyObject *args)
 
static PyObject * Field_move_pawn (PyObject *self, PyObject *args)
 
static PyObject * Field_print_with_border (PyObject *self, PyObject *args)
 
static int Field_init (PyObject *self, PyObject *args, PyObject *kwds)
 Initializes a Field object.
 
static int sista_module_exec (PyObject *module)
 
PyMODINIT_FUNC PyInit__sista (void)
 Module initialization function.
 

Variables

static PyTypeObject CursorType
 
static PyTypeObject PawnType
 
static PyMethodDef Cursor_methods []
 
static PyTypeObject SwappableFieldType
 
static PyMethodDef SwappableField_methods []
 
static PyTypeObject FieldType
 
static PyMethodDef Field_methods []
 
static PyMethodDef sista_module_methods []
 
static PyModuleDef_Slot sista_module_slots []
 
static struct PyModuleDef sista_module
 Module definition.
 

Detailed Description

Python C extension module for Sista C API.

This file defines a Python C extension module that wraps the Sista C API, allowing Python programs to interact with the Sista library functionalities.

Author
FLAK-ZOSO
Date
2025
Version
3.0.0
See also
https://peps.python.org/pep-0007/

Macro Definition Documentation

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Function Documentation

◆ Cursor_dealloc()

static void Cursor_dealloc ( PyObject *  self)
static

◆ Cursor_go_to()

static PyObject * Cursor_go_to ( PyObject *  self,
PyObject *  args 
)
static

Cursor.go_to(self, y, x)

Moves the cursor to the specified (y, x) coordinates.

Parameters
yThe y coordinate.
xThe x coordinate.

◆ Cursor_go_to_coordinates()

static PyObject * Cursor_go_to_coordinates ( PyObject *  self,
PyObject *  args 
)
static

Cursor.go_to_coordinates(self, coords_capsule)

Moves the cursor to the specified coordinates.

Parameters
coords_capsuleCapsule containing Coordinates.

◆ Cursor_init()

static int Cursor_init ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)
static

◆ Cursor_move()

static PyObject * Cursor_move ( PyObject *  self,
PyObject *  args 
)
static

Cursor.move(self, direction, amount)

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

Parameters
directionThe direction to move the cursor.
amountThe amount to move the cursor.

◆ Field_create_pawn()

static PyObject * Field_create_pawn ( PyObject *  self,
PyObject *  args 
)
static

◆ Field_dealloc()

static void Field_dealloc ( PyObject *  self)
static

◆ Field_init()

static int Field_init ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)
static

Initializes a Field object.

Parameters
wThe width of the field.
hThe height of the field.
Returns
0 on success, -1 on failure.

This function is called during the creation of a Field object.

◆ Field_move_pawn()

static PyObject * Field_move_pawn ( PyObject *  self,
PyObject *  args 
)
static

◆ Field_print_with_border()

static PyObject * Field_print_with_border ( PyObject *  self,
PyObject *  args 
)
static

◆ Pawn_dealloc()

static void Pawn_dealloc ( PyObject *  self)
static

◆ Pawn_init()

static int Pawn_init ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)
static

◆ py_sista_clear_screen()

static PyObject * py_sista_clear_screen ( PyObject *  self,
PyObject *  args,
PyObject *  kwargs 
)
static

Clears the terminal and repositions the cursor.

Parameters
spacesWhether to clear visible content and scrollback buffer.

◆ py_sista_create_ansi_settings()

static PyObject * py_sista_create_ansi_settings ( PyObject *  self,
PyObject *  args,
PyObject *  kwargs 
)
static

◆ py_sista_create_border()

static PyObject * py_sista_create_border ( PyObject *  self,
PyObject *  args 
)
static

Creates a Border object.

Parameters
borderThe BorderHandler_t to wrap.
Returns
A capsule containing the BorderHandler_t.

◆ py_sista_create_coordinates()

static PyObject * py_sista_create_coordinates ( PyObject *  self,
PyObject *  args 
)
static

Creates a Coordinates object.

Parameters
yThe y coordinate.
xThe x coordinate.
Returns
A capsule containing the Coordinates object.

◆ py_sista_create_pawn_object()

static PyObject * py_sista_create_pawn_object ( PawnHandler_t  pawn,
PyObject *  owner 
)
static

◆ py_sista_destroy_ansi_settings_capsule_destructor()

static void py_sista_destroy_ansi_settings_capsule_destructor ( PyObject *  capsule)
static

◆ py_sista_destroy_border_capsule_destructor()

static void py_sista_destroy_border_capsule_destructor ( PyObject *  capsule)
static

Destructor for BorderHandler_t capsule.

Parameters
capsuleThe capsule object.

This function is called when the BorderHandler_t capsule is deallocated. It retrieves the BorderHandler_t pointer from the capsule and calls the appropriate destructor to free the memory.

◆ py_sista_destroy_coordinates_capsule_destructor()

static void py_sista_destroy_coordinates_capsule_destructor ( PyObject *  capsule)
static

◆ py_sista_get_pawn_from_object()

static PawnHandler_t py_sista_get_pawn_from_object ( PyObject *  pawn_obj)
static

◆ py_sista_print()

static PyObject * py_sista_print ( PyObject *  self,
PyObject *  args 
)
static

Prints a message.

Prints a message using Sista's ANSI settings, using the same stream as printf.

Parameters
messageThe message to print.

◆ py_sista_raise_from_last_error()

static int py_sista_raise_from_last_error ( const char *  fallback_message)
static

◆ py_sista_raise_from_status()

static int py_sista_raise_from_status ( int  status_code,
const char *  fallback_message 
)
static

◆ py_sista_reset_ansi()

static PyObject * py_sista_reset_ansi ( PyObject *  self,
PyObject *  Py_UNUSEDignored 
)
static

Resets ANSI settings to default.

◆ py_sista_reset_attribute()

static PyObject * py_sista_reset_attribute ( PyObject *  self,
PyObject *  arg 
)
static

Resets the text attribute.

Parameters
attributeThe text attribute to reset.

◆ py_sista_set_attribute()

static PyObject * py_sista_set_attribute ( PyObject *  self,
PyObject *  arg 
)
static

Sets the text attribute.

Parameters
attributeThe text attribute to set.

◆ py_sista_set_background_color()

static PyObject * py_sista_set_background_color ( PyObject *  self,
PyObject *  arg 
)
static

Sets the background color.

Parameters
colorThe background color to set.

◆ py_sista_set_foreground_color()

static PyObject * py_sista_set_foreground_color ( PyObject *  self,
PyObject *  arg 
)
static

Sets the foreground color.

Parameters
colorThe foreground color to set.

◆ PyDoc_STRVAR() [1/24]

PyDoc_STRVAR ( py_Cursor_go_to_coordinates_doc  ,
"Move the cursor to the position described by a Coordinates capsule.\n\n" "### Parameters\n\n" "- `coords` (Capsule): Capsule returned by `create_coordinates`.\n"   
)

◆ PyDoc_STRVAR() [2/24]

PyDoc_STRVAR ( py_Cursor_go_to_doc  ,
"Move the cursor to the absolute `(y, x)` position.\n\n" "### Parameters\n\n" "- `y` (int): Row index to move to.\n" "- `x` (int): Column index to move to.\n"   
)

◆ PyDoc_STRVAR() [3/24]

PyDoc_STRVAR ( py_Cursor_move_doc  ,
"Move the cursor in the specified direction by the given amount.\n\n" "### Parameters\n\n" "- `direction` (int): One of the `DIRECTION_*` constants.\n" "- `amount` (int): Number of positions to move the cursor.\n"   
)

◆ PyDoc_STRVAR() [4/24]

PyDoc_STRVAR ( py_doc_Cursor  ,
"Class representing a terminal cursor for movement operations.\n\n" "Create with `Cursor()`.\n\n" "Provides: `move`  ,
`go_to`  ,
`go_to_coordinates`.\n"   
)

◆ PyDoc_STRVAR() [5/24]

PyDoc_STRVAR ( py_doc_Field  ,
"Class representing a terminal Field for pawns and borders.\n\n" "Create with `Field(width: int, height: int)`.\n\n" "Provides: `create_pawn`  ,
`move_pawn`  ,
`print_with_border`.\n"   
)

◆ PyDoc_STRVAR() [6/24]

PyDoc_STRVAR ( py_doc_Pawn  ,
"Class representing a Pawn owned by a Field or SwappableField.\n\n" "Instances are created by `Field.create_pawn(...)` and\n" "`SwappableField.create_pawn(...)`.\n"   
)

◆ PyDoc_STRVAR() [7/24]

PyDoc_STRVAR ( py_doc_SwappableField  ,
"Class representing a terminal SwappableField for pawns and borders.\n\n" "Create with `SwappableField(width: int, height: int)`.\n\n" "Provides: `create_pawn`  ,
`print_with_border`  ,
`add_pawn_to_swap`  ,
`apply_swaps`.\n"   
)

◆ PyDoc_STRVAR() [8/24]

PyDoc_STRVAR ( py_Field_create_pawn_doc  ,
"Create a Pawn inside this Field and return a Pawn object.\n\n" "### Parameters\n\n" "- `symbol` (str): Single character string representing the pawn.\n" "- `ansi_settings` (Capsule): Capsule returned by `create_ansi_settings`.\n" "- `coords` (Capsule): Capsule returned by `create_coordinates`.\n\n" "### Returns\n\n" "- A `Pawn` object.\n"   
)

◆ PyDoc_STRVAR() [9/24]

PyDoc_STRVAR ( py_Field_move_pawn_doc  ,
"Move a pawn inside this Field.\n\n" "### Parameters\n\n" "- `pawn` (Pawn): Pawn object to move.\n" "- `y` (int): Y coordinate of the destination.\n" "- `x` (int): X coordinate of the destination.\n\n" "### Raises\n\n" "- `IndexError`: destination is out of bounds.\n" "- `RuntimeError`: destination is occupied or another API error occurs.\n"   
)

◆ PyDoc_STRVAR() [10/24]

PyDoc_STRVAR ( py_Field_print_with_border_doc  ,
"Render this Field to the terminal using the given Border object.\n\n" "### Parameters\n\n" "- `border` (Capsule): Capsule for the Border to draw around the field.\n"   
)

◆ PyDoc_STRVAR() [11/24]

PyDoc_STRVAR ( py_sista_clear_screen_doc  ,
"Clear the terminal and reposition the cursor to top-left.\n\n" "### Parameters\n\n" "- `spaces` (bool, optional):\n" " - `True` (default): clear visible content and scrollback buffer.\n" " - `False`: only reposition cursor to top-left.\n\n" "### Raises\n\n" "- `RuntimeError`: if the underlying API reports a failure.\n"   
)

◆ PyDoc_STRVAR() [12/24]

PyDoc_STRVAR ( py_sista_create_ansi_settings_doc  ,
"Create an ANSI settings object and return it as a capsule.\n\n" "```py\n" "create_ansi_settings(fgcolor=F_WHITE, bgcolor=B_BLACK, attribute=A_RESET) -> Capsule\n" "```\n\n" "### Parameters\n\n" "- `fgcolor` (int): Foreground color (one of the `F_*` constants).\n" "- `bgcolor` (int): Background color (one of the `B_*` constants).\n" "- `attribute` (int): Text attribute (one of the `A_*` constants).\n\n" "### Returns\n\n" "- Capsule wrapping the ANSISettings handler.\n"   
)

◆ PyDoc_STRVAR() [13/24]

PyDoc_STRVAR ( py_sista_create_border_doc  ,
"Create a Border object that uses a single-character symbol and ANSI settings.\n\n" "### Parameters\n\n" "- `symbol` (str): Single character string used to draw border bricks.\n" "- `ansi_settings` (Capsule): Capsule returned by `create_ansi_settings`.\n\n" "### Returns\n\n" "- Capsule wrapping the Border handler.\n"   
)

◆ PyDoc_STRVAR() [14/24]

PyDoc_STRVAR ( py_sista_create_coordinates_doc  ,
"Create a Coordinates object and return it as a capsule.\n\n" "### Parameters\n\n" "- `y` (int): Row index.\n" "- `x` (int): Column index.\n\n" "### Returns\n\n" "- Capsule wrapping a Coordinates struct.\n"   
)

◆ PyDoc_STRVAR() [15/24]

PyDoc_STRVAR ( py_sista_print_doc  ,
"Print a message to the terminal using Sista's configured output stream.\n\n" "### Parameters\n\n" "- `message` (str): Message to print (a single text line).\n"   
)

◆ PyDoc_STRVAR() [16/24]

PyDoc_STRVAR ( py_sista_reset_ansi_doc  ,
"Reset all ANSI text attributes and colors to the terminal defaults.\n\n" "Raises `RuntimeError` if the underlying API reports a failure.\n"   
)

◆ PyDoc_STRVAR() [17/24]

PyDoc_STRVAR ( py_sista_reset_attribute_doc  ,
"Disable/reset a terminal text attribute using one of the `A_*` constants.\n\n" "### Parameters\n\n" "- `attribute` (int): One of the `A_*` constants (e.g. `A_RESET`).\n"   
)

◆ PyDoc_STRVAR() [18/24]

PyDoc_STRVAR ( py_sista_set_attribute_doc  ,
"Enable a terminal text attribute using one of the `A_*` constants.\n\n" "### Parameters\n\n" "- `attribute` (int): One of the `A_*` constants (e.g. `A_UNDERLINE`).\n"   
)

◆ PyDoc_STRVAR() [19/24]

PyDoc_STRVAR ( py_sista_set_background_color_doc  ,
"Set the terminal background color using one of the `B_*` constants.\n\n" "### Parameters\n\n" "- `color` (int): One of the `B_*` constants (e.g. `B_BLUE`).\n"   
)

◆ PyDoc_STRVAR() [20/24]

PyDoc_STRVAR ( py_sista_set_foreground_color_doc  ,
"Set the terminal foreground color using one of the `F_*` constants.\n\n" "### Parameters\n\n" "- `color` (int): One of the `F_*` constants (e.g. `F_RED`).\n"   
)

◆ PyDoc_STRVAR() [21/24]

PyDoc_STRVAR ( py_SwappableField_add_pawn_to_swap_doc  ,
"add_pawn_to_swap(self, pawn: Pawn, coords: Capsule) -> None\n\n" "Schedule a pawn to be swapped to the given coordinates in the next swap operation.\n\n" "### Parameters\n\n" "- `pawn` (Pawn): Pawn object to schedule for swapping.\n" "- `coords` (Capsule): Capsule for the target Coordinates.\n\n" "### Raises\n\n" "- `IndexError`: destination is out of bounds.\n" "- `RuntimeError`: destination is occupied or another API error occurs.\n"   
)

◆ PyDoc_STRVAR() [22/24]

PyDoc_STRVAR ( py_SwappableField_apply_swaps_doc  ,
"apply_swaps(self) -> None\n\n" "Execute all scheduled pawn swaps in this SwappableField.\n\n" "### Raises\n\n" "- `RuntimeError`: if applying swaps fails.\n"   
)

◆ PyDoc_STRVAR() [23/24]

PyDoc_STRVAR ( py_SwappableField_create_pawn_doc  ,
"create_pawn(self, symbol: str, ansi_settings: Capsule, coords: Capsule) -> Pawn\n\n" "Create a Pawn inside this SwappableField and return a Pawn object.\n\n" "### Parameters\n\n" "- `symbol` (str): Single character string used to represent the pawn.\n" "- `ansi_settings` (Capsule): Capsule returned by create_ansi_settings().\n" "- `coords` (Capsule): Capsule returned by create_coordinates().\n\n" "### Returns\n\n" "- A `Pawn` object.\n"   
)

◆ PyDoc_STRVAR() [24/24]

PyDoc_STRVAR ( py_SwappableField_print_with_border_doc  ,
"print_with_border(self, border: Capsule) -> None\n\n" "Render this SwappableField to the terminal using the given Border object.\n\n" "### Parameters\n\n" "- `border` (Capsule): Capsule for the Border to draw around the field.\n"   
)

◆ PyInit__sista()

PyMODINIT_FUNC PyInit__sista ( void  )

Module initialization function.

Returns
The initialized module object.

This function is called when the module is imported in Python. It initializes the module and returns the module object.

◆ sista_module_exec()

static int sista_module_exec ( PyObject *  module)
static

◆ SwappableField_add_pawn_to_swap()

static PyObject * SwappableField_add_pawn_to_swap ( PyObject *  self,
PyObject *  args 
)
static

◆ SwappableField_apply_swaps()

static PyObject * SwappableField_apply_swaps ( PyObject *  self,
PyObject *  Py_UNUSEDignored 
)
static

◆ SwappableField_create_pawn()

static PyObject * SwappableField_create_pawn ( PyObject *  self,
PyObject *  args 
)
static

◆ SwappableField_dealloc()

static void SwappableField_dealloc ( PyObject *  self)
static

◆ SwappableField_init()

static int SwappableField_init ( PyObject *  self,
PyObject *  args,
PyObject *  kwds 
)
static

◆ SwappableField_print_with_border()

static PyObject * SwappableField_print_with_border ( PyObject *  self,
PyObject *  args 
)
static

Variable Documentation

◆ Cursor_methods

PyMethodDef Cursor_methods[]
static
Initial value:
= {
{"go_to", (PyCFunction)Cursor_go_to, METH_VARARGS, py_Cursor_go_to_doc},
{"go_to_coordinates", (PyCFunction)Cursor_go_to_coordinates, METH_VARARGS, py_Cursor_go_to_coordinates_doc},
{"move", (PyCFunction)Cursor_move, METH_VARARGS, py_Cursor_move_doc},
{NULL, NULL, 0, NULL}
}
static PyObject * Cursor_move(PyObject *self, PyObject *args)
Cursor.move(self, direction, amount)
Definition sistamodule.c:688
static PyObject * Cursor_go_to_coordinates(PyObject *self, PyObject *args)
Cursor.go_to_coordinates(self, coords_capsule)
Definition sistamodule.c:651
static PyObject * Cursor_go_to(PyObject *self, PyObject *args)
Cursor.go_to(self, y, x)
Definition sistamodule.c:622

◆ CursorType

static PyTypeObject CursorType
static
Initial value:
= {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "sista.Cursor",
.tp_basicsize = sizeof(CursorObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = py_doc_Cursor,
.tp_methods = Cursor_methods,
.tp_dealloc = (destructor)Cursor_dealloc,
.tp_new = PyType_GenericNew,
.tp_init = Cursor_init,
}
static void Cursor_dealloc(PyObject *self)
Definition sistamodule.c:604
static PyMethodDef Cursor_methods[]
Definition sistamodule.c:711
static int Cursor_init(PyObject *self, PyObject *args, PyObject *kwds)
Definition sistamodule.c:719
Definition sistamodule.c:526

◆ Field_methods

PyMethodDef Field_methods[]
static
Initial value:
= {
{"create_pawn", (PyCFunction)Field_create_pawn, METH_VARARGS, py_Field_create_pawn_doc},
{"move_pawn", (PyCFunction)Field_move_pawn, METH_VARARGS, py_Field_move_pawn_doc},
{"print_with_border", (PyCFunction)Field_print_with_border, METH_VARARGS, py_Field_print_with_border_doc},
{NULL, NULL, 0, NULL}
}
static PyObject * Field_create_pawn(PyObject *self, PyObject *args)
Definition sistamodule.c:981
static PyObject * Field_move_pawn(PyObject *self, PyObject *args)
Definition sistamodule.c:1030
static PyObject * Field_print_with_border(PyObject *self, PyObject *args)
Definition sistamodule.c:1063

◆ FieldType

static PyTypeObject FieldType
static
Initial value:
= {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "sista.Field",
.tp_basicsize = sizeof(FieldObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = py_doc_Field,
.tp_methods = Field_methods,
.tp_dealloc = (destructor)Field_dealloc,
.tp_new = PyType_GenericNew,
.tp_init = Field_init,
}
static void Field_dealloc(PyObject *self)
Definition sistamodule.c:969
static PyMethodDef Field_methods[]
Definition sistamodule.c:1093
static int Field_init(PyObject *self, PyObject *args, PyObject *kwds)
Initializes a Field object.
Definition sistamodule.c:1108
Definition sistamodule.c:960

◆ PawnType

static PyTypeObject PawnType
static
Initial value:
= {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "sista.Pawn",
.tp_basicsize = sizeof(PawnObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = py_doc_Pawn,
.tp_dealloc = (destructor)Pawn_dealloc,
.tp_new = PyType_GenericNew,
.tp_init = Pawn_init,
}
static void Pawn_dealloc(PyObject *self)
Definition sistamodule.c:543
static int Pawn_init(PyObject *self, PyObject *args, PyObject *kwds)
Definition sistamodule.c:553
Definition sistamodule.c:534

◆ sista_module

struct PyModuleDef sista_module
static
Initial value:
= {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "sista._sista",
.m_size = 0,
.m_methods = sista_module_methods,
.m_slots = sista_module_slots,
}
static PyModuleDef_Slot sista_module_slots[]
Definition sistamodule.c:1267
static PyMethodDef sista_module_methods[]
Definition sistamodule.c:1229

Module definition.

◆ sista_module_methods

PyMethodDef sista_module_methods[]
static

◆ sista_module_slots

PyModuleDef_Slot sista_module_slots[]
static
Initial value:
= {
{Py_mod_exec, (void*)sista_module_exec},
{0, NULL}
}
static int sista_module_exec(PyObject *module)
Definition sistamodule.c:1151

◆ SwappableField_methods

PyMethodDef SwappableField_methods[]
static
Initial value:
= {
{"create_pawn", (PyCFunction)SwappableField_create_pawn, METH_VARARGS, py_SwappableField_create_pawn_doc},
{"add_pawn_to_swap", (PyCFunction)SwappableField_add_pawn_to_swap, METH_VARARGS, py_SwappableField_add_pawn_to_swap_doc},
{"apply_swaps", (PyCFunction)SwappableField_apply_swaps, METH_NOARGS, py_SwappableField_apply_swaps_doc},
{"print_with_border", (PyCFunction)SwappableField_print_with_border, METH_VARARGS, py_SwappableField_print_with_border_doc},
{NULL, NULL, 0, NULL}
}
static PyObject * SwappableField_add_pawn_to_swap(PyObject *self, PyObject *args)
Definition sistamodule.c:817
static PyObject * SwappableField_print_with_border(PyObject *self, PyObject *args)
Definition sistamodule.c:875
static PyObject * SwappableField_create_pawn(PyObject *self, PyObject *args)
Definition sistamodule.c:768
static PyObject * SwappableField_apply_swaps(PyObject *self, PyObject *Py_UNUSED(ignored))
Definition sistamodule.c:860

◆ SwappableFieldType

static PyTypeObject SwappableFieldType
static
Initial value:
= {
PyVarObject_HEAD_INIT(NULL, 0)
.tp_name = "sista.SwappableField",
.tp_basicsize = sizeof(SwappableFieldObject),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_doc = py_doc_SwappableField,
.tp_methods = SwappableField_methods,
.tp_dealloc = (destructor)SwappableField_dealloc,
.tp_new = PyType_GenericNew,
.tp_init = SwappableField_init,
}
static PyMethodDef SwappableField_methods[]
Definition sistamodule.c:905
static int SwappableField_init(PyObject *self, PyObject *args, PyObject *kwds)
Definition sistamodule.c:914
static void SwappableField_dealloc(PyObject *self)
Definition sistamodule.c:756
Definition sistamodule.c:747