gizak / termui

Golang terminal dashboard
MIT License
13.06k stars 783 forks source link

ModifierReverse causes characters to become clear in Gauge #306

Open FoxFurry opened 2 years ago

FoxFurry commented 2 years ago

Description

When gauge cells reach the label they (both gauge cells and label) become totally transparent

Issue screen

How to reproduce

Additional

Same behavior everywhere

Possible solution

I figured out that these lines produce such behavior:

if labelXCoordinate+i+1 <= self.Inner.Min.X+barWidth {
       style = NewStyle(self.BarColor, ColorClear, ModifierReverse)
}

Removing ModifierReverse makes it normal (normal assuming we have already the wrong color calculation) Removing ModifierReverse and swapping remaining parameters seems to almost fix the issue:

if labelXCoordinate+i+1 <= self.Inner.Min.X+barWidth {
       style = NewStyle(ColorClear, self.BarColor)
}

Almost fixed

Label color is obviously not getting reversed, so a bad color combination will result in an unreadable label. However, I haven't dig into the mathematics behind reverse color calculation and I cannot assume it's a 100% ModifierReverse issue.

go-hacks commented 2 years ago

Change line 52 of gauge.go to

style.Bg = self.BarColor

this seems to give the desired result. I was unable to find a bit modifier that did what was expected.

Naturally, if you use the same color text as the bar, it's unreadable. I think whomever wrote this was trying to get the bar to have that blank area with the text the color of the bar inside it but even if it worked, it wouldn't look good at all. This fix is MUCH better.