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);
}else{
if(!(mask & NCBOXMASK_LEFT)){
ret |= ncplane_cursor_move_yx(w, maxy, begx);
ret |= ncplane_putc(w, &ll);
if(ncplane_cursor_move_yx(w, maxy, begx) || ncplane_putc(w, &ll) < 0){
ret = -1;
}
}
if(!(mask & NCBOXMASK_RIGHT)){
// mvwadd_wch returns error if we print to the lowermost+rightmost
// character cell. maybe we can make this go away with scrolling controls
// at setup? until then, don't check for error here FIXME.
ret |= ncplane_cursor_move_yx(w, maxy, maxx);
ret |= ncplane_putc(w, &lr);
if(ncplane_cursor_move_yx(w, maxy, maxx) || ncplane_putc(w, &lr) < 0){
ret = -1;
}
}
}
}
@ -317,8 +319,8 @@ panelreel_draw_tablet(const panelreel* pr, tablet* t, int frontiery,
}
}
draw_borders(fp, pr->popts.tabletmask,
direction == 0 ? &pr->popts.focusedattr : &pr->popts.tabletattr,
cliphead, clipfoot);
direction == 0 ? &pr->popts.focusedattr : &pr->popts.tabletattr,
cliphead, clipfoot);
return cliphead || clipfoot;
}
@ -510,6 +512,7 @@ int panelreel_redraw(panelreel* pr){
// having to do an o(n) iteration each round, but this is still grotesque, and
// feels fragile...
if(pr->all_visible){
//fprintf(stderr, "all are visible!\n");
return panelreel_arrange_denormalized(pr);
}
//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);
}
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) {
panelreel_options p{};
p.tabletmask = NCBOXMASK_LEFT * 2;