add term_dims() func

This commit is contained in:
Emile Clark-Boman 2025-09-11 19:26:28 +10:00
parent f73dbd7d8a
commit 79f5c5235a

View file

@ -87,6 +87,13 @@ static struct crs_nodedims *get_dims(const struct crs_node *node) {
return dims;
}
struct crs_nodedims term_dims(void) {
struct crs_nodedims dims;
getbegyx(stdscr, dims.y, dims.x);
getmaxyx(stdscr, dims.height, dims.width);
return dims;
}
/* Calculate the dimensions for nodes resulting from a bifurcation.
* Returns 0 on success, and 1 on failure if any width/height are 0 characters.
* WARNING: This function does not guarantee the x,y positions returned
@ -162,7 +169,6 @@ void bifurcate_window_node(struct crs_node **node,
struct crs_nodedims *dims0, *dims1;
struct crs_node *node0, *node1;
if (bifurcate_dims(*node, axis, ratio, &dims0, &dims1)) {
printf("FAILED TERRIBLY THE FUCK\n");
exit(1);
@ -202,7 +208,15 @@ static void collapse_abstract_node(struct crs_node **node,
/*
*/
static struct crs_node *init_root_node(void) {
return init_window_node(root_window());
struct crs_nodedims rootdims;
WINDOW *rootwin;
// rootdims = term_dims();
// rootwin = new_window(rootdims.x, rootdims.y,
// rootdims.height, rootdims.height);
// rootwin = new_window(0, 0, 0, 0);
rootwin = root_window();
return init_window_node(rootwin);
}
int init_tree(struct crs_tree **const tree) {