From 6e49bbce457493a0e902e0b19b940b07976bc067 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 13 Dec 2019 15:28:11 -0500 Subject: [PATCH] panelreel: don't treat putc() return as bool #132 --- src/lib/panelreel.c | 15 +++++++++------ tests/panelreel.cpp | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/lib/panelreel.c b/src/lib/panelreel.c index ac28abdf3..3db5fa0b6 100644 --- a/src/lib/panelreel.c +++ b/src/lib/panelreel.c @@ -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); diff --git a/tests/panelreel.cpp b/tests/panelreel.cpp index 658312cc4..d1a4054a7 100644 --- a/tests/panelreel.cpp +++ b/tests/panelreel.cpp @@ -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;