mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
correct sub to add in ncreel_tighten_down() #901
This commit is contained in:
parent
1cda7758b5
commit
720f61d51f
@ -284,12 +284,12 @@ ncreel_draw_tablet(const ncreel* nr, nctablet* t, int frontiertop,
|
||||
return -1;
|
||||
}
|
||||
ncplane_move_above(t->cbp, t->p);
|
||||
// fprintf(stderr, "calling! lenx/leny: %d/%d cbx/cby: %d/%d cblenx/cbleny: %d/%d dir: %d\n", lenx, leny, cbx, cby, cblenx, cbleny, direction);
|
||||
//fprintf(stderr, "calling! lenx/leny: %d/%d cbx/cby: %d/%d cblenx/cbleny: %d/%d dir: %d\n", lenx, leny, cbx, cby, cblenx, cbleny, direction);
|
||||
int ll = t->cbfxn(t, direction == DIRECTION_DOWN);
|
||||
//fprintf(stderr, "RETURNRETURNRETURN %p %d (%d, %d, %d) DIR %d\n", t, ll, cby, cbleny, leny, direction);
|
||||
if(ll != cbleny){
|
||||
int diff = cbleny - ll;
|
||||
//fprintf(stderr, "resizing data plane %d->%d\n", cbleny, ll);
|
||||
//fprintf(stderr, "resizing data plane %d->%d\n", cbleny, leny - diff);
|
||||
if(ll){
|
||||
ncplane_resize_simple(t->cbp, ll, cblenx);
|
||||
}else{
|
||||
@ -481,9 +481,9 @@ tighten_reel_down(ncreel* r, int ybot){
|
||||
if(cury == ybot - ylen){
|
||||
break;
|
||||
}
|
||||
//fprintf(stderr, "tightening %p down to %d from %d\n", cur, ybot - ylen, cury);
|
||||
cury = ybot - ylen;
|
||||
ncplane_move_yx(cur->p, cury, curx);
|
||||
//fprintf(stderr, "tightened %p down to %d\n", cur, cury);
|
||||
ybot = cury - 1;
|
||||
if((cur = cur->prev) == r->tablets){
|
||||
break;
|
||||
@ -492,18 +492,18 @@ tighten_reel_down(ncreel* r, int ybot){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// run at the end of redraw, this aligns the top tablet with the top
|
||||
// of the reel. we prefer empty space at the bottom (FIXME but not
|
||||
// really -- we ought prefer space away from the last direction of
|
||||
// movement. rather than this postprocessing, draw things to the
|
||||
// right places!). we then trim any tablet overhang.
|
||||
// FIXME could pass top/bottom in directly, available as otherend
|
||||
// run at the end of redraw, this aligns the top tablet with the top of the
|
||||
// reel. we prefer empty space at the bottom (FIXME but not really -- we ought
|
||||
// prefer space away from the last direction of movement. rather than this
|
||||
// postprocessing, draw things to the right places!). we then trim any tablet
|
||||
// overhang. FIXME could pass top/bottom in directly, available as otherend
|
||||
static int
|
||||
tighten_reel(ncreel* r){
|
||||
//fprintf(stderr, "tightening it up\n");
|
||||
nctablet* top = r->tablets;
|
||||
nctablet* cur = top;
|
||||
int ytop = INT_MAX;
|
||||
// find the top tablet
|
||||
while(cur){
|
||||
if(cur->p == NULL){
|
||||
break;
|
||||
@ -520,6 +520,7 @@ tighten_reel(ncreel* r){
|
||||
int expected = !(r->ropts.bordermask & NCBOXMASK_TOP);
|
||||
cur = top;
|
||||
nctablet* bottom = r->tablets;
|
||||
// find the bottom tablet, moving tablets up as we go along
|
||||
while(cur){
|
||||
if(cur->p == NULL){
|
||||
break;
|
||||
@ -549,7 +550,7 @@ tighten_reel(ncreel* r){
|
||||
ncplane_dim_yx(r->p, &rylen, NULL);
|
||||
ncplane_yx(n, &yoff, NULL);
|
||||
ncplane_dim_yx(n, &ylen, NULL);
|
||||
const int ybot = rylen - 1 - !!(r->ropts.bordermask & NCBOXMASK_BOTTOM);
|
||||
const int ybot = rylen - 1 + !!(r->ropts.bordermask & NCBOXMASK_BOTTOM);
|
||||
// FIXME want to tighten down whenever we're at the bottom, and the reel
|
||||
// is full, not just in this case (this can leave a gap of more than 1 row)
|
||||
if(yoff + ylen + 1 >= ybot){
|
||||
|
@ -80,60 +80,47 @@ TEST_CASE("ReelGaps") {
|
||||
CHECK(nullptr != t1);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t2 = ncreel_add(nr, NULL, NULL, t2_tablet_cb, NULL);
|
||||
CHECK(nullptr != t2);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t3 = ncreel_add(nr, NULL, NULL, t3_tablet_cb, NULL);
|
||||
CHECK(nullptr != t3);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t4 = ncreel_add(nr, NULL, NULL, t4_tablet_cb, NULL);
|
||||
CHECK(nullptr != t4);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t5 = ncreel_add(nr, NULL, NULL, t5_tablet_cb, NULL);
|
||||
CHECK(nullptr != t5);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
auto t6 = ncreel_add(nr, NULL, NULL, t6_tablet_cb, NULL);
|
||||
CHECK(nullptr != t6);
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t2
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t3
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t4
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t5
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t6
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t7
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
ncreel_next(nr); // move to t8
|
||||
CHECK(ncreel_validate(nr));
|
||||
CHECK_EQ(0, notcurses_render(nc_));
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
|
Loading…
Reference in New Issue
Block a user