[#1223] lens/tui: Fix color formatting

Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
Aleksey Savchuk 2024-08-13 23:30:54 +03:00
parent 1515d8b7b4
commit e3490cf0e1
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View file

@ -32,7 +32,7 @@ func NewHexColor(hexColor string) tcell.Color {
}
type FormatOptions struct {
Foreground tcell.Color
Color tcell.Color
Bold,
Italic,
@ -67,10 +67,10 @@ func Format(s string, opts FormatOptions) string {
strikeThroughTag,
)
color := strconv.FormatInt(int64(opts.Foreground.Hex()), 16)
color := strconv.FormatInt(int64(opts.Color.Hex()), 16)
return fmt.Sprintf(
"[#%06s::%s]%s[white::-]",
"[#%06s::%s]%s[-::-]",
color,
attributes,
s,
@ -78,5 +78,5 @@ func Format(s string, opts FormatOptions) string {
}
func FormatSimple(s string, c tcell.Color) string {
return Format(s, FormatOptions{Foreground: c})
return Format(s, FormatOptions{Color: c})
}

View file

@ -153,8 +153,10 @@ func (v *RecordsView) Draw(screen tcell.Screen) {
text := result.String()
if index == v.selectedRecordIndex {
text = fmt.Sprintf("[:white]%s[:black]", text)
tview.Print(screen, text, x, y, width, tview.AlignLeft, tview.Styles.PrimitiveBackgroundColor)
} else {
tview.Print(screen, text, x, y, width, tview.AlignLeft, tview.Styles.PrimaryTextColor)
}
tview.Print(screen, text, x, y, width, tview.AlignLeft, tview.Styles.PrimaryTextColor)
y++
}