ncplane_dup(): adjust for marginalia #679

This commit is contained in:
nick black 2020-06-05 01:30:29 -04:00
parent e268301a42
commit b72a386aa3
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,7 @@ rearrangements of Notcurses.
and `ncplane_blit_bgrx()`, to match every other existing ncplane function.
In addition, they both now accept an `ncblitter_e` to select the blitting
method. `NCBLIT_DEFAULT` will use `NCBLITTER_2x1`.
* Added `ncplane_notcurses_const()`.
* 1.4.4.1 (2020-06-01)
* Got the `ncvisual` API ready for API freeze: `ncvisual_render()` and

View File

@ -931,6 +931,7 @@ API int notcurses_mouse_disable(struct notcurses* n);
API int notcurses_refresh(struct notcurses* n, int* RESTRICT y, int* RESTRICT x);
API struct notcurses* ncplane_notcurses(struct ncplane* n);
API const struct notcurses* ncplane_notcurses_const(const struct ncplane* n);
// Return the dimensions of this ncplane.
API void ncplane_dim_yx(const struct ncplane* n, int* RESTRICT y, int* RESTRICT x);

View File

@ -82,7 +82,7 @@ rotate_visual(struct notcurses* nc, struct ncplane* n, int dy, int dx){
failed = true;
break;
}
if(notcurses_render(nc)){
if(demo_render(nc)){
failed = true;
break;
}

View File

@ -370,7 +370,11 @@ ncplane* ncplane_dup(const ncplane* n, void* opaque){
int dimx = n->lenx;
uint32_t attr = ncplane_attr(n);
uint64_t chan = ncplane_channels(n);
ncplane* newn = ncplane_create(n->nc, n->boundto, dimy, dimx, n->absy, n->absx, opaque);
// if we're duping the standard plane, we need adjust for marginalia
const struct notcurses* nc = ncplane_notcurses_const(n);
const int placey = n->absy - nc->margin_t;
const int placex = n->absx - nc->margin_l;
ncplane* newn = ncplane_create(n->nc, n->boundto, dimy, dimx, placey, placex, opaque);
if(newn){
if(egcpool_dup(&newn->pool, &n->pool)){
ncplane_destroy(newn);
@ -1842,6 +1846,10 @@ notcurses* ncplane_notcurses(ncplane* n){
return n->nc;
}
const notcurses* ncplane_notcurses_const(const ncplane* n){
return n->nc;
}
ncplane* ncplane_reparent(ncplane* n, ncplane* newparent){
if(n == n->nc->stdscr){
return NULL; // can't reparent standard plane