diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-23 00:44:08 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-23 00:44:08 +0300 |
commit | bedb9979a9b65dad9d72dcbdb3174508d3714f36 (patch) | |
tree | bc5adfadfac2f58fbfe198aec9d93d96cd84656f /vendor/maunium.net/go/tview/table.go | |
parent | 14903e0cdcd3ba78face2cbe0ad0287da269a1ea (diff) |
Update some dependencies
Diffstat (limited to 'vendor/maunium.net/go/tview/table.go')
-rw-r--r-- | vendor/maunium.net/go/tview/table.go | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/vendor/maunium.net/go/tview/table.go b/vendor/maunium.net/go/tview/table.go index 0446c6a..2491ec7 100644 --- a/vendor/maunium.net/go/tview/table.go +++ b/vendor/maunium.net/go/tview/table.go @@ -33,6 +33,9 @@ type TableCell struct { // The background color of the cell. BackgroundColor tcell.Color + // The style attributes of the cell. + Attributes tcell.AttrMask + // If set to true, this cell cannot be selected. NotSelectable bool @@ -107,6 +110,22 @@ func (c *TableCell) SetBackgroundColor(color tcell.Color) *TableCell { return c } +// SetAttributes sets the cell's text attributes. You can combine different +// attributes using bitmask operations: +// +// cell.SetAttributes(tcell.AttrUnderline | tcell.AttrBold) +func (c *TableCell) SetAttributes(attr tcell.AttrMask) *TableCell { + c.Attributes = attr + return c +} + +// SetStyle sets the cell's style (foreground color, background color, and +// attributes) all at once. +func (c *TableCell) SetStyle(style tcell.Style) *TableCell { + c.Color, c.BackgroundColor, c.Attributes = style.Decompose() + return c +} + // SetSelectable sets whether or not this cell can be selected by the user. func (c *TableCell) SetSelectable(selectable bool) *TableCell { c.NotSelectable = !selectable @@ -684,11 +703,10 @@ ColumnLoop: finalWidth = width - columnX - 1 } cell.x, cell.y, cell.width = x+columnX+1, y+rowY, finalWidth - _, printed := Print(screen, cell.Text, x+columnX+1, y+rowY, finalWidth, cell.Align, cell.Color) + _, printed := printWithStyle(screen, cell.Text, x+columnX+1, y+rowY, finalWidth, cell.Align, tcell.StyleDefault.Foreground(cell.Color)|tcell.Style(cell.Attributes)) if StringWidth(cell.Text)-printed > 0 && printed > 0 { _, _, style, _ := screen.GetContent(x+columnX+1+finalWidth-1, y+rowY) - fg, _, _ := style.Decompose() - Print(screen, string(GraphicsEllipsis), x+columnX+1+finalWidth-1, y+rowY, 1, AlignLeft, fg) + printWithStyle(screen, string(GraphicsEllipsis), x+columnX+1+finalWidth-1, y+rowY, 1, AlignLeft, style) } } |