panelreel: don't treat putc() return as bool #132

This commit is contained in:
nick black 2019-12-13 15:28:11 -05:00
parent a9c21526a7
commit 6e49bbce45
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 23 additions and 6 deletions

View File

@ -116,15 +116,17 @@ draw_borders(ncplane* w, unsigned mask, const cell* attr,
ncplane_putc(w, &lr); ncplane_putc(w, &lr);
}else{ }else{
if(!(mask & NCBOXMASK_LEFT)){ if(!(mask & NCBOXMASK_LEFT)){
ret |= ncplane_cursor_move_yx(w, maxy, begx); if(ncplane_cursor_move_yx(w, maxy, begx) || ncplane_putc(w, &ll) < 0){
ret |= ncplane_putc(w, &ll); ret = -1;
}
} }
if(!(mask & NCBOXMASK_RIGHT)){ if(!(mask & NCBOXMASK_RIGHT)){
// mvwadd_wch returns error if we print to the lowermost+rightmost // mvwadd_wch returns error if we print to the lowermost+rightmost
// character cell. maybe we can make this go away with scrolling controls // character cell. maybe we can make this go away with scrolling controls
// at setup? until then, don't check for error here FIXME. // at setup? until then, don't check for error here FIXME.
ret |= ncplane_cursor_move_yx(w, maxy, maxx); if(ncplane_cursor_move_yx(w, maxy, maxx) || ncplane_putc(w, &lr) < 0){
ret |= ncplane_putc(w, &lr); ret = -1;
}
} }
} }
} }
@ -510,6 +512,7 @@ int panelreel_redraw(panelreel* pr){
// having to do an o(n) iteration each round, but this is still grotesque, and // having to do an o(n) iteration each round, but this is still grotesque, and
// feels fragile... // feels fragile...
if(pr->all_visible){ if(pr->all_visible){
//fprintf(stderr, "all are visible!\n");
return panelreel_arrange_denormalized(pr); return panelreel_arrange_denormalized(pr);
} }
//fprintf(stderr, "drawing focused tablet %p dir: %d!\n", focused, pr->last_traveled_direction); //fprintf(stderr, "drawing focused tablet %p dir: %d!\n", focused, pr->last_traveled_direction);

View File

@ -150,6 +150,20 @@ TEST_F(PanelReelTest, NoTabletBorder) {
ASSERT_NE(nullptr, pr); ASSERT_NE(nullptr, pr);
} }
TEST_F(PanelReelTest, NoTopBottomBorder) {
panelreel_options p{};
p.bordermask = NCBOXMASK_TOP | NCBOXMASK_BOTTOM;
struct panelreel* pr = panelreel_create(n_, &p, -1);
ASSERT_NE(nullptr, pr);
}
TEST_F(PanelReelTest, NoSideBorders) {
panelreel_options p{};
p.bordermask = NCBOXMASK_LEFT | NCBOXMASK_RIGHT;
struct panelreel* pr = panelreel_create(n_, &p, -1);
ASSERT_NE(nullptr, pr);
}
TEST_F(PanelReelTest, BadTabletBorderBitsRejected) { TEST_F(PanelReelTest, BadTabletBorderBitsRejected) {
panelreel_options p{}; panelreel_options p{};
p.tabletmask = NCBOXMASK_LEFT * 2; p.tabletmask = NCBOXMASK_LEFT * 2;