(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.
This commit is contained in:
Emile Clark-Boman 2025-09-13 23:45:56 +10:00
parent b04f0b4aa3
commit 759920a9cc
9 changed files with 476 additions and 193 deletions

View file

@ -5,22 +5,19 @@
/*
*/
static struct ct_node *init_root_node(void) {
WINDOW *rootwin;
rootwin = new_window_fs();
return init_window_node(rootwin);
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 = init_root_node();
return EXIT_SUCCESS;
*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);
endwin();
end_ncurses();
free(tree);
}
@ -28,3 +25,14 @@ 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);
}