ncplane_create()

pull/63/head
nick black 5 years ago
parent 9a41257669
commit 71a127463a
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -11,7 +11,7 @@ int widecolor_demo(struct notcurses* nc){
"Война и мир",
"Бра́тья Карама́зовы",
"Час сэканд-хэнд",
"ஸீரோ டிகிரி",
//"ஸீரோ டிகிரி",
"Tonio Kröger",
/*"بين القصرين",
"قصر الشوق",
@ -259,7 +259,7 @@ int widecolor_demo(struct notcurses* nc){
}
}while(y < maxy && x < maxx);
ncplane_fg_rgb8(n, 255, 255, 255);
// ncplane_set_style(n, WA_BOLD);
ncplane_set_style(n, WA_BOLD);
ncplane_cursor_move_yx(n, 2, 2);
ncplane_printf(n, " %dx%d (%d/%d) ", maxx, maxy, i, sizeof(steps) / sizeof(*steps));
ncplane_cursor_move_yx(n, 3, 2);

@ -42,6 +42,7 @@ typedef struct ncplane {
egcpool pool; // attached storage pool for UTF-8 EGCs
uint64_t channels; // works the same way as cells
uint32_t attrword; // same deal as in a cell
void* userptr; // slot for the user to stick some opaque pointer
} ncplane;
typedef struct ncstats {
@ -253,14 +254,8 @@ term_emit(const char* seq, FILE* out, bool flush){
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*
create_initial_ncplane(notcurses* nc){
int rows, cols;
if(update_term_dimensions(nc, &rows, &cols)){
return NULL;
}
ncplane_create(notcurses* nc, int rows, int cols){
ncplane* p = malloc(sizeof(*p));
size_t fbsize = sizeof(*p->fb) * (rows * cols);
if((p->fb = malloc(fbsize)) == NULL){
@ -278,6 +273,17 @@ create_initial_ncplane(notcurses* nc){
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
// 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
@ -327,6 +333,21 @@ const ncplane* notcurses_stdplane_const(const notcurses* nc){
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){
if(ncp){
if(nc->stdscr == ncp){

Loading…
Cancel
Save