linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

DarkMode - Source code unreadable #208

Closed fletcher97 closed 1 year ago

fletcher97 commented 1 year ago

When using darkmode the code shown is unreadable as the background color is too light. On version 1.16 (and up to commit 92e21217d3e487952e8fab49f98d3560fbde4be8) the darkmode displayed properly. After the commit 5f659f63801ef7f94c50a0eb5cffa1ea70f73651 it was somewhat broken. Generating the html with both version we can observe a slight shift of the displayed items (not a major issue at all) and a color change to the background of the code making it unreadable. Only the code seems to be affected as the legends stays unchanged (color-wise).

Page generated with 92e21217d3e487952e8fab49f98d3560fbde4be8: 2023-04-08-002757_2240x441_scrot

Page generated with 5f659f63801ef7f94c50a0eb5cffa1ea70f73651: 2023-04-08-002722_2240x454_scrot

Both pages where generated using the same command: genhtml report.info -o html --branch-coverage --demangle-cpp --legend --dark-mode

fletcher97 commented 1 year ago

I have never touched (or read) anything in perl until today so I'm not the best person to create a PR. That being said I think I found the issue. On the bin/genhtml file lines 5195-5207 there is a peace of code that inverts the colors when on dark mode. Playing around with it a bit I figured that if I remove the inverting of the colors and add these 2 lines to force select the colors it starts working properly again (colors only not the indentation/placement problem)

my $bg = $lcovutil::tlaColor{$tla};
# $lcovutil::tlaColor{$tla}     = $lcovutil::tlaTextColor{$tla};
# $lcovutil::tlaTextColor{$tla} = $bg;
$lcovutil::tlaColor{$tla} = "#143E4F" if ($bg eq "#CAD7FE"); # BLUE BG
$lcovutil::tlaColor{$tla} = "#772D16" if ($bg eq "#FF6230"); # RED BG

My guess would be that the code to actually swap the normal colors with the darkmode colors should have gone here. But as a place holder the invert colors was put there and forgotten. I simply used the colors of the palette declared on line 7251 to change them. Only did these 2 but I guess is that all colors should be checked. As I don't know how to program in perl I'll wait for someone with a better understanding to come up with a better way that checks every color.

Hope this helps in resolving the issue :)

henry2cox commented 1 year ago

Fixed in dfbec40, I believe. The fix also updates the code to use CSS classes to set the various colours - so you can override if you like (without changing the perl code).

Henry

fletcher97 commented 1 year ago

Issue looks to be fixed. Thank you very much for the rapid response.