From 3b254c6787af26b4c4064ef32f711e1684dcff75 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 13 Sep 2020 13:11:16 -0400 Subject: [PATCH] selector: trans out bg cells #627 --- src/lib/selector.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/lib/selector.c b/src/lib/selector.c index 9e5e86bed..65f84f26a 100644 --- a/src/lib/selector.c +++ b/src/lib/selector.c @@ -79,17 +79,27 @@ ncselector_draw(ncselector* n){ if(n->title){ size_t riserwidth = n->titlecols + 4; int offx = ncplane_align(n->ncp, NCALIGN_RIGHT, riserwidth); + ncplane_cursor_move_yx(n->ncp, 0, 0); + ncplane_hline(n->ncp, &transchar, offx); ncplane_cursor_move_yx(n->ncp, 0, offx); ncplane_rounded_box_sized(n->ncp, 0, n->boxchannels, 3, riserwidth, 0); n->ncp->channels = n->titlechannels; ncplane_printf_yx(n->ncp, 1, offx + 1, " %s ", n->title); yoff += 2; + ncplane_cursor_move_yx(n->ncp, 1, 0); + ncplane_hline(n->ncp, &transchar, offx); } int bodywidth = ncselector_body_width(n); - int xoff = ncplane_align(n->ncp, NCALIGN_RIGHT, bodywidth); - ncplane_cursor_move_yx(n->ncp, yoff, xoff); int dimy, dimx; ncplane_dim_yx(n->ncp, &dimy, &dimx); + int xoff = ncplane_align(n->ncp, NCALIGN_RIGHT, bodywidth); + if(xoff){ + for(int y = yoff + 1 ; y < dimy ; ++y){ + ncplane_cursor_move_yx(n->ncp, y, 0); + ncplane_hline(n->ncp, &transchar, xoff); + } + } + ncplane_cursor_move_yx(n->ncp, yoff, xoff); ncplane_rounded_box_sized(n->ncp, 0, n->boxchannels, dimy - yoff, bodywidth, 0); if(n->title){ n->ncp->channels = n->boxchannels; @@ -135,7 +145,8 @@ ncselector_draw(ncselector* n){ ++yoff; ncplane_cursor_move_yx(n->ncp, yoff, xoff + 1); for(int i = xoff + 1 ; i < dimx - 1 ; ++i){ - ncplane_putc(n->ncp, &transchar); + cell transc = CELL_TRIVIAL_INITIALIZER; // fall back to base cell + ncplane_putc(n->ncp, &transc); } const int bodyoffset = dimx - bodywidth + 2; if(n->maxdisplay && n->maxdisplay < n->itemcount){ @@ -158,7 +169,8 @@ ncselector_draw(ncselector* n){ } ncplane_cursor_move_yx(n->ncp, yoff, xoff + 1); for(int i = xoff + 1 ; i < dimx - 1 ; ++i){ - ncplane_putc(n->ncp, &transchar); + cell transc = CELL_TRIVIAL_INITIALIZER; // fall back to base cell + ncplane_putc(n->ncp, &transc); } n->ncp->channels = n->opchannels; if(printidx == n->selected){ @@ -178,7 +190,8 @@ ncselector_draw(ncselector* n){ // Bottom line of body (background and possibly down arrow) ncplane_cursor_move_yx(n->ncp, yoff, xoff + 1); for(int i = xoff + 1 ; i < dimx - 1 ; ++i){ - ncplane_putc(n->ncp, &transchar); + cell transc = CELL_TRIVIAL_INITIALIZER; // fall back to base cell + ncplane_putc(n->ncp, &transc); } if(n->maxdisplay && n->maxdisplay < n->itemcount){ n->ncp->channels = n->descchannels; @@ -279,7 +292,8 @@ ncselector* ncselector_create(ncplane* n, const ncselector_options* opts){ ns->longop = cols; } cols = mbswidth(src->desc); - ns->items[ns->itemcount].desccolumns = cols; if(cols > ns->longdesc){ + ns->items[ns->itemcount].desccolumns = cols; + if(cols > ns->longdesc){ ns->longdesc = cols; } ns->items[ns->itemcount].option = strdup(src->option);