mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
ncplane_at_yx_cell: work directly with cell_duplicate() #1231
This commit is contained in:
parent
1b613591fe
commit
28b1a80433
@ -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
|
// Retrieve the current contents of the specified cell into 'c'. This cell is
|
||||||
// invalidated if the associated plane is destroyed.
|
// invalidated if the associated plane is destroyed.
|
||||||
static inline int
|
API int ncplane_at_yx_cell(struct ncplane* n, int y, int x, nccell* c);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a flat string from the EGCs of the selected region of the ncplane
|
// 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
|
// 'n'. Start at the plane's 'begy'x'begx' coordinate (which must lie on the
|
||||||
|
@ -151,13 +151,8 @@ int fallin_demo(struct notcurses* nc){
|
|||||||
if(ncplane_at_yx_cell(stdn, usey, usex, &stdc) < 0){
|
if(ncplane_at_yx_cell(stdn, usey, usex, &stdc) < 0){
|
||||||
goto err;
|
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(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
|
// allow a fail if we were printing a wide char to the
|
||||||
// last column of our plane
|
// last column of our plane
|
||||||
if(!cell_double_wide_p(&c) || usex + 1 < x + newx){
|
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;
|
usemap[usey * dimx + usex] = true;
|
||||||
cell_release(n, &c);
|
cell_release(n, &stdc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// shuffle the new ncplane into the array
|
// shuffle the new ncplane into the array
|
||||||
|
@ -235,6 +235,11 @@ char* ncplane_at_yx(const ncplane* n, int y, int x, uint16_t* stylemask, uint64_
|
|||||||
return ret;
|
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){
|
void ncplane_dim_yx(const ncplane* n, int* rows, int* cols){
|
||||||
if(rows){
|
if(rows){
|
||||||
*rows = n->leny;
|
*rows = n->leny;
|
||||||
|
Loading…
Reference in New Issue
Block a user