progbar: don't overrun on 1.0 #1257

pull/1259/head
nick black 4 years ago
parent 5d90e7de15
commit f22ddfa72f
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -68,6 +68,7 @@ allglyphs(struct notcurses* nc, struct ncplane* column, int legendy,
}
}
}
ncprogbar_set_progress(left, glyphsdone / totalglyphs);
ncprogbar_set_progress(right, glyphsdone / totalglyphs);
DEMO_RENDER(nc);
return 0;

@ -108,6 +108,16 @@ progbar_redraw(ncprogbar* n){
const int chunks = n->progress / eachcell;
chunk -= eachcell * chunks;
pos += delt * chunks;
if(pos >= range){
return 0;
}
if(pos < 0){
return 0;
}
// at this point, we have a gradient across the entirety of the progress
// bar. we're going to first update the active frontier, which might need
// to cut down from a full block to a partial block. we'll then null out
// anything beyond the frontier.
const int egcidx = (int)(chunk / (eachcell / 8));
const char* egc = egcs + egcidx * 5;
if(horizontal){
@ -139,6 +149,7 @@ progbar_redraw(ncprogbar* n){
}
}
}
// we now clear out all cells beyond the frontier.
pos += delt;
while(pos >= 0 && pos < range){
if(horizontal){

Loading…
Cancel
Save