gizak / gizak/termui

ModifierReverse causes characters to become clear in Gauge

Open
#306 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
13.6k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

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

![Issue screen](https://i.imgur.com/F9G99D1.png)

## 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:
```go
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:
```go
if labelXCoordinate+i+1 <= self.Inner.Min.X+barWidth {
style = NewStyle(ColorClear, self.BarColor)
}
```

![Almost fixed](https://i.imgur.com/3qwW0el.png)

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the gauge rendering code containing the ModifierReverse and NewStyle snippet, then reproduce the issue with a gauge above 48% in a terminal. Trace the reverse-color calculation and compare the affected gauge cells and label. Done means the gauge and label remain visible with correct, readable colors across the reported terminal setups.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.