ncplane_reparent: promote child planes #1078

pull/1136/head
nick black 4 years ago committed by Nick Black
parent 0485c6f35d
commit 9e460ca1c2

@ -301,7 +301,6 @@ typedef struct ncdirect {
typedef struct ncpile {
ncplane* top; // topmost plane, never NULL
ncplane* bottom; // bottommost plane, never NULL
ncplane* root; // first plane of the root set
struct notcurses* nc; // notcurses context
struct ncpile *prev, *next; // circular list
} ncpile;

@ -303,7 +303,6 @@ make_ncpile(notcurses* nc){
ret->nc = nc;
ret->top = NULL;
ret->bottom = NULL;
ret->root = NULL;
if(nc->stdplane){
ret->prev = ncplane_pile(nc->stdplane)->prev;
ncplane_pile(nc->stdplane)->prev->next = ret;
@ -2160,7 +2159,20 @@ ncplane* ncplane_reparent(ncplane* n, ncplane* newparent){
if(n->boundto == n && newparent == NULL){
return NULL; // can't make new stack out of a stack's root
}
// FIXME take blist, add it to boundto
if(n->boundto == n){ // children become new root planes
for(ncplane* child = n->blist ; child ; child = child->bnext){
child->boundto = child;
}
}else{
if(n->blist){
if( (n->blist->bnext = n->boundto->blist) ){
n->boundto->blist->bprev = &n->blist->bnext;
}
n->blist->bprev = &n->boundto->blist;
n->boundto->blist = n->blist;
n->blist = NULL;
}
}
return ncplane_reparent_family(n, newparent);
}
@ -2186,6 +2198,8 @@ ncplane* ncplane_reparent_family(ncplane* n, ncplane* newparent){
if(newparent == NULL){
n->bnext = NULL;
n->bprev = NULL;
n->boundto = n;
// FIXME need new pile
return n;
}
if( (n->bnext = newparent->blist) ){

Loading…
Cancel
Save