Skip to content

Commit

Permalink
Fix color issues after tcell upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
yogin committed Mar 4, 2021
1 parent 36c01f5 commit 258e078
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ func (s *Service) updateTable() {
// https://godoc.org/github.com/rivo/tview#hdr-Colors
// https://pkg.go.dev/github.com/gdamore/tcell?tab=doc#Color
// https://www.w3schools.com/colors/colors_names.asp
color := tcell.ColorWhite
color := tcell.ColorWhite.TrueColor()
switch instance.State {
case "terminated", "stopped":
color = tcell.ColorGrey
color = tcell.ColorGrey.TrueColor()
case "pending", "stopping", "shutting-down":
color = tcell.ColorCrimson
color = tcell.ColorCrimson.TrueColor()
case "running":
if instance.IsRunningLessThan(15) { // 15 minutes
color = tcell.ColorPaleGreen
color = tcell.ColorPaleGreen.TrueColor()
} else if instance.IsRunningMoreThan(129600) { //  129600 minutes = 90 days (1 quarter)
color = tcell.ColorOrange
color = tcell.ColorOrange.TrueColor()
}
}

Expand All @@ -193,15 +193,15 @@ func (s *Service) updateTable() {
tag := tview.NewTableCell("Tag:" + t).
SetSelectable(false).
SetAttributes(tcell.AttrBold).
SetBackgroundColor(tcell.ColorDimGrey)
SetBackgroundColor(tcell.ColorDimGrey.TrueColor())
s.table.SetCell(0, c, tag)
}

for c, h := range headers {
head := tview.NewTableCell(h).
SetSelectable(false).
SetAttributes(tcell.AttrBold).
SetBackgroundColor(tcell.ColorDimGrey)
SetBackgroundColor(tcell.ColorDimGrey.TrueColor())
s.table.SetCell(0, c+tagsCount, head)
}

Expand All @@ -212,7 +212,8 @@ func (s *Service) updateTable() {
cell := tview.NewTableCell(val).
SetSelectable(true).
SetReference(instance.ID).
SetTextColor(color)
SetTextColor(color).
SetBackgroundColor(tcell.ColorBlack.TrueColor())
s.table.SetCell(row, col, cell)
}

Expand Down

0 comments on commit 258e078

Please sign in to comment.