mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
ncplane_at_cursor_cell: rewrite with ncplane_at_yx_cell()
This commit is contained in:
parent
1798e061e1
commit
bf3e3eb0b5
@ -1336,16 +1336,7 @@ API char* ncplane_at_cursor(struct ncplane* n, uint16_t* stylemask, uint64_t* ch
|
||||
|
||||
// Retrieve the current contents of the cell under the cursor into 'c'. This
|
||||
// cell is invalidated if the associated plane is destroyed.
|
||||
static inline int
|
||||
ncplane_at_cursor_cell(struct ncplane* n, nccell* c){
|
||||
char* egc = ncplane_at_cursor(n, &c->stylemask, &c->channels);
|
||||
if(!egc){
|
||||
return -1;
|
||||
}
|
||||
int r = cell_load(n, c, egc);
|
||||
free(egc);
|
||||
return r;
|
||||
}
|
||||
API int ncplane_at_cursor_cell(struct ncplane* n, nccell* c);
|
||||
|
||||
// Retrieve the current contents of the specified cell. The EGC is returned, or
|
||||
// NULL on error. This EGC must be free()d by the caller. The stylemask and
|
||||
|
@ -219,25 +219,30 @@ cursor_invalid_p(const ncplane* n){
|
||||
}
|
||||
|
||||
char* ncplane_at_cursor(ncplane* n, uint16_t* stylemask, uint64_t* channels){
|
||||
if(cursor_invalid_p(n)){
|
||||
return NULL;
|
||||
}
|
||||
return cell_extract(n, &n->fb[nfbcellidx(n, n->y, n->x)], stylemask, channels);
|
||||
return ncplane_at_yx(n, n->y, n->x, stylemask, channels);
|
||||
}
|
||||
|
||||
char* ncplane_at_yx(const ncplane* n, int y, int x, uint16_t* stylemask, uint64_t* channels){
|
||||
char* ret = NULL;
|
||||
if(y < n->leny && x < n->lenx){
|
||||
if(y >= 0 && x >= 0){
|
||||
ret = cell_extract(n, &n->fb[nfbcellidx(n, y, x)], stylemask, channels);
|
||||
return cell_extract(n, &n->fb[nfbcellidx(n, y, x)], stylemask, channels);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
int ncplane_at_cursor_cell(ncplane* n, nccell* c){
|
||||
return ncplane_at_yx_cell(n, n->y, n->x, c);
|
||||
}
|
||||
|
||||
int ncplane_at_yx_cell(ncplane* n, int y, int x, nccell* c){
|
||||
if(y < n->leny && x < n->lenx){
|
||||
if(y >= 0 && x >= 0){
|
||||
nccell* targ = ncplane_cell_ref_yx(n, y, x);
|
||||
return cell_duplicate(n, c, targ);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ncplane_dim_yx(const ncplane* n, int* rows, int* cols){
|
||||
|
Loading…
Reference in New Issue
Block a user