libtui
Loading...
Searching...
No Matches
Buffer

Files

file  libtui_buffer.h
 A readadble and writable 2D mapped buffer in the heap. WARNING: Internal, end user shouldn't use this.
 

Data Structures

struct  libtui_buffer
 A struct that represents a 2D buffer. WARNING: Internal struct, end user shouldn't use this. More...
 

Functions

struct libtui_bufferlibtui_buffer_create (size_t column, size_t row)
 Allocates and returns owned pointer to the struct libtui_buffer struct. WARNING: Internal function, end user shouldn't use this.
 
size_t libtui_buffer_get_index (const struct libtui_buffer *const buf, size_t x, size_t y)
 Gets x, y positions and maps them according to the buf which is 1-Dimensional. WARNING: Internal Funcion, end user shouldn't use this.
 
void libtui_buffer_set (struct libtui_buffer *const buf, const char c, size_t x, size_t y)
 Sets the char at a specific position. WARNING: Internal Funcion, end user shouldn't use this.
 
char libtui_buffer_get (const struct libtui_buffer *const buf, size_t x, size_t y)
 Gets the char at a specific location. WARNING: Internal Funcion, end user shouldn't use this.
 
void libtui_buffer_free (struct libtui_buffer *buf)
 Frees the struct libtui_buffer and the buffer inside it. WARNING: Internal Funcion, end user shouldn't use this.
 

Detailed Description

All the things aobut the libtui_buffer and the buffer module

Function Documentation

◆ libtui_buffer_create()

struct libtui_buffer * libtui_buffer_create ( size_t column,
size_t row )

Allocates and returns owned pointer to the struct libtui_buffer struct. WARNING: Internal function, end user shouldn't use this.

Returns
Returns an strcut libtui_buffer which the caller is responsible to free using void void libtui_buffer_free(struct libtui_buffer *buf). Will return NULL if malloc fails.
Parameters
columnThe amount of chars it stores in the X axis. Must be bigger than 0
rowThe amount of chars it stores in the Y axis. Must be bigger than 0

◆ libtui_buffer_free()

void libtui_buffer_free ( struct libtui_buffer * buf)

Frees the struct libtui_buffer and the buffer inside it. WARNING: Internal Funcion, end user shouldn't use this.

Must be called by the caller. Dont't use any pointers to the struct libtui_buffer neither the char* buf inside it.

Parameters
bufThe pointer to the struct libtui_buffer that was created with struct libtui_buffer *libtui_buffer_create(size_t column, size_t row). This function will neither modify the pointer or the struct.

◆ libtui_buffer_get()

char libtui_buffer_get ( const struct libtui_buffer *const buf,
size_t x,
size_t y )

Gets the char at a specific location. WARNING: Internal Funcion, end user shouldn't use this.

The origin is top-left.

Returns
Returns the char at given position. Will return '\0' in case of an error.
Parameters
bufThe pointer to the struct libtui_buffer that was created with struct libtui_buffer *libtui_buffer_create(size_t column, size_t row). This function will neither modify the pointer or the struct.
xThe x position of the wanted char.
yThe y position of the wanted char.

◆ libtui_buffer_get_index()

size_t libtui_buffer_get_index ( const struct libtui_buffer *const buf,
size_t x,
size_t y )

Gets x, y positions and maps them according to the buf which is 1-Dimensional. WARNING: Internal Funcion, end user shouldn't use this.

Returns
Returns the corresponding index in 1-Dimensional buffer. Returns 0 (origin) when something goes bad.
Parameters
bufThe pointer to the struct libtui_buffer that was created with struct libtui_buffer *libtui_buffer_create(size_t column, size_t row). This function will neither modify the pointer or the struct.
xThe x position of the wanted char.
yThe y position of the wanted char.

◆ libtui_buffer_set()

void libtui_buffer_set ( struct libtui_buffer *const buf,
const char c,
size_t x,
size_t y )

Sets the char at a specific position. WARNING: Internal Funcion, end user shouldn't use this.

The origin is top-left.

Parameters
bufThe pointer to the struct libtui_buffer that was created with struct libtui_buffer *libtui_buffer_create(size_t column, size_t row). This function will modify the struct passed but it won't modify the pointer.
cThe char value, the char at the given position will be setted.
xThe x position of the char that should be setted.
yThe y position of the char that should be setted.