58 lines
1.7 KiB
C
58 lines
1.7 KiB
C
//---
|
|
// flow: Horizontal flows of nodes arranged from left to right
|
|
//---
|
|
|
|
#ifndef TEX_FLOW
|
|
#define TEX_FLOW
|
|
|
|
#include <stdint.h>
|
|
|
|
struct TeX_Node;
|
|
|
|
/* TeX_Flow
|
|
This object represents a horizontal line of nodes following the flow of the
|
|
text; each node can be a plain string or a functional node. All share the
|
|
same base line when rendered. */
|
|
struct TeX_Flow
|
|
{
|
|
/* Pointer to first and last elements of the line */
|
|
struct TeX_Node *first;
|
|
struct TeX_Node *last;
|
|
|
|
uint16_t width;
|
|
uint16_t height;
|
|
uint16_t line;
|
|
|
|
} __attribute__((packed, aligned(sizeof (void *))));
|
|
|
|
//---
|
|
// Flow construction and destruction functions
|
|
//---
|
|
|
|
/* TeX_flow_add_node(): Add a new node to a flow
|
|
The provided node is added at the right of the flow. If [flow] is NULL,
|
|
creates and returns a new flow. Otherwise, always returns [flow]. */
|
|
struct TeX_Flow *TeX_flow_add_node(struct TeX_Flow *flow,
|
|
struct TeX_Node *node);
|
|
|
|
/* TeX_flow_free(): Free TeX_Flow objects
|
|
Destroys a flow and all of its contained elements. */
|
|
void TeX_flow_free(struct TeX_Flow *flow);
|
|
|
|
//---
|
|
// Layout and rendering
|
|
//---
|
|
|
|
/* TeX_flow_layout(): Calculate the layout of a flow
|
|
This function calculates the size taken by nodes sharing the same baseline.
|
|
It heeds for special size and alignment exceptions such as parenthesis-type
|
|
characters and subscripts/superscripts. Modifies the flow's metadata. */
|
|
void TeX_flow_layout(struct TeX_Flow *flow);
|
|
|
|
/* TeX_flow_render(): Render a flow and all its components
|
|
This function renders all horizontal objects in a flow. The layout of the
|
|
flow must have been computed. */
|
|
void TeX_flow_render(struct TeX_Flow const * flow, int x, int y, int color);
|
|
|
|
#endif /* TEX_FLOW */
|