From 310d8aeec955c48cdcdc09bd542e48f277de6491 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 26 Feb 2021 02:21:08 -0500 Subject: [PATCH] paint: carry through pixel bit #200 --- src/lib/blit.c | 2 +- src/lib/direct.cpp | 13 +++++++++++-- src/lib/internal.h | 8 ++++++-- src/lib/render.c | 7 ++++--- src/player/play.cpp | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index b52c790a9..68f1c7309 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -898,7 +898,7 @@ sixel_blit(ncplane* nc, int placey, int placex, int linesize, if(pool_blit_direct(&nc->pool, c, sixel, offset, 1) <= 0){ return -1; } - cell_set_pixels(c); + cell_set_pixels(c, 1); } // FIXME otherwise, reset? } } diff --git a/src/lib/direct.cpp b/src/lib/direct.cpp index 4d62048a1..b2f6be033 100644 --- a/src/lib/direct.cpp +++ b/src/lib/direct.cpp @@ -416,7 +416,9 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ } if(!channels_pixel_p(channels)){ if(pixelmode){ - // FIXME leave pixel mode + if(term_emit(n->tcache.pixeloff, n->ttyfp, false)){ + return -1; + } pixelmode = false; } if(channels_fg_alpha(channels) == CELL_ALPHA_TRANSPARENT){ @@ -430,7 +432,9 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ ncdirect_set_bg_rgb(n, channels_bg_rgb(channels)); } }else if(!pixelmode){ - // FIXME enter pixel mode + if(term_emit(n->tcache.pixelon, n->ttyfp, false)){ + return -1; + } pixelmode = true; } //fprintf(stderr, "%03d/%03d [%s] (%03dx%03d)\n", y, x, egc, dimy, dimx); @@ -443,6 +447,11 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){ // yes, we want to reset colors and emit an explicit new line following // each line of output; this is necessary if our output is lifted out and // used in something e.g. paste(1). + if(pixelmode){ + if(term_emit(n->tcache.pixeloff, n->ttyfp, false)){ + return -1; + } + } // FIXME replace with a SGR clear ncdirect_set_fg_default(n); ncdirect_set_bg_default(n); diff --git a/src/lib/internal.h b/src/lib/internal.h index 33379f3d9..3a4acc4c7 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -634,8 +634,12 @@ cell_pixels_p(const nccell* c){ } static inline nccell* -cell_set_pixels(nccell* c){ - c->channels |= CELL_PIXEL_GRAPHICS; +cell_set_pixels(nccell* c, unsigned p){ + if(p){ + c->channels |= CELL_PIXEL_GRAPHICS; + }else{ + c->channels &= ~CELL_PIXEL_GRAPHICS; + } return c; } diff --git a/src/lib/render.c b/src/lib/render.c index c12300ce5..c83fcb546 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -401,6 +401,7 @@ paint(const ncplane* p, struct crender* rvec, int dstleny, int dstlenx, targc->stylemask = vis->stylemask; targc->width = vis->width; } + cell_set_pixels(targc, cell_pixels_p(vis)); crender->p = p; }else if(cell_wide_right_p(vis)){ crender->p = p; @@ -607,9 +608,9 @@ term_putc(notcurses* nc, FILE* out, const egcpool* e, const nccell* c){ if(enter_pixel_mode(nc, out)){ return -1; } - if(ncfputs(egcpool_extended_gcluster(e, c), out) == EOF){ - return -1; - } + } + if(ncfputs(egcpool_extended_gcluster(e, c), out) == EOF){ + return -1; } }else{ if(nc->rstate.pixelmode){ diff --git a/src/player/play.cpp b/src/player/play.cpp index d8ec55dc9..a9a6942d4 100644 --- a/src/player/play.cpp +++ b/src/player/play.cpp @@ -304,7 +304,7 @@ auto main(int argc, char** argv) -> int { ncscale_e scalemode; notcurses_options ncopts{}; ncopts.flags = NCOPTION_VERIFY_SIXEL; - ncblitter_e blitter = NCBLIT_DEFAULT; + ncblitter_e blitter = NCBLIT_PIXEL; bool quiet = false; bool loop = false; auto nonopt = handle_opts(argc, argv, ncopts, &quiet, ×cale, &scalemode,