mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-04 06:00:30 +00:00
[bitmapstates] properly use ncplane_erase_region()
This commit is contained in:
parent
ad2b806444
commit
69e58667c7
@ -2103,6 +2103,7 @@ void ncplane_yx(const ncplane* n, int* y, int* x){
|
||||
}
|
||||
|
||||
void ncplane_erase(ncplane* n){
|
||||
loginfo("erasing plane\n");
|
||||
if(n->sprite){
|
||||
sprixel_hide(n->sprite);
|
||||
}
|
||||
@ -2156,13 +2157,17 @@ int ncplane_erase_region(ncplane* n, int ystart, int xstart, int ylen, int xlen)
|
||||
if(ystart + ylen > ncplane_dim_y(n)){
|
||||
ylen = ncplane_dim_y(n) - ystart;
|
||||
}
|
||||
loginfo("erasing %d/%d - %d/%d\n", ystart, xstart, ystart + ylen, xstart + xlen);
|
||||
// special-case the full plane erasure, as it's powerfully optimized (O(1))
|
||||
if(ystart == 0 && xstart == 0 &&
|
||||
ylen == ncplane_dim_y(n) && xlen == ncplane_dim_x(n)){
|
||||
int tmpy = n->y; // preserve cursor location
|
||||
int tmpx = n->x;
|
||||
ncplane_erase(n);
|
||||
n->y = tmpy;
|
||||
n->x = tmpx;
|
||||
return 0;
|
||||
}
|
||||
loginfo("erasing %d/%d - %d/%d\n", ystart, xstart, ystart + ylen, xstart + xlen);
|
||||
for(int y = ystart ; y < ystart + ylen ; ++y){
|
||||
for(int x = xstart ; x < xstart + xlen ; ++x){
|
||||
nccell_release(n, &n->fb[nfbcellidx(n, y, x)]);
|
||||
|
@ -4,7 +4,7 @@
|
||||
static void
|
||||
emit(struct ncplane* n, const char* str){
|
||||
fprintf(stderr, "\n\n\n%s\n", str);
|
||||
ncplane_erase_region(n, 6, 0, 0, 0);
|
||||
ncplane_erase_region(n, 6, 0, INT_MAX, 0);
|
||||
ncplane_putstr_yx(n, 6, 0, str);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,8 @@ draw_grid(struct ncplane* stdn){
|
||||
int main(void){
|
||||
struct notcurses_options opts = {
|
||||
.flags = NCOPTION_NO_ALTERNATE_SCREEN |
|
||||
NCOPTION_DRAIN_INPUT,
|
||||
NCOPTION_DRAIN_INPUT |
|
||||
NCOPTION_NO_CLEAR_BITMAPS,
|
||||
// .loglevel = NCLOGLEVEL_TRACE,
|
||||
};
|
||||
struct notcurses* nc = notcurses_init(&opts, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user