special-case double/rounded boxes in ASCII #325

This commit is contained in:
nick black 2020-05-11 04:22:44 -04:00 committed by Nick Black
parent 7b4ebed07d
commit 25baa10f72
3 changed files with 31 additions and 15 deletions

View File

@ -2008,11 +2008,9 @@ cells_load_box(struct ncplane* n, uint32_t attrs, uint64_t channels,
return -1;
}
static inline int
cells_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr, cell* hl, cell* vl){
return cells_load_box(n, attr, channels, ul, ur, ll, lr, hl, vl, "╭╮╰╯─│");
}
API int cells_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr,
cell* hl, cell* vl);
static inline int
ncplane_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
@ -2039,11 +2037,9 @@ ncplane_rounded_box_sized(struct ncplane* n, uint32_t attr, uint64_t channels,
x + xlen - 1, ctlword);
}
static inline int
cells_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr, cell* hl, cell* vl){
return cells_load_box(n, attr, channels, ul, ur, ll, lr, hl, vl, "╔╗╚╝═║");
}
API int cells_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr,
cell* hl, cell* vl);
static inline int
ncplane_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,

View File

@ -2122,3 +2122,24 @@ char* ncplane_contents(const ncplane* nc, int begy, int begx, int leny, int lenx
}
return ret;
}
int cells_ascii_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr, cell* hl, cell* vl){
return cells_load_box(n, attr, channels, ul, ur, ll, lr, hl, vl, "/\\\\/-|");
}
int cells_double_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr, cell* hl, cell* vl){
if(enforce_utf8(n->nc)){
return cells_load_box(n, attr, channels, ul, ur, ll, lr, hl, vl, "╔╗╚╝═║");
}
return cells_ascii_box(n, attr, channels, ul, ur, ll, lr, hl, vl);
}
int cells_rounded_box(struct ncplane* n, uint32_t attr, uint64_t channels,
cell* ul, cell* ur, cell* ll, cell* lr, cell* hl, cell* vl){
if(enforce_utf8(n->nc)){
return cells_load_box(n, attr, channels, ul, ur, ll, lr, hl, vl, "╭╮╰╯─│");
}
return cells_ascii_box(n, attr, channels, ul, ur, ll, lr, hl, vl);
}

View File

@ -495,12 +495,11 @@ ncmultiselector_draw(ncmultiselector* n){
if(printidx == n->current){
n->ncp->channels = (uint64_t)channels_bchannel(n->descchannels) << 32u | channels_fchannel(n->descchannels);
}
// FIXME this is the wrong place to do this. see https://github.com/dankamongmen/notcurses/issues/451
if(enforce_utf8(n->ncp->nc)){
if(enforce_utf8(n->ncp->nc)){
ncplane_putegc_yx(n->ncp, yoff, bodyoffset, n->items[printidx].selected ? "" : "", NULL);
}else{
}else{
ncplane_putsimple_yx(n->ncp, yoff, bodyoffset, n->items[printidx].selected ? 'X' : '-');
}
}
n->ncp->channels = n->opchannels;
if(printidx == n->current){
n->ncp->channels = (uint64_t)channels_bchannel(n->opchannels) << 32u | channels_fchannel(n->opchannels);