diff --git a/include/notcurses.h b/include/notcurses.h index 55c0814e9..c6bd96728 100644 --- a/include/notcurses.h +++ b/include/notcurses.h @@ -387,13 +387,14 @@ API int ncplane_resize(struct ncplane* n, int keepy, int keepx, int keepleny, // the standard plane. API int ncplane_destroy(struct ncplane* ncp); -// Set the ncplane's default cell to this cell. If defined, it will be rendered +// Set the ncplane's base cell to this cell. If defined, it will be rendered // anywhere that the ncplane's gcluster is 0. Erasing the ncplane does not -// reset the default cell; this function must instead be called with a zero c. -API int ncplane_set_default(struct ncplane* ncp, const cell* c); +// reset the base cell; this function must instead be called with a zero c. +API int ncplane_set_base(struct ncplane* ncp, const cell* c); -// Extract the ncplane's default cell into 'c'. -API int ncplane_default(struct ncplane* ncp, cell* c); +// Extract the ncplane's base cell into 'c'. The reference is invalidated if +// 'ncp' is destroyed. +API int ncplane_base(struct ncplane* ncp, cell* c); // Move this plane relative to the standard plane. It is an error to attempt to // move the standard plane. @@ -736,7 +737,7 @@ ncplane_box_sized(struct ncplane* n, const cell* ul, const cell* ur, // Erase every cell in the ncplane, resetting all attributes to normal, all // colors to the default color, and all cells to undrawn. All cells associated // with this ncplane is invalidated, and must not be used after the call, -// excluding the default cell. +// excluding the base cell. API void ncplane_erase(struct ncplane* n); #define CELL_WIDEASIAN_MASK 0x8000000080000000ull diff --git a/src/demo/boxdemo.c b/src/demo/boxdemo.c index af1a40ae9..c27230a7c 100644 --- a/src/demo/boxdemo.c +++ b/src/demo/boxdemo.c @@ -28,7 +28,7 @@ int box_demo(struct notcurses* nc){ int ytargbase = (ylen - targy) / 2; cell c = CELL_SIMPLE_INITIALIZER(' '); cell_set_bg_default(&c); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); cell_release(n, &c); ncplane_set_fg_rgb(n, 180, 40, 180); ncplane_set_bg_default(n); diff --git a/src/demo/demo.c b/src/demo/demo.c index 0b10659e1..89698f244 100644 --- a/src/demo/demo.c +++ b/src/demo/demo.c @@ -99,7 +99,7 @@ intro(struct notcurses* nc){ } cell c = CELL_TRIVIAL_INITIALIZER; cell_set_bg_rgb(&c, 0x20, 0x20, 0x20); - ncplane_set_default(ncp, &c); + ncplane_set_base(ncp, &c); if(ncplane_cursor_move_yx(ncp, 0, 0)){ return -1; } diff --git a/src/demo/eagle.c b/src/demo/eagle.c index 8dd21353e..7faa6c650 100644 --- a/src/demo/eagle.c +++ b/src/demo/eagle.c @@ -116,7 +116,7 @@ draw_eagle(struct ncplane* n, const char* sprite){ cell bgc = CELL_TRIVIAL_INITIALIZER; cell_set_fg_alpha(&bgc, CELL_ALPHA_TRANSPARENT); cell_set_bg_alpha(&bgc, CELL_ALPHA_TRANSPARENT); - ncplane_set_default(n, &bgc); + ncplane_set_base(n, &bgc); cell_release(n, &bgc); size_t s; int sbytes; diff --git a/src/demo/hud.c b/src/demo/hud.c index 40110face..526485f80 100644 --- a/src/demo/hud.c +++ b/src/demo/hud.c @@ -39,7 +39,7 @@ hud_standard_bg(struct ncplane* n){ cell c = CELL_SIMPLE_INITIALIZER(' '); cell_set_bg_rgb(&c, 0xc0, 0xf0, 0xc0); cell_set_bg_alpha(&c, CELL_ALPHA_BLEND); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); cell_release(n, &c); return 0; } @@ -48,7 +48,7 @@ static int hud_grabbed_bg(struct ncplane* n){ cell c = CELL_SIMPLE_INITIALIZER(' '); cell_set_bg_rgb(&c, 0x40, 0x90, 0x40); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); cell_release(n, &c); return 0; } @@ -133,7 +133,7 @@ int hud_schedule(const char* demoname){ return -1; } cell c = CELL_TRIVIAL_INITIALIZER; - ncplane_default(hud, &c); + ncplane_base(hud, &c); ncplane_set_bg(hud, cell_get_bg(&c)); ncplane_set_bg_alpha(hud, CELL_ALPHA_BLEND); ncplane_set_fg(hud, 0); diff --git a/src/demo/luigi.c b/src/demo/luigi.c index f9c85d674..c46f32856 100644 --- a/src/demo/luigi.c +++ b/src/demo/luigi.c @@ -114,7 +114,7 @@ draw_luigi(struct ncplane* n, const char* sprite){ cell bgc = CELL_TRIVIAL_INITIALIZER; cell_set_fg_alpha(&bgc, CELL_ALPHA_TRANSPARENT); cell_set_bg_alpha(&bgc, CELL_ALPHA_TRANSPARENT); - ncplane_set_default(n, &bgc); + ncplane_set_base(n, &bgc); cell_release(n, &bgc); size_t s; int sbytes; diff --git a/src/demo/maxcolor.c b/src/demo/maxcolor.c index b2e4489eb..582eefb4a 100644 --- a/src/demo/maxcolor.c +++ b/src/demo/maxcolor.c @@ -38,7 +38,7 @@ legend(struct notcurses* nc, const char* msg){ cell_set_fg_rgb(&c, 0, 0, 0); // darken surrounding characters by half cell_set_fg_alpha(&c, CELL_ALPHA_BLEND); cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); // don't touch background - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); ncplane_set_fg(n, 0xd78700); ncplane_set_bg(n, 0); if(ncplane_putstr_yx(n, 1, 1, msg) < 0){ @@ -127,7 +127,7 @@ slidepanel(struct notcurses* nc){ // of the underlying desktop). cell c = CELL_SIMPLE_INITIALIZER(' '); struct timespec cur; - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); uint64_t deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); int direction = random() % 4; @@ -140,7 +140,7 @@ slidepanel(struct notcurses* nc){ ncplane_destroy(l); cell_load_simple(n, &c, '\0'); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); l = legend(nc, "default background, all opaque, no glyph"); @@ -154,7 +154,7 @@ slidepanel(struct notcurses* nc){ // Next, we set our foreground transparent, allowing characters underneath to // be seen in their natural colors. Our background remains opaque+default. cell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); l = legend(nc, "default background, fg transparent, no glyph"); @@ -169,7 +169,7 @@ slidepanel(struct notcurses* nc){ // glyphs in a blended color, with the default background color. cell_set_fg(&c, 0x80c080); cell_set_fg_alpha(&c, CELL_ALPHA_BLEND); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "default background, fg blended, no glyph"); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); @@ -184,7 +184,7 @@ slidepanel(struct notcurses* nc){ // fixed color, with the default background color. cell_set_fg(&c, 0x80c080); cell_set_fg_alpha(&c, CELL_ALPHA_OPAQUE); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "default background, fg colored opaque, no glyph"); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); @@ -201,7 +201,7 @@ slidepanel(struct notcurses* nc){ cell_set_fg_default(&c); cell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); cell_set_bg_alpha(&c, CELL_ALPHA_OPAQUE); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "default colors, fg transparent, print glyph"); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); @@ -216,7 +216,7 @@ slidepanel(struct notcurses* nc){ // background color from below us. cell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "all transparent, print glyph"); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); @@ -233,7 +233,7 @@ slidepanel(struct notcurses* nc){ cell_set_bg_alpha(&c, CELL_ALPHA_BLEND); cell_set_fg(&c, 0x80c080); cell_set_bg(&c, 0x204080); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); clock_gettime(CLOCK_MONOTONIC, &cur); l = legend(nc, "all blended, print glyph"); deadlinens = timespec_to_ns(&cur) + DELAYSCALE * timespec_to_ns(&demodelay); diff --git a/src/demo/outro.c b/src/demo/outro.c index 00b538096..6d4f19126 100644 --- a/src/demo/outro.c +++ b/src/demo/outro.c @@ -72,7 +72,7 @@ outro_message(struct notcurses* nc, int* rows, int* cols){ } cell bgcell = CELL_SIMPLE_INITIALIZER(' '); channels_set_bg_rgb(&bgcell.channels, 0x58, 0x36, 0x58); - if(ncplane_set_default(non, &bgcell) < 0){ + if(ncplane_set_base(non, &bgcell) < 0){ return NULL; } ncplane_dim_yx(non, rows, cols); diff --git a/src/demo/sliding.c b/src/demo/sliding.c index 065aac210..066737fb1 100644 --- a/src/demo/sliding.c +++ b/src/demo/sliding.c @@ -117,7 +117,7 @@ fill_chunk(struct ncplane* n, int idx){ cell_init(&style); cell_set_fg_rgb(&style, r, g, b); cell_prime(n, &style, "█", 0, channels); - ncplane_set_default(n, &style); + ncplane_set_base(n, &style); cell_release(n, &style); return 0; } diff --git a/src/demo/view.c b/src/demo/view.c index 1450f1b86..940813d11 100644 --- a/src/demo/view.c +++ b/src/demo/view.c @@ -45,7 +45,7 @@ legend(struct notcurses* nc, int dimy, int dimx){ uint64_t channels = 0; channels_set_bg_alpha(&channels, CELL_ALPHA_TRANSPARENT); cell c = CELL_INITIALIZER(' ', 0, channels); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); ncplane_styles_set(n, CELL_STYLE_BOLD); ncplane_set_fg_rgb(n, 0xff, 0xff, 0xff); if(ncplane_putstr_aligned(n, 0, NCALIGN_CENTER, "target launch") <= 0){ diff --git a/src/demo/witherworm.c b/src/demo/witherworm.c index 408b6e0ca..127a66cef 100644 --- a/src/demo/witherworm.c +++ b/src/demo/witherworm.c @@ -276,7 +276,7 @@ message(struct ncplane* n, int maxy, int maxx, int num, int total, cell c = CELL_TRIVIAL_INITIALIZER; cell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); cell_release(n, &c); uint64_t channels = 0; ncplane_set_fg_rgb(n, 64, 128, 240); diff --git a/src/demo/xray.c b/src/demo/xray.c index d8f770f70..a5c7b9b85 100644 --- a/src/demo/xray.c +++ b/src/demo/xray.c @@ -38,7 +38,7 @@ perframecb(struct notcurses* nc, struct ncvisual* ncv __attribute__ ((unused)), cell c = CELL_SIMPLE_INITIALIZER(' '); cell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT); cell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT); - ncplane_set_default(n, &c); + ncplane_set_base(n, &c); ncplane_set_fg_alpha(n, CELL_ALPHA_BLEND); ncplane_set_bg_alpha(n, CELL_ALPHA_BLEND); // fg/bg rgbs are set within loop diff --git a/src/lib/fade.c b/src/lib/fade.c index 003244afc..44967e2ef 100644 --- a/src/lib/fade.c +++ b/src/lib/fade.c @@ -53,7 +53,7 @@ alloc_ncplane_palette(ncplane* n, planepalette* pp){ } } // FIXME factor this duplication out - channels = n->defcell.channels; + channels = n->basecell.channels; pp->channels[y * pp->cols] = channels; channels_get_fg_rgb(channels, &r, &g, &b); if(r > pp->maxr){ @@ -211,20 +211,20 @@ int ncplane_fadeout(struct ncplane* n, const struct timespec* ts, fadecb fader){ } } } - cell* c = &n->defcell; + cell* c = &n->basecell; if(!cell_fg_default_p(c)){ channels_get_fg_rgb(pp.channels[pp.cols * y], &r, &g, &b); r = r * (maxsteps - iter) / maxsteps; g = g * (maxsteps - iter) / maxsteps; b = b * (maxsteps - iter) / maxsteps; - cell_set_fg_rgb(&n->defcell, r, g, b); + cell_set_fg_rgb(&n->basecell, r, g, b); } if(!cell_bg_default_p(c)){ channels_get_bg_rgb(pp.channels[pp.cols * y], &br, &bg, &bb); br = br * (maxsteps - iter) / maxsteps; bg = bg * (maxsteps - iter) / maxsteps; bb = bb * (maxsteps - iter) / maxsteps; - cell_set_bg_rgb(&n->defcell, br, bg, bb); + cell_set_bg_rgb(&n->basecell, br, bg, bb); } if(fader){ fader(n->nc, n); diff --git a/src/lib/internal.h b/src/lib/internal.h index b5d7878c4..2c3adf0e8 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -61,7 +61,7 @@ typedef struct ncplane { 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 - cell defcell; // cell written anywhere that fb[i].gcluster == 0 + cell basecell; // cell written anywhere that fb[i].gcluster == 0 struct notcurses* nc; // notcurses object of which we are a part } ncplane; diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index ed7fa3c45..65c9ed0b7 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -291,7 +291,7 @@ ncplane_create(notcurses* nc, int rows, int cols, int yoff, int xoff){ p->z = nc->top; nc->top = p; p->nc = nc; - cell_init(&p->defcell); + cell_init(&p->basecell); nc->stats.fbbytes += fbsize; return p; } @@ -925,16 +925,16 @@ int ncplane_set_bg_alpha(ncplane *n, int alpha){ return channels_set_bg_alpha(&n->channels, alpha); } -int ncplane_set_default(ncplane* ncp, const cell* c){ - int ret = cell_duplicate(ncp, &ncp->defcell, c); +int ncplane_set_base(ncplane* ncp, const cell* c){ + int ret = cell_duplicate(ncp, &ncp->basecell, c); if(ret < 0){ return -1; } return ret; } -int ncplane_default(ncplane* ncp, cell* c){ - return cell_duplicate(ncp, c, &ncp->defcell); +int ncplane_base(ncplane* ncp, cell* c){ + return cell_duplicate(ncp, c, &ncp->basecell); } const char* cell_extended_gcluster(const struct ncplane* n, const cell* c){ @@ -1555,11 +1555,11 @@ void ncplane_erase(ncplane* n){ // we must preserve the background, but a pure cell_duplicate() would be // wiped out by the egcpool_dump(). do a duplication (to get the attrword // and channels), and then reload. - char* egc = cell_egc_copy(n, &n->defcell); + char* egc = cell_egc_copy(n, &n->basecell); memset(n->fb, 0, sizeof(*n->fb) * n->lenx * n->leny); egcpool_dump(&n->pool); egcpool_init(&n->pool); - cell_load(n, &n->defcell, egc); + cell_load(n, &n->basecell, egc); free(egc); ncplane_unlock(n); } diff --git a/src/lib/panelreel.c b/src/lib/panelreel.c index 466bdb1d8..80dc70b26 100644 --- a/src/lib/panelreel.c +++ b/src/lib/panelreel.c @@ -623,7 +623,7 @@ panelreel* panelreel_create(ncplane* w, const panelreel_options* popts, int efd) } cell bgc = CELL_TRIVIAL_INITIALIZER; bgc.channels = popts->bgchannel; - ncplane_set_default(pr->p, &bgc); + ncplane_set_base(pr->p, &bgc); cell_release(pr->p, &bgc); if(panelreel_redraw(pr)){ ncplane_destroy(pr->p); diff --git a/src/lib/render.c b/src/lib/render.c index 5f7068159..6ad9f2f8a 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -160,7 +160,7 @@ dig_visible_cell(cell* c, int y, int x, ncplane* p){ // if we never loaded any content into the cell (or obliterated it by // writing in a zero), use the plane's default cell. if(vis->gcluster == 0){ - vis = &p->defcell; + vis = &p->basecell; } // if we have no character in this cell, we continune to look for a // character, but our foreground color will still be used unless it's diff --git a/src/planereel/main.cpp b/src/planereel/main.cpp index 055d244e1..2585a35a6 100644 --- a/src/planereel/main.cpp +++ b/src/planereel/main.cpp @@ -25,7 +25,7 @@ int tabletfxn(struct tablet* t, int begx, int begy, int maxx, int maxy, ncplane_erase(p); cell c = CELL_SIMPLE_INITIALIZER(' '); cell_set_bg(&c, (((uintptr_t)t) % 0x1000000) + cliptop + begx + maxx); - ncplane_set_default(p, &c); + ncplane_set_base(p, &c); cell_release(p, &c); return tctx->getLines() > maxy - begy ? maxy - begy : tctx->getLines(); } diff --git a/tests/cell.cpp b/tests/cell.cpp index 757ed8506..8c75370ff 100644 --- a/tests/cell.cpp +++ b/tests/cell.cpp @@ -32,7 +32,7 @@ SUBCASE("SetItalic") { cell_styles_set(&c, CELL_STYLE_ITALIC); REQUIRE(1 == cell_load(n_, &c, "i")); cell_set_fg_rgb(&c, 255, 255, 255); - ncplane_set_default(n_, &c); + ncplane_set_base(n_, &c); cell_release(n_, &c); CHECK(0 == notcurses_render(nc_)); cell_styles_off(&c, CELL_STYLE_ITALIC); @@ -45,7 +45,7 @@ SUBCASE("SetItalic") { cell_styles_set(&c, CELL_STYLE_BOLD); REQUIRE(1 == cell_load(n_, &c, "b")); cell_set_fg_rgb(&c, 255, 255, 255); - ncplane_set_default(n_, &c); + ncplane_set_base(n_, &c); cell_release(n_, &c); CHECK(0 == notcurses_render(nc_)); cell_styles_off(&c, CELL_STYLE_BOLD); @@ -58,7 +58,7 @@ SUBCASE("SetItalic") { cell_styles_set(&c, CELL_STYLE_UNDERLINE); REQUIRE(1 == cell_load(n_, &c, "u")); cell_set_fg_rgb(&c, 255, 255, 255); - ncplane_set_default(n_, &c); + ncplane_set_base(n_, &c); cell_release(n_, &c); CHECK(0 == notcurses_render(nc_)); cell_styles_off(&c, CELL_STYLE_UNDERLINE);