38 lines
936 B
C
38 lines
936 B
C
#include <stdlib.h>
|
|
|
|
#include "ncrswrap.h"
|
|
#include "tree.h"
|
|
|
|
/*
|
|
*/
|
|
static inline struct ct_node *__root_node(void) {
|
|
return new_node(termdims(), bounds_none(), 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)->surface->dims);
|
|
struct ct_dims *const node1dims = dup_dims((*node1)->surface->dims);
|
|
|
|
*node0 = *node1;
|
|
resize_node(*node0, node1dims);
|
|
|
|
*node1 = node0ptr;
|
|
resize_node(*node1, node0dims);
|
|
}
|