termui icon indicating copy to clipboard operation
termui copied to clipboard

ModifierReverse causes characters to become clear in Gauge

Open FoxFurry opened this issue 3 years ago • 1 comments

Description

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

Issue screen

How to reproduce

  • Create a gauge with any style
  • Set percentage to >48%

Additional

  • Shells:
    • fish
    • zsh
    • bash
  • Color scheme:
    • sweet-mars
    • breeze
    • linux-dark
  • Terminal emulators
    • Terminator
    • Alacritty
    • Konsole
    • Yakuake

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.

FoxFurry avatar Oct 09 '21 23:10 FoxFurry

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.

go-hacks avatar Nov 18 '21 11:11 go-hacks