mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
ncplane_content: add diagnostics #520
This commit is contained in:
parent
a46dcc5fe4
commit
1f9855b243
@ -760,7 +760,9 @@ calc_gradient_channels(uint64_t* channels, uint64_t ul, uint64_t ur,
|
||||
void nclog(const char* fmt, ...);
|
||||
|
||||
// logging
|
||||
#define logerror(nc, fmt, ...) do{ if(nc->loglevel >= NCLOGLEVEL_ERROR){ nclog(__FILE__ ":%d:" fmt, __LINE__, ##__VA_ARGS__); } }while(0);
|
||||
#define logerror(nc, fmt, ...) do{ \
|
||||
if((nc)->loglevel >= NCLOGLEVEL_ERROR){ \
|
||||
nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } }while(0);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2095,9 +2095,12 @@ uint32_t* ncplane_rgba(const ncplane* nc, ncblitter_e blit,
|
||||
|
||||
char* ncplane_contents(const ncplane* nc, int begy, int begx, int leny, int lenx){
|
||||
if(begy < 0 || begx < 0){
|
||||
logerror(nc->nc, "Beginning coordinates (%d/%d) below 0\n", begy, begx);
|
||||
return NULL;
|
||||
}
|
||||
if(begx >= nc->lenx || begy >= nc->leny){
|
||||
logerror(nc->nc, "Beginning coordinates (%d/%d) exceeded lengths (%d/%d)\n",
|
||||
begy, begx, nc->leny, nc->lenx);
|
||||
return NULL;
|
||||
}
|
||||
if(lenx == -1){ // -1 means "to the end"; use all space available
|
||||
@ -2107,9 +2110,12 @@ char* ncplane_contents(const ncplane* nc, int begy, int begx, int leny, int lenx
|
||||
leny = nc->leny - begy;
|
||||
}
|
||||
if(lenx < 0 || leny < 0){ // no need to draw zero-size object, exit
|
||||
logerror(nc->nc, "Lengths (%d/%d) below 0\n", leny, lenx);
|
||||
return NULL;
|
||||
}
|
||||
if(begx + lenx > nc->lenx || begy + leny > nc->leny){
|
||||
logerror(nc->nc, "Ending coordinates (%d/%d) exceeded lengths (%d/%d)\n",
|
||||
begy + leny, begx + lenx, nc->leny, nc->lenx);
|
||||
return NULL;
|
||||
}
|
||||
size_t retlen = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user