|
|
@ -42,6 +42,7 @@ typedef struct ncplane {
|
|
|
|
egcpool pool; // attached storage pool for UTF-8 EGCs
|
|
|
|
egcpool pool; // attached storage pool for UTF-8 EGCs
|
|
|
|
uint64_t channels; // works the same way as cells
|
|
|
|
uint64_t channels; // works the same way as cells
|
|
|
|
uint32_t attrword; // same deal as in a cell
|
|
|
|
uint32_t attrword; // same deal as in a cell
|
|
|
|
|
|
|
|
void* userptr; // slot for the user to stick some opaque pointer
|
|
|
|
} ncplane;
|
|
|
|
} ncplane;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct ncstats {
|
|
|
|
typedef struct ncstats {
|
|
|
@ -253,14 +254,8 @@ term_emit(const char* seq, FILE* out, bool flush){
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// create an ncplane of the specified dimensions, but do not yet place it in
|
|
|
|
|
|
|
|
// the z-buffer. clear out all cells. this is for a wholly new context.
|
|
|
|
|
|
|
|
static ncplane*
|
|
|
|
static ncplane*
|
|
|
|
create_initial_ncplane(notcurses* nc){
|
|
|
|
ncplane_create(notcurses* nc, int rows, int cols){
|
|
|
|
int rows, cols;
|
|
|
|
|
|
|
|
if(update_term_dimensions(nc, &rows, &cols)){
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ncplane* p = malloc(sizeof(*p));
|
|
|
|
ncplane* p = malloc(sizeof(*p));
|
|
|
|
size_t fbsize = sizeof(*p->fb) * (rows * cols);
|
|
|
|
size_t fbsize = sizeof(*p->fb) * (rows * cols);
|
|
|
|
if((p->fb = malloc(fbsize)) == NULL){
|
|
|
|
if((p->fb = malloc(fbsize)) == NULL){
|
|
|
@ -278,6 +273,17 @@ create_initial_ncplane(notcurses* nc){
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create an ncplane of the specified dimensions, but do not yet place it in
|
|
|
|
|
|
|
|
// the z-buffer. clear out all cells. this is for a wholly new context.
|
|
|
|
|
|
|
|
static ncplane*
|
|
|
|
|
|
|
|
create_initial_ncplane(notcurses* nc){
|
|
|
|
|
|
|
|
int rows, cols;
|
|
|
|
|
|
|
|
if(update_term_dimensions(nc, &rows, &cols)){
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ncplane_create(nc, rows, cols);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Call this when the screen size changes. Takes a flat
|
|
|
|
// Call this when the screen size changes. Takes a flat
|
|
|
|
// array of *rows * *cols cells (may be NULL if *rows == *cols == 0). Gets the
|
|
|
|
// array of *rows * *cols cells (may be NULL if *rows == *cols == 0). Gets the
|
|
|
|
// new size, and copies what can be copied from the old stdscr. Assumes that
|
|
|
|
// new size, and copies what can be copied from the old stdscr. Assumes that
|
|
|
@ -327,6 +333,21 @@ const ncplane* notcurses_stdplane_const(const notcurses* nc){
|
|
|
|
return nc->stdscr;
|
|
|
|
return nc->stdscr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ncplane* notcurses_newplane(notcurses* nc, int rows, int cols,
|
|
|
|
|
|
|
|
int yoff, int xoff, void* opaque){
|
|
|
|
|
|
|
|
if(rows <= 0 || cols <= 0){
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ncplane* n = create_initial_ncplane(nc);
|
|
|
|
|
|
|
|
if(n == NULL){
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
n->absx = xoff;
|
|
|
|
|
|
|
|
n->absy = yoff;
|
|
|
|
|
|
|
|
n->userptr = opaque;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ncplane_destroy(notcurses* nc, ncplane* ncp){
|
|
|
|
int ncplane_destroy(notcurses* nc, ncplane* ncp){
|
|
|
|
if(ncp){
|
|
|
|
if(ncp){
|
|
|
|
if(nc->stdscr == ncp){
|
|
|
|
if(nc->stdscr == ncp){
|
|
|
|