|
|
@ -582,7 +582,7 @@ ncfputc(char c, FILE* out){
|
|
|
|
static int
|
|
|
|
static int
|
|
|
|
enter_pixel_mode(notcurses* nc, FILE* out){
|
|
|
|
enter_pixel_mode(notcurses* nc, FILE* out){
|
|
|
|
if(!nc->rstate.pixelmode){
|
|
|
|
if(!nc->rstate.pixelmode){
|
|
|
|
if(term_emit("\ePq", out, false)){
|
|
|
|
if(term_emit(nc->tcache.pixelon, out, false)){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -592,7 +592,7 @@ enter_pixel_mode(notcurses* nc, FILE* out){
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
static int
|
|
|
|
leave_pixel_mode(notcurses* nc, FILE* out){
|
|
|
|
leave_pixel_mode(notcurses* nc, FILE* out){
|
|
|
|
if(term_emit("\e\\", out, false)){
|
|
|
|
if(term_emit(nc->tcache.pixeloff, out, false)){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nc->rstate.pixelmode = false;
|
|
|
|
nc->rstate.pixelmode = false;
|
|
|
@ -971,96 +971,98 @@ notcurses_rasterize_inner(notcurses* nc, const ncpile* p, FILE* out){
|
|
|
|
if(goto_location(nc, out, y, x)){
|
|
|
|
if(goto_location(nc, out, y, x)){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// set the style. this can change the color back to the default; if it
|
|
|
|
if(!cell_pixels_p(srccell)){
|
|
|
|
// does, we need update our elision possibilities.
|
|
|
|
// set the style. this can change the color back to the default; if it
|
|
|
|
if(term_setstyles(out, &nc->rstate, srccell,
|
|
|
|
// does, we need update our elision possibilities.
|
|
|
|
nc->tcache.sgr0, nc->tcache.sgr,
|
|
|
|
if(term_setstyles(out, &nc->rstate, srccell,
|
|
|
|
nc->tcache.italics, nc->tcache.italoff,
|
|
|
|
nc->tcache.sgr0, nc->tcache.sgr,
|
|
|
|
nc->tcache.struck, nc->tcache.struckoff)){
|
|
|
|
nc->tcache.italics, nc->tcache.italoff,
|
|
|
|
return -1;
|
|
|
|
nc->tcache.struck, nc->tcache.struckoff)){
|
|
|
|
}
|
|
|
|
|
|
|
|
// if our cell has a default foreground *or* background, we can elide
|
|
|
|
|
|
|
|
// the default set iff one of:
|
|
|
|
|
|
|
|
// * we are a partial glyph, and the previous was default on both, or
|
|
|
|
|
|
|
|
// * we are a no-foreground glyph, and the previous was default background, or
|
|
|
|
|
|
|
|
// * we are a no-background glyph, and the previous was default foreground
|
|
|
|
|
|
|
|
bool nobackground = cell_nobackground_p(srccell);
|
|
|
|
|
|
|
|
if((cell_fg_default_p(srccell)) || (!nobackground && cell_bg_default_p(srccell))){
|
|
|
|
|
|
|
|
if(raster_defaults(nc, cell_fg_default_p(srccell),
|
|
|
|
|
|
|
|
!nobackground && cell_bg_default_p(srccell), out)){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if our cell has a default foreground *or* background, we can elide
|
|
|
|
// if our cell has a non-default foreground, we can elide the
|
|
|
|
// the default set iff one of:
|
|
|
|
// non-default foreground set iff either:
|
|
|
|
// * we are a partial glyph, and the previous was default on both, or
|
|
|
|
// * the previous was non-default, and matches what we have now, or
|
|
|
|
// * we are a no-foreground glyph, and the previous was default background, or
|
|
|
|
// * we are a no-foreground glyph (iswspace() is true)
|
|
|
|
// * we are a no-background glyph, and the previous was default foreground
|
|
|
|
if(cell_fg_palindex_p(srccell)){ // palette-indexed foreground
|
|
|
|
bool nobackground = cell_nobackground_p(srccell);
|
|
|
|
palfg = cell_fg_palindex(srccell);
|
|
|
|
if((cell_fg_default_p(srccell)) || (!nobackground && cell_bg_default_p(srccell))){
|
|
|
|
// we overload lastr for the palette index; both are 8 bits
|
|
|
|
if(raster_defaults(nc, cell_fg_default_p(srccell),
|
|
|
|
if(nc->rstate.fgpalelidable && nc->rstate.lastr == palfg){
|
|
|
|
!nobackground && cell_bg_default_p(srccell), out)){
|
|
|
|
++nc->stats.fgelisions;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(term_fg_palindex(nc, out, palfg)){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++nc->stats.fgemissions;
|
|
|
|
|
|
|
|
nc->rstate.fgpalelidable = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nc->rstate.lastr = palfg;
|
|
|
|
// if our cell has a non-default foreground, we can elide the
|
|
|
|
nc->rstate.fgdefelidable = false;
|
|
|
|
// non-default foreground set iff either:
|
|
|
|
nc->rstate.fgelidable = false;
|
|
|
|
// * the previous was non-default, and matches what we have now, or
|
|
|
|
}else if(!cell_fg_default_p(srccell)){ // rgb foreground
|
|
|
|
// * we are a no-foreground glyph (iswspace() is true)
|
|
|
|
cell_fg_rgb8(srccell, &r, &g, &b);
|
|
|
|
if(cell_fg_palindex_p(srccell)){ // palette-indexed foreground
|
|
|
|
if(nc->rstate.fgelidable && nc->rstate.lastr == r && nc->rstate.lastg == g && nc->rstate.lastb == b){
|
|
|
|
palfg = cell_fg_palindex(srccell);
|
|
|
|
++nc->stats.fgelisions;
|
|
|
|
// we overload lastr for the palette index; both are 8 bits
|
|
|
|
}else{
|
|
|
|
if(nc->rstate.fgpalelidable && nc->rstate.lastr == palfg){
|
|
|
|
if(term_fg_rgb8(nc->tcache.RGBflag, nc->tcache.setaf, nc->tcache.colors, out, r, g, b)){
|
|
|
|
++nc->stats.fgelisions;
|
|
|
|
return -1;
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(term_fg_palindex(nc, out, palfg)){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
++nc->stats.fgemissions;
|
|
|
|
|
|
|
|
nc->rstate.fgpalelidable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++nc->stats.fgemissions;
|
|
|
|
nc->rstate.lastr = palfg;
|
|
|
|
nc->rstate.fgelidable = true;
|
|
|
|
nc->rstate.fgdefelidable = false;
|
|
|
|
}
|
|
|
|
nc->rstate.fgelidable = false;
|
|
|
|
nc->rstate.lastr = r; nc->rstate.lastg = g; nc->rstate.lastb = b;
|
|
|
|
}else if(!cell_fg_default_p(srccell)){ // rgb foreground
|
|
|
|
nc->rstate.fgdefelidable = false;
|
|
|
|
cell_fg_rgb8(srccell, &r, &g, &b);
|
|
|
|
nc->rstate.fgpalelidable = false;
|
|
|
|
if(nc->rstate.fgelidable && nc->rstate.lastr == r && nc->rstate.lastg == g && nc->rstate.lastb == b){
|
|
|
|
}
|
|
|
|
++nc->stats.fgelisions;
|
|
|
|
// if our cell has a non-default background, we can elide the
|
|
|
|
}else{
|
|
|
|
// non-default background set iff either:
|
|
|
|
if(term_fg_rgb8(nc->tcache.RGBflag, nc->tcache.setaf, nc->tcache.colors, out, r, g, b)){
|
|
|
|
// * we do not use the background, because the cell is all-foreground,
|
|
|
|
return -1;
|
|
|
|
// * the previous was non-default, and matches what we have now, or
|
|
|
|
}
|
|
|
|
if(nobackground){
|
|
|
|
++nc->stats.fgemissions;
|
|
|
|
++nc->stats.bgelisions;
|
|
|
|
nc->rstate.fgelidable = true;
|
|
|
|
}else if(cell_bg_palindex_p(srccell)){ // palette-indexed background
|
|
|
|
|
|
|
|
palbg = cell_bg_palindex(srccell);
|
|
|
|
|
|
|
|
if(nc->rstate.bgpalelidable && nc->rstate.lastbr == palbg){
|
|
|
|
|
|
|
|
++nc->stats.bgelisions;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(term_bg_palindex(nc, out, palbg)){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++nc->stats.bgemissions;
|
|
|
|
nc->rstate.lastr = r; nc->rstate.lastg = g; nc->rstate.lastb = b;
|
|
|
|
nc->rstate.bgpalelidable = true;
|
|
|
|
nc->rstate.fgdefelidable = false;
|
|
|
|
|
|
|
|
nc->rstate.fgpalelidable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nc->rstate.lastr = palbg;
|
|
|
|
// if our cell has a non-default background, we can elide the
|
|
|
|
nc->rstate.bgdefelidable = false;
|
|
|
|
// non-default background set iff either:
|
|
|
|
nc->rstate.bgelidable = false;
|
|
|
|
// * we do not use the background, because the cell is all-foreground,
|
|
|
|
}else if(!cell_bg_default_p(srccell)){ // rgb background
|
|
|
|
// * the previous was non-default, and matches what we have now, or
|
|
|
|
cell_bg_rgb8(srccell, &br, &bg, &bb);
|
|
|
|
if(nobackground){
|
|
|
|
if(nc->rstate.bgelidable && nc->rstate.lastbr == br && nc->rstate.lastbg == bg && nc->rstate.lastbb == bb){
|
|
|
|
|
|
|
|
++nc->stats.bgelisions;
|
|
|
|
++nc->stats.bgelisions;
|
|
|
|
}else{
|
|
|
|
}else if(cell_bg_palindex_p(srccell)){ // palette-indexed background
|
|
|
|
if(term_bg_rgb8(nc->tcache.RGBflag, nc->tcache.setab,
|
|
|
|
palbg = cell_bg_palindex(srccell);
|
|
|
|
nc->tcache.colors, out, br, bg, bb,
|
|
|
|
if(nc->rstate.bgpalelidable && nc->rstate.lastbr == palbg){
|
|
|
|
nc->tcache.bg_collides_default)){
|
|
|
|
++nc->stats.bgelisions;
|
|
|
|
return -1;
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(term_bg_palindex(nc, out, palbg)){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
++nc->stats.bgemissions;
|
|
|
|
|
|
|
|
nc->rstate.bgpalelidable = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nc->rstate.lastr = palbg;
|
|
|
|
|
|
|
|
nc->rstate.bgdefelidable = false;
|
|
|
|
|
|
|
|
nc->rstate.bgelidable = false;
|
|
|
|
|
|
|
|
}else if(!cell_bg_default_p(srccell)){ // rgb background
|
|
|
|
|
|
|
|
cell_bg_rgb8(srccell, &br, &bg, &bb);
|
|
|
|
|
|
|
|
if(nc->rstate.bgelidable && nc->rstate.lastbr == br && nc->rstate.lastbg == bg && nc->rstate.lastbb == bb){
|
|
|
|
|
|
|
|
++nc->stats.bgelisions;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if(term_bg_rgb8(nc->tcache.RGBflag, nc->tcache.setab,
|
|
|
|
|
|
|
|
nc->tcache.colors, out, br, bg, bb,
|
|
|
|
|
|
|
|
nc->tcache.bg_collides_default)){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
++nc->stats.bgemissions;
|
|
|
|
|
|
|
|
nc->rstate.bgelidable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++nc->stats.bgemissions;
|
|
|
|
nc->rstate.lastbr = br; nc->rstate.lastbg = bg; nc->rstate.lastbb = bb;
|
|
|
|
nc->rstate.bgelidable = true;
|
|
|
|
nc->rstate.bgdefelidable = false;
|
|
|
|
|
|
|
|
nc->rstate.bgpalelidable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nc->rstate.lastbr = br; nc->rstate.lastbg = bg; nc->rstate.lastbb = bb;
|
|
|
|
|
|
|
|
nc->rstate.bgdefelidable = false;
|
|
|
|
|
|
|
|
nc->rstate.bgpalelidable = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//fprintf(stderr, "RAST %08x [%s] to %d/%d cols: %u %016lx\n", srccell->gcluster, pool_extended_gcluster(&nc->pool, srccell), y, x, srccell->width, srccell->channels);
|
|
|
|
//fprintf(stderr, "RAST %08x [%s] to %d/%d cols: %u %016lx\n", srccell->gcluster, pool_extended_gcluster(&nc->pool, srccell), y, x, srccell->width, srccell->channels);
|
|
|
|
if(term_putc(nc, out, &nc->pool, srccell)){
|
|
|
|
if(term_putc(nc, out, &nc->pool, srccell)){
|
|
|
|