diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 6e9f91dc4..9a21b4db4 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1355,18 +1355,7 @@ API char* ncplane_at_yx(const struct ncplane* n, int y, int x, // Retrieve the current contents of the specified cell into 'c'. This cell is // invalidated if the associated plane is destroyed. -static inline int -ncplane_at_yx_cell(struct ncplane* n, int y, int x, nccell* c){ - char* egc = ncplane_at_yx(n, y, x, &c->stylemask, &c->channels); - if(!egc){ - return -1; - } - uint64_t channels = c->channels; // need to preserve wide flag - int r = cell_load(n, c, egc); - c->channels = channels; - free(egc); - return r; -} +API int ncplane_at_yx_cell(struct ncplane* n, int y, int x, nccell* c); // Create a flat string from the EGCs of the selected region of the ncplane // 'n'. Start at the plane's 'begy'x'begx' coordinate (which must lie on the diff --git a/src/demo/fallin.c b/src/demo/fallin.c index e2235cbc7..3162f02c0 100644 --- a/src/demo/fallin.c +++ b/src/demo/fallin.c @@ -151,13 +151,8 @@ int fallin_demo(struct notcurses* nc){ if(ncplane_at_yx_cell(stdn, usey, usex, &stdc) < 0){ goto err; } - if(cell_prime(n, &c, cell_extended_gcluster(stdn, &stdc), stdc.stylemask, stdc.channels) < 0){ - cell_release(stdn, &stdc); - goto err; - } - cell_release(stdn, &stdc); if(c.gcluster){ - if(ncplane_putc_yx(n, usey - y, usex - x, &c) < 0){ + if(ncplane_putc_yx(n, usey - y, usex - x, &stdc) < 0){ // allow a fail if we were printing a wide char to the // last column of our plane if(!cell_double_wide_p(&c) || usex + 1 < x + newx){ @@ -166,7 +161,7 @@ int fallin_demo(struct notcurses* nc){ } } usemap[usey * dimx + usex] = true; - cell_release(n, &c); + cell_release(n, &stdc); } } // shuffle the new ncplane into the array diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 5c1af4b90..9e4a41cf5 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -235,6 +235,11 @@ char* ncplane_at_yx(const ncplane* n, int y, int x, uint16_t* stylemask, uint64_ return ret; } +int ncplane_at_yx_cell(struct ncplane* n, int y, int x, nccell* c){ + nccell* targ = ncplane_cell_ref_yx(n, y, x); + return cell_duplicate(n, c, targ); +} + void ncplane_dim_yx(const ncplane* n, int* rows, int* cols){ if(rows){ *rows = n->leny;