diff --git a/NEWS.md b/NEWS.md index c0eb477a94..e38488947c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index e1bee499bd..a58839e7b1 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -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; diff --git a/src/lib/render.c b/src/lib/render.c index bad60af08c..ff370d9251 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -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; } @@ -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; } @@ -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; + } + } } } }