core: deprecate ncplane_new() #1115

pull/1128/head
nick black 4 years ago committed by Nick Black
parent a9fbe41f2b
commit a3d9f78612

@ -487,7 +487,15 @@ rotate_plane(ncplane* n){
}
const int newy = dimx / 2;
const int newx = dimy * 2;
ncplane* newp = ncplane_new(n, newy, newx, absy, absx, n->userptr, "copy");
struct ncplane_options nopts = {
.y = absy,
.horiz.x = absx,
.rows = newy,
.cols = newx,
.userptr = n->userptr,
.name = "copy",
};
ncplane* newp = ncplane_create(n, &nopts);
return newp;
}

@ -321,8 +321,14 @@ ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){
if(totalwidth < dimx){
totalwidth = dimx;
}
int ypos = ret->bottom ? dimy - totalheight : 0;
ret->ncp = ncplane_new(n, totalheight, totalwidth, ypos, 0, NULL, "menu");
struct ncplane_options nopts = {
.y = ret->bottom ? dimy - totalheight : 0,
.horiz.x = 0,
.rows = totalheight,
.cols = totalwidth,
.name = "menu",
};
ret->ncp = ncplane_create(n, &nopts);
if(ret->ncp){
ret->unrolledsection = -1;
ret->headerchannels = opts->headerchannels;

@ -457,8 +457,15 @@ ncplane* ncplane_dup(const ncplane* n, void* opaque){
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_new(n->boundto, dimy, dimx,
placey, placex, opaque, n->name);
struct ncplane_options nopts = {
.y = placey,
.horiz.x = placex,
.rows = dimy,
.cols = dimx,
.userptr = opaque,
.name = n->name,
};
ncplane* newn = ncplane_create(n->boundto, &nopts);
if(newn){
if(egcpool_dup(&newn->pool, &n->pool)){
ncplane_destroy(newn);

@ -16,9 +16,14 @@ ncreader* ncreader_create(ncplane* n, const ncreader_options* opts){
nr->ncp = n;
// do *not* bind it to the visible plane; we always want it offscreen,
// to the upper left of the true origin
if((nr->textarea = ncplane_new(notcurses_stdplane(ncplane_notcurses(n)),
ncplane_dim_y(n), ncplane_dim_x(n),
-ncplane_dim_y(n), -ncplane_dim_x(n), NULL, "text")) == NULL){
struct ncplane_options nopts = {
.y = -ncplane_dim_y(n),
.horiz.x = -ncplane_dim_x(n),
.rows = ncplane_dim_y(n),
.cols = ncplane_dim_x(n),
.name = "text",
};
if((nr->textarea = ncplane_create(notcurses_stdplane(ncplane_notcurses(n)), &nopts)) == NULL){
ncplane_destroy(nr->ncp);
free(nr);
return NULL;

@ -258,7 +258,14 @@ ncreel_draw_tablet(const ncreel* nr, nctablet* t, int frontiertop,
return -1;
}
//fprintf(stderr, "p tplacement: %p base %d/%d len %d/%d frontiery %d %d dir %d\n", t, begy, begx, leny, lenx, frontiertop, frontierbottom, direction);
ncplane* fp = ncplane_new(nr->p, leny, lenx, begy, begx, NULL, "tab");
struct ncplane_options nopts = {
.y = begy,
.horiz.x = begx,
.rows = leny,
.cols = lenx,
.name = "tab",
};
ncplane* fp = ncplane_create(nr->p, &nopts);
if((t->p = fp) == NULL){
//fprintf(stderr, "failure creating border plane %d %d %d %d\n", leny, lenx, begy, begx);
return -1;
@ -278,7 +285,14 @@ ncreel_draw_tablet(const ncreel* nr, nctablet* t, int frontiertop,
}
if(cbleny - cby + 1 > 0){
//fprintf(stderr, "cbp placement %dx%d @ %dx%d\n", cbleny, cblenx, cby, cbx);
t->cbp = ncplane_new(t->p, cbleny, cblenx, cby, cbx, NULL, "tdat");
struct ncplane_options dnopts = {
.y = cby,
.horiz.x = cbx,
.rows = cbleny,
.cols = cblenx,
.name = "tdat",
};
t->cbp = ncplane_create(t->p, &dnopts);
if(t->cbp == NULL){
//fprintf(stderr, "failure creating data plane %d %d %d %d\n", cbleny, cblenx, cby, cbx);
ncplane_destroy(t->p);

@ -418,9 +418,16 @@ auto ncvisual_render(notcurses* nc, ncvisual* ncv,
}
}
//fprintf(stderr, "PLACING NEW PLANE: %d/%d @ %d/%d\n", disprows, dispcols, placey, placex);
n = ncplane_new(notcurses_stdplane(nc), disprows / encoding_y_scale(bset),
dispcols / encoding_x_scale(bset), placey, placex, nullptr, "vis");
if(n == nullptr){
struct ncplane_options nopts = {
.y = placey,
.horiz = {
.x = placex,
},
.rows = disprows / encoding_y_scale(bset),
.cols = dispcols / encoding_x_scale(bset),
.name = "vis",
};
if((n = ncplane_create(notcurses_stdplane(nc), &nopts)) == nullptr){
return nullptr;
}
placey = 0;

Loading…
Cancel
Save