mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
nctree: free items pushed below screen #1164
This commit is contained in:
parent
3f66cb0ff7
commit
ac9059e0ac
@ -287,7 +287,7 @@ draw_tree_item(nctree* n, nctree_int_item* nii, const unsigned* path,
|
||||
ymin = 0;
|
||||
ymax = *frontiert;
|
||||
}
|
||||
fprintf(stderr, "x: %d y: %d\n", startx, ymin);
|
||||
//fprintf(stderr, "x: %d y: %d\n", startx, ymin);
|
||||
struct ncplane_options nopts = {
|
||||
.x = startx,
|
||||
.y = ymin,
|
||||
@ -303,7 +303,6 @@ fprintf(stderr, "x: %d y: %d\n", startx, ymin);
|
||||
return -1;
|
||||
}
|
||||
}else{
|
||||
// FIXME is frontiert always the place to be?
|
||||
// FIXME possibly enlarge nii->ncp?
|
||||
}
|
||||
if(ncplane_y(nii->ncp) <= *frontiert || *frontierb >= ncplane_dim_y(n->items.ncp)){
|
||||
@ -316,7 +315,7 @@ fprintf(stderr, "x: %d y: %d\n", startx, ymin);
|
||||
return -1;
|
||||
}
|
||||
// FIXME shrink plane if it was enlarged
|
||||
fprintf(stderr, "ft: %d fb: %d %p ncplane_y: %d\n", *frontiert, *frontierb, nii->ncp, ncplane_y(nii->ncp));
|
||||
//fprintf(stderr, "ft: %d fb: %d %p ncplane_y: %d\n", *frontiert, *frontierb, nii->ncp, ncplane_y(nii->ncp));
|
||||
if(ncplane_y(nii->ncp) <= *frontiert){
|
||||
*frontiert = ncplane_y(nii->ncp) - 1;
|
||||
}
|
||||
@ -336,7 +335,24 @@ destroy_above(nctree* n, nctree_int_item* nii, unsigned* path, int distance){
|
||||
nii = tmpnii;
|
||||
--distance;
|
||||
if(nii->ncp){
|
||||
fprintf(stderr, "PREVDESTROY: %s\n", (const char*)nii->curry);
|
||||
ncplane_destroy(nii->ncp);
|
||||
nii->ncp = NULL;
|
||||
n->cbfxn(nii->ncp, nii->curry, distance);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// iterate forwards from tmppath, destroying any ncplanes we find. they've
|
||||
// been pushed off-screen. tmppath is changed as we iterate. nii will not be
|
||||
// destroyed, only items below nii.
|
||||
static int
|
||||
destroy_below(nctree* n, nctree_int_item* nii, unsigned* path, int distance){
|
||||
nctree_int_item* tmpnii;
|
||||
while((tmpnii = nctree_next_internal(n, path)) != nii){
|
||||
nii = tmpnii;
|
||||
++distance;
|
||||
if(nii->ncp){
|
||||
ncplane_destroy(nii->ncp);
|
||||
nii->ncp = NULL;
|
||||
n->cbfxn(nii->ncp, nii->curry, distance);
|
||||
@ -357,14 +373,12 @@ nctree_inner_redraw(nctree* n, unsigned* tmppath){
|
||||
int frontierb = n->activerow;
|
||||
nctree_int_item* nii = n->curitem;
|
||||
int distance = 0;
|
||||
fprintf(stderr, "FOCUSED: %s\n", (const char*)nii->curry);
|
||||
// draw the focused item
|
||||
if(draw_tree_item(n, nii, tmppath, &frontiert, &frontierb, distance)){
|
||||
return -1;
|
||||
}
|
||||
nctree_int_item* tmpnii;
|
||||
// draw items above the current one
|
||||
fprintf(stderr, "FRONTIERT: %d\n", frontiert);
|
||||
while(frontiert >= 0){
|
||||
if((tmpnii = nctree_prev_internal(n, tmppath)) == nii){
|
||||
break;
|
||||
@ -374,7 +388,6 @@ fprintf(stderr, "FRONTIERT: %d\n", frontiert);
|
||||
if(draw_tree_item(n, nii, tmppath, &frontiert, &frontierb, distance)){
|
||||
return -1;
|
||||
}
|
||||
fprintf(stderr, "PREV: %s\n", (const char*)nii->curry);
|
||||
}
|
||||
destroy_above(n, nii, tmppath, distance);
|
||||
// move items up if there is a gap at the top FIXME
|
||||
@ -395,7 +408,7 @@ fprintf(stderr, "PREV: %s\n", (const char*)nii->curry);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// FIXME destroy any drawn ones after us
|
||||
destroy_below(n, nii, tmppath, distance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user