dorne/cursetree/tree.c
Emile Clark-Boman 759920a9cc (UNDER CONSTRUCTION) cursetree is now a non-binary tree yippiegit add .
also abstracted ncurses WINDOW into the ct_surface structure. and added ct_bounds to complement ct_dims.
2025-09-13 23:45:56 +10:00

38 lines
903 B
C

#include <stdlib.h>
#include "ncrswrap.h"
#include "tree.h"
/*
*/
static inline struct ct_node *__root_node(void) {
return new_node(termdims(), NULL);
}
int init_tree(struct ct_tree **const tree) {
*tree = (struct ct_tree *)malloc(sizeof(struct ct_tree));
(*tree)->root = __root_node();
return EXIT_SUCCESS;
}
void destroy_tree(struct ct_tree *const tree) {
destroy_node(tree->root);
end_ncurses();
free(tree);
}
void resize_tree(struct ct_tree *const tree, struct ct_dims *const dims) {
resize_node(tree->root, dims);
}
void switch_nodes(struct ct_node **const node0, struct ct_node **const node1) {
struct ct_node *const node0ptr = *node0;
struct ct_dims *const node0dims = dup_dims((*node0)->dims);
struct ct_dims *const node1dims = dup_dims((*node1)->dims);
*node0 = *node1;
resize_node(*node0, node1dims);
*node1 = node0ptr;
resize_node(*node1, node0dims);
}