Skip to content

Commit

Permalink
paint: solve for egc following colors #1068
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jan 10, 2021
1 parent 1a597f2 commit 0a165a9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 49 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ This document attempts to list user-visible changes and any major internal
rearrangements of Notcurses.

* 2.1.5 (not yet released):
* Notcurses **now depends on GNU Readline at build and runtime**, entirely
for the benefit of direct mode, which now prepares GNU Readline for safe
use (unless the new `NCDIRECT_OPTIONS_NO_READLINE` is used).
* `ncplane_putstr_yx()`, `ncplane_putstr_stained()`, and
`ncplane_putnstr_yx()` now return the number of columns output, as
long documented (they were mistakenly returning the number of bytes).
* Notcurses now depends on GNU Readline at build and runtime, entirely
for the benefit of direct mode, which now prepares GNU Readline for safe
use (unless the new `NCDIRECT_OPTIONS_NO_READLINE` is used).

* 2.1.4 (2021-01-03):
* Direct mode now supports `NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS`, and by
Expand Down
2 changes: 0 additions & 2 deletions src/lib/notcurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ notcurses_stop_minimal(void* vnc){
if(nc->tcache.cnorm && tty_emit("cnorm", nc->tcache.cnorm, nc->ttyfd)){
ret = -1;
}
}
if(nc->ttyfd >= 0){
ret |= tcsetattr(nc->ttyfd, TCSANOW, &nc->tpreserved);
}
return ret;
Expand Down
88 changes: 44 additions & 44 deletions src/lib/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,55 +263,13 @@ paint(const ncplane* p, struct crender* rvec, int dstleny, int dstlenx,
if(cell_wide_right_p(targc)){
continue;
}
const nccell* vis = &p->fb[nfbcellidx(p, y, x)];
// if we never loaded any content into the cell (or obliterated it by
// writing in a zero), use the plane's base cell.
if(vis->gcluster == 0 && !cell_double_wide_p(vis)){
vis = &p->basecell;
}
// if we have no character in this cell, we continue to look for a
// character, but our foreground color will still be used unless it's
// been set to transparent. if that foreground color is transparent, we
// still use a character we find here, but its color will come entirely
// from cells underneath us.
if(!crender->p){
// if the following is true, we're a real glyph, and not the right-hand
// side of a wide glyph (nor the null codepoint).
if( (targc->gcluster = vis->gcluster) ){ // index copy only
// we can't plop down a wide glyph if the next cell is beyond the
// screen, nor if we're bisected by a higher plane.
if(cell_double_wide_p(vis)){
// are we on the last column of the real screen? if so, 0x20 us
if(absx >= dstlenx - 1){
targc->gcluster = htole(' ');
targc->width = 1;
// is the next cell occupied? if so, 0x20 us
}else if(crender[1].c.gcluster){
//fprintf(stderr, "NULLING out %d/%d (%d/%d) due to %u\n", y, x, absy, absx, crender[1].c.gcluster);
targc->gcluster = htole(' ');
targc->width = 1;
}else{
targc->stylemask = vis->stylemask;
targc->width = vis->width;
}
}else{
targc->stylemask = vis->stylemask;
targc->width = vis->width;
}
crender->p = p;
}else if(cell_wide_right_p(vis)){
crender->p = p;
targc->width = 0;
}
}

// Background color takes effect independently of whether we have a
// glyph. If we've already locked in the background, it has no effect.
// If it's transparent, it has no effect. Otherwise, update the
// background channel and balpha.
// Evaluate the background first, in case we have HIGHCONTRAST fg text.
if(cell_bg_alpha(targc) > CELL_ALPHA_OPAQUE){
vis = &p->fb[nfbcellidx(p, y, x)];
const nccell* vis = &p->fb[nfbcellidx(p, y, x)];
if(cell_bg_default_p(vis)){
vis = &p->basecell;
}
Expand All @@ -325,7 +283,7 @@ paint(const ncplane* p, struct crender* rvec, int dstleny, int dstlenx,
}

if(cell_fg_alpha(targc) > CELL_ALPHA_OPAQUE){
vis = &p->fb[nfbcellidx(p, y, x)];
const nccell* vis = &p->fb[nfbcellidx(p, y, x)];
if(cell_fg_default_p(vis)){
vis = &p->basecell;
}
Expand All @@ -348,6 +306,48 @@ paint(const ncplane* p, struct crender* rvec, int dstleny, int dstlenx,
}
}
}

// if we never loaded any content into the cell (or obliterated it by
// writing in a zero), use the plane's base cell.
// if we have no character in this cell, we continue to look for a
// character, but our foreground color will still be used unless it's
// been set to transparent. if that foreground color is transparent, we
// still use a character we find here, but its color will come entirely
// from cells underneath us.
if(!crender->p){
const nccell* vis = &p->fb[nfbcellidx(p, y, x)];
if(vis->gcluster == 0 && !cell_double_wide_p(vis)){
vis = &p->basecell;
}
// if the following is true, we're a real glyph, and not the right-hand
// side of a wide glyph (nor the null codepoint).
if( (targc->gcluster = vis->gcluster) ){ // index copy only
// we can't plop down a wide glyph if the next cell is beyond the
// screen, nor if we're bisected by a higher plane.
if(cell_double_wide_p(vis)){
// are we on the last column of the real screen? if so, 0x20 us
if(absx >= dstlenx - 1){
targc->gcluster = htole(' ');
targc->width = 1;
// is the next cell occupied? if so, 0x20 us
}else if(crender[1].c.gcluster){
//fprintf(stderr, "NULLING out %d/%d (%d/%d) due to %u\n", y, x, absy, absx, crender[1].c.gcluster);
targc->gcluster = htole(' ');
targc->width = 1;
}else{
targc->stylemask = vis->stylemask;
targc->width = vis->width;
}
}else{
targc->stylemask = vis->stylemask;
targc->width = vis->width;
}
crender->p = p;
}else if(cell_wide_right_p(vis)){
crender->p = p;
targc->width = 0;
}
}
}
}
}
Expand Down

0 comments on commit 0a165a9

Please sign in to comment.