More docs and rename a function

This commit is contained in:
Heath Mitchell 2023-01-29 14:14:05 +00:00
parent d4c55b8e0f
commit 58fa6d7049
4 changed files with 33 additions and 12 deletions

View File

@ -67,6 +67,16 @@ void TeX_flow_free(struct TeX_Flow *flow);
characters and subscripts/superscripts. Modifies the flow's metadata. */
void TeX_flow_layout(struct TeX_Flow *flow, int display);
/* 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, struct editContext * context, int x, int y, int color);
//---
// Cursor and editing
//---
/* TeX_flow_cursor_action(): Perform a cursor action on a flow
This function performs a cursor action on a flow, like moving left or right.
This is recursive, and should usually be called on the top-level flow.
@ -75,9 +85,4 @@ void TeX_flow_layout(struct TeX_Flow *flow, int display);
Returns a cursorMoveResult enum; see edit.h for details of the return value. */
enum cursorMoveResult TeX_flow_cursor_action(struct TeX_Flow * flow, struct editContext * context, enum cursorAction action);
/* 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, struct editContext * context, int x, int y, int color);
#endif /* TEX_FLOW */

View File

@ -101,7 +101,23 @@ void TeX_node_layout(struct TeX_Node *node, int display);
The node's layout must have been computed first. */
void TeX_node_render(struct TeX_Node const * node, struct editContext * context, int x, int y, int color);
enum cursorMoveResult move_cursor_node(struct TeX_Node *node, struct editContext * context, enum cursorAction action);
enum cursorMoveResult cursor_enter_node(struct TeX_Node *node, struct editContext * context, enum cursorAction action);
//---
// Cursor and editing
//---
/* TeX_flow_cursor_action(): Perform a cursor action on a flow
See TeX_flow_cursor_action in flow.h for more information.
If this node contains flows, this will propagate the action to them,
and nagivate between them. by updating the cursor context. */
enum cursorMoveResult TeX_node_cursor_action(struct TeX_Node *node, struct editContext * context, enum cursorAction action);
/* TeX_node_cursor_enter(): Enter a node
This function is called when the cursor navigates into a node.
If the node is just a simple symbol or character, this will return
CURSOR_PAST_END/START, and the parent flow will skip over the node.
If the node contains flows that can be navigated into, this will usually
nagivate into the first/last flow depending on the direction that the
cursor enters from, and return SUCCESS. */
enum cursorMoveResult TeX_node_cursor_enter(struct TeX_Node *node, struct editContext * context, enum cursorAction action);
#endif /* TEX_NODE */

View File

@ -393,7 +393,7 @@ enum cursorMoveResult TeX_flow_cursor_action(struct TeX_Flow * flow, struct edit
int offset = 0;
while (node != NULL)
{
int returnCode = move_cursor_node(node, context, action);
int returnCode = TeX_node_cursor_action(node, context, action);
if (returnCode == SUCCESS)
{
@ -445,7 +445,7 @@ enum cursorMoveResult TeX_flow_cursor_action(struct TeX_Flow * flow, struct edit
{
node = node->next;
}
int returncode = cursor_enter_node(node, context, action);
int returncode = TeX_node_cursor_enter(node, context, action);
if (returncode == CURSOR_PAST_START)
{
// Put the cursor in this flow before the node
@ -469,7 +469,7 @@ enum cursorMoveResult TeX_flow_cursor_action(struct TeX_Flow * flow, struct edit
{
node = node->next;
}
int returncode = cursor_enter_node(node, context, action);
int returncode = TeX_node_cursor_enter(node, context, action);
if (returncode == CURSOR_PAST_END)
{
context->offset++;

View File

@ -18,7 +18,7 @@
((node)->type == TEX_NODECLASS_TEXT || \
(node)->type == TEX_NODECLASS_ENV)
enum cursorMoveResult move_cursor_node(struct TeX_Node *node, struct editContext * context, enum cursorAction action)
enum cursorMoveResult TeX_node_cursor_action(struct TeX_Node *node, struct editContext * context, enum cursorAction action)
{
if (node->type == 0)
{
@ -82,7 +82,7 @@ enum cursorMoveResult move_cursor_node(struct TeX_Node *node, struct editContext
return CURSOR_NOT_HERE;
}
enum cursorMoveResult cursor_enter_node(struct TeX_Node *node, struct editContext * context, enum cursorAction action)
enum cursorMoveResult TeX_node_cursor_enter(struct TeX_Node *node, struct editContext * context, enum cursorAction action)
{
enum cursorMoveResult skipPast = action == CURSOR_MOVE_RIGHT ? CURSOR_PAST_END : CURSOR_PAST_START;