wdvi

network DVI viewer
Log | Files | Refs

commit c84cd7867f7b1828fad454f4a5bd7c8498d2f944
parent 701de0b8ce593dc2b875c3dd7c72e0fe28664847
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Fri, 17 Sep 2021 19:04:29 +0000

when -rv is given reverse all color specials

-rv mode did not work well with color specials because the colors were
displayed unchanged, leading to contrast and other issues. in some cases
video reversion was not detected and characters were printed black on
black.

Diffstat:
Mevents.h | 2--
Mspecial.c | 17++++++++++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/events.h b/events.h @@ -87,8 +87,6 @@ struct fgrec { struct rgb color; Boolean pixel_good; /* if the pixel entry is valid */ Pixel pixel; - Boolean palette_good; /* if the palette entry is valid */ - Pixel palette[16]; /* non-TrueColor only */ }; struct bgrec *bg_head = NULL; /* head of list */ diff --git a/special.c b/special.c @@ -590,6 +590,17 @@ static struct dvipscolor colornames[] = { #undef CVPART #undef DVIPSCOLORDESC +static void +reverse_color(struct rgb *rgbp) +{ + if (resource.reverse == False) + return; + + rgbp->r = 65535 - rgbp->r; + rgbp->g = 65535 - rgbp->g; + rgbp->b = 65535 - rgbp->b; +} + static Boolean parse_color(cp0, cp, rgbp) const char *cp0, *cp; @@ -605,12 +616,14 @@ parse_color(cp0, cp, rgbp) rgbp->r = r * 65535 + 0.5; rgbp->g = g * 65535 + 0.5; rgbp->b = b * 65535 + 0.5; + reverse_color(rgbp); return True; } } else if (memicmp(cp, "gray ", 5) == 0) { if (sscanf(cp + 4, "%lf", &r) == 1 && r >= 0 && r <= 1) { rgbp->r = rgbp->g = rgbp->b = r * 65535 + 0.5; + reverse_color(rgbp); return True; } } @@ -626,6 +639,7 @@ parse_color(cp0, cp, rgbp) rgbp->g = (g < 0 ? 0 : g * 65535 + 0.5); b = 1.0 - b - k; /* yellow --> blue */ rgbp->b = (b < 0 ? 0 : b * 65535 + 0.5); + reverse_color(rgbp); return True; } } @@ -651,6 +665,7 @@ parse_color(cp0, cp, rgbp) rgbp->r = r * 65535 + 0.5; rgbp->g = g * 65535 + 0.5; rgbp->b = b * 65535 + 0.5; + reverse_color(rgbp); return True; } } @@ -674,6 +689,7 @@ parse_color(cp0, cp, rgbp) j = memcmp(cp, dp->name, len); if (j == 0) { *rgbp = dp->color; + reverse_color(rgbp); return True; } } @@ -871,7 +887,6 @@ set_fg_color(const struct rgb *color) fg_current->next = NULL; fg_current->color = *color; fg_current->pixel_good = False; - fg_current->palette_good = False; break; } if (fg_current->color.r == color->r