mirror of https://github.com/rivo/tview.git
Added individual cell background colors. Resolves #20
This commit is contained in:
parent
b423641ec2
commit
97450a0de3
20
table.go
20
table.go
|
@ -628,12 +628,14 @@ ColumnLoop:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine colors.
|
// Determine cell colors.
|
||||||
bgColor := t.backgroundColor
|
bgColor := t.backgroundColor
|
||||||
textColor := cell.Color
|
textColor := cell.Color
|
||||||
|
if cell.BackgroundColor != tcell.ColorDefault {
|
||||||
|
bgColor = cell.BackgroundColor
|
||||||
|
}
|
||||||
if cellSelected && !cell.NotSelectable {
|
if cellSelected && !cell.NotSelectable {
|
||||||
bgColor = cell.Color
|
textColor, bgColor = bgColor, textColor
|
||||||
textColor = t.backgroundColor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw cell background.
|
// Draw cell background.
|
||||||
|
@ -647,6 +649,18 @@ ColumnLoop:
|
||||||
}
|
}
|
||||||
cell.x, cell.y, cell.width = x+columnX+1, y+rowY, finalWidth
|
cell.x, cell.y, cell.width = x+columnX+1, y+rowY, finalWidth
|
||||||
|
|
||||||
|
// We may want continuous background colors in rows so change
|
||||||
|
// border/separator background colors, too.
|
||||||
|
if cell.BackgroundColor != tcell.ColorDefault && column > 0 {
|
||||||
|
leftCell := getCell(row, column-1)
|
||||||
|
if leftCell != nil {
|
||||||
|
if cell.BackgroundColor == leftCell.BackgroundColor {
|
||||||
|
ch, _, style, _ := screen.GetContent(x+columnX, y+rowY)
|
||||||
|
screen.SetContent(x+columnX, y+rowY, ch, nil, style.Background(bgColor))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw text.
|
// Draw text.
|
||||||
text := cell.Text
|
text := cell.Text
|
||||||
textWidth := runewidth.StringWidth(text)
|
textWidth := runewidth.StringWidth(text)
|
||||||
|
|
Loading…
Reference in New Issue